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;
}
*/
// Removes leading whitespaces
function LTrim( value ) {
	
	var re = /\s*((\S+\s*)*)/;
	return value.replace(re, "$1");
	
}

// Removes ending whitespaces
function RTrim( value ) {
	
	var re = /((\s*\S+)*)\s*/;
	return value.replace(re, "$1");
	
}

// Removes leading and ending whitespaces
function trim( value ) {
	
	return LTrim(RTrim(value));
	
}

//validate combo box if first field is selected.
function validateCombo(cbo) {
	if(cbo.options.selectedIndex==0) { 
		alert("All * marked fields are mendatory");
		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);
}
