function popup(url, title, w, h) {
	h = (h == '0') ? '315' : h;
	w = (w =='0') ? '415' : w;
	window.open(url,title,'height=' + h + ',width=' + w + ',resizable=yes,toolbars=no,scrollbars=yes');
}

function onLoad ()
{
	
}

function submitPopUpForm(id,filename,ref) {
		
	opener.setImage(id,filename, ref);
	window.close();
}

function submitSelectedFile(id,filename) {
		
	opener.setFile(id,filename);
	window.close();
}
	
function getRef(obj){
  	return(typeof obj == "string") ? document.getElementById(obj) : obj;
}

function setImage(id,filename, ref){
	var updateElement = getRef('input_' + ref + '_imgThumbnailID');
	updateElement.value = id;
	
	var imageElement = getRef('input_' + ref + '_imgThumbnail');
	imageElement.src = filename;
}

function removeImage(){
	var updateElement = getRef('input_f7_imgThumbnailID');
	updateElement.value = 0;
	
	var imageElement = getRef('input_f7_imgThumbnail');
	imageElement.src = '/cms/core/graphics/image_blank.gif';
}

function setFile(id,filename){
	var updateElement = getRef('input_fileInfo_fileID');
	updateElement.value = id;
	
	var fileElement = getRef('fileTitle');
	var new_txt = document.createTextNode(filename);
    fileElement.replaceChild(new_txt, fileElement.childNodes[0]);
    
    var removeElement = getRef('removeFile');
    removeElement.style.visibility = "visible";
}

function removeFile(){
	var updateElement = getRef('input_fileInfo_fileID');
	updateElement.value = '0';
	
	var fileElement = getRef('fileTitle');
	var new_txt = document.createTextNode("[add new file]");
    fileElement.replaceChild(new_txt, fileElement.childNodes[0]);
    
    var removeElement = getRef('removeFile');
    removeElement.style.visibility = "hidden";
}

