function openWindow(u,n,w,h,l,t,c,f,x) { //v2.0 4LevelWebs
  var ww=((screen.width-w)/2);if(c==1){l=ww;t=(screen.height-h)/2;}if(c==2){l=ww}
	f+=',top='+t+',left='+l;LvlWin = window.open(u,n,f);LvlWin.focus();
	document.MM_returnValue=false;
}

function validateBlankField(obj) {
	if(trim(obj.value)=='') {
		alert("All * fields are mandatory");
		obj.value='';
		obj.focus();
		return false;
	}
	return true;
}

function trim(s) {
  while (s.substring(0,1) == ' ') {
    s = s.substring(1,s.length);
  }
  while (s.substring(s.length-1,s.length) == ' ') {
    s = s.substring(0,s.length-1);
  }
  return s;
}

//validate combo box if first field is selected.
function validateCombo(cbo) {
	if(cbo.options.selectedIndex==0) { 
		alert("All * marked fields are mandatory");
		cbo.focus();
		return false;
	}
	return true;
}

function validateRadio(rad) {
	var chk=false;
		
	if(rad.length!=null) {
		for(var i=0;i<rad.length;i++) {
			if(rad[i].checked) {
				chk=true;
				break;
			}
		}
	} else {
		if(rad.checked)
			chk = true;
	}
	
	return chk;
}
function toggleMenu(divSubmenu) {
	var div = document.getElementById(divSubmenu);
	if(div.style.display=='none')
		div.style.display='block';
	else if(div.style.display=='block')
		div.style.display='block';
		
}

function viewVideo(flv) {
	w = 640;
	h = 438;
	openWindow('video.php?VideoID='+flv,'',w,h,'0','0','1','titlebar=no,scrollbars=no,width='+w+',height='+h);
}

function printPage(url) {
	width = 840;
	height = 600;
	openWindow(url,'',width,height,'0','0','1','titlebar=no,scrollbars=yes,width='+width+',height='+height);	
}

function openImageEditor(src,dest,thumb_w,thumb_h,ref,resize){
	var w = 1020;
	var h = 520;
	ref = urlencode(ref);
	//window.location.href='image_editor.php?hdnSrc='+src+'&hdnDest='+dest+'&hdnThumbWidth='+thumb_w+'&hdnThumbHeight='+thumb_h+'&hdnMultiple=0&hdnRef='+urlencode(ref);
	openWindow('image_editor.php?hdnSrc='+src+'&hdnDest='+dest+'&hdnThumbWidth='+thumb_w+'&hdnThumbHeight='+thumb_h+'&hdnMultiple=0&hdnResize='+resize+'&hdnRef='+ref,'',w,h,'0','0','1','titlebar=no,scrollbars=yes,resizable=no,directories=no,width='+w+',height='+h);
}

function openBulkImageEditor(src,dest,thumb_w,thumb_h,arrImg,file_path,src_suffix,dest_suffix,watermark,ref,resize){
	var w = 1020;
	var h = 520;
	ref = urlencode(ref);
	var url = 'image_editor.php?hdnSrc='+src+'&hdnDest='+dest+'&hdnThumbWidth='+thumb_w+'&hdnThumbHeight='+thumb_h+'&arrImg='+arrImg+'&hdnFilePath='+file_path+'&hdnSrcSuffix='+src_suffix+'&hdnDestSuffix='+dest_suffix+'&hdnMultiple=1&hdnWatermark='+watermark+'&hdnResize='+resize+'&hdnRef='+ref;
	openWindow(url,'',w,h,'0','0','1','titlebar=no,scrollbars=yes,resizable=no,directories=no,width='+w+',height='+h);
}

function openWin(url,width,height) {
	openWindow(url,'',width,height,'0','0','1','titlebar=no,scrollbars=yes,width='+width+',height='+height);	
}
