function openWindow(theURL,winName,features) { 
  window.open(theURL,winName,features);
}

function del(theName){
		theName.value="";
return true;
}

function checkvalue(theName){
   if (theName.value){
	if (!theName.checked){
			alert("Please make your selection!"); 
		return false;
		}
   }else{
	len=theName.length;
	flag=false;
	for (i=0;i<len;i++)
	{
		if ( theName[i].checked)
			flag=true;
	}
	if (!flag){
		alert("Please make your selection!");
		return false;
	}
   } 
   return true;
}

function checkfrm_login(){
	temp=document.form_login.user_id;
	if (temp.value==""){
		alert("Please enter your username!");
		temp.focus();
		return false;
	}else{
		tmp=temp.value;
		while(tmp.charAt(0)==" ")
			tmp=tmp.substring(1);
		if (tmp==""){
			alert("Please enter your username!");
			temp.focus();
			return false;
		}
	}
	temp=document.form_login.user_password;
	if (temp.value==""){
		alert("Please enter your password!");
		temp.focus();
		return false;
	}else{
		tmp=temp.value;
		while(tmp.charAt(0)==" ")
			tmp=tmp.substring(1);
		if (tmp==""){
			alert("Please enter your password!");
			temp.focus();
			return false;
		}
	}
return true;
}

function checkfrm_search(){
	temp=document.form_search.keyword;
	if (temp.value==""){
		alert("Please enter a keyword!");
		document.form_search.keyword.focus();
		return false;
	}else{
		if (temp.value=="Keyword"){
			alert("Please enter a keyword!");
			document.form_search.keyword.value="";
			document.form_search.keyword.focus();
			return false;
		}
	}
return true;
}

function checkfrm_search1(){
	temp=document.form_search1.keyword;
	if (temp.value==""){
		alert("Please enter a keyword!");
		document.form_search1.keyword.focus();
		return false;
	}else{
		if (temp.value=="Keyword"){
			alert("Please enter a keyword!");
			document.form_search1.keyword.value="";
			document.form_search1.keyword.focus();
			return false;
		}
	}
return true;
}

function checkfrm_regis_username()
{
	temp=document.form_regis_username.username;
	if (temp.value==""){
		alert("Please enter a username!");
		temp.focus();
		return false;
	}else{
		tmp=temp.value;
		while(tmp.charAt(0)==" ")
			tmp=tmp.substring(1);
		if (tmp==""){
			alert("Please enter a username!");
			temp.focus();
			return false;
		}
	}
return true;
}

function checkfrm_register()
{
	temp=document.form_register.password;
	if (temp.value==""){
		alert("Please enter a password!");
		temp.focus();
		return false;
	}else{
		tmp=temp.value;
		while(tmp.charAt(0)==" ")
			tmp=tmp.substring(1);
		if (tmp==""){
			alert("Please enter a password!");
			temp.focus();
			return false;
		}
	}
	temp=document.form_register.repassword;
	if (temp.value==""){
		alert("Please enter your password to confirm!");
		temp.focus();
		return false;
	}else{
		tmp=temp.value;
		while(tmp.charAt(0)==" ")
			tmp=tmp.substring(1);
		if (tmp==""){
			alert("Please enter your password to confirm!");
			temp.focus();
			return false;
		}
	}

	temp1=document.form_register.password;
	temp2=document.form_register.repassword;
	if (temp1.value!=temp2.value){
		alert("Confirmed password is not same as password!");
		temp2.focus();
		return false;
	}

	temp=document.form_register.email.value
	if ((temp == null) || (temp.length == 0)){
	    window.alert("Please enter your E-mail!");	
		document.form_register.email.focus();
		return false;
	}		
	len = temp.length;
	if(len>0)
	{
	  if (len > 50)
	  {
		window.alert("Email should not be longer than 50 characters!");
		document.form_register.email.focus();
		return false;
	  }
	  pos1 = temp.indexOf("@");
	  pos2 = temp.indexOf(".");
	  pos3 = temp.lastIndexOf("@");
	  pos4 = temp.lastIndexOf(".");
	  if ((pos1 <= 0)||(pos1 == len)||(pos2 <= 0)||(pos2 == len))
	  {
		window.alert("Please enter a valid email!");
		document.form_register.email.focus();
		return false;
	  }
	  else
	  {
		if( (pos1 == pos2 - 1)||(pos1 == pos2 + 1)||( pos1 != pos3 )||( pos4 < pos3 ) )
		{
			window.alert("Please enter a valid email!");
		    document.form_register.email.focus();
		    return false;
		}
	  }		
	}
	temp=document.form_register.unit_name;
	if (temp.value==""){
		alert("Please enter your organization's name!");
		temp.focus();
		return false;
	}else{
		tmp=temp.value;
		while(tmp.charAt(0)==" ")
			tmp=tmp.substring(1);
		if (tmp==""){
			alert("Please enter your organization's name!");
			temp.focus();
			return false;
		}
	}
return true;
}

function checkfrm_message(){
	temp=document.form_message.cont;
	if (temp.value==""){
		alert("Please enter the content for your enquiry!");
		temp.focus();
		return false;
	}else{
		tmp=temp.value;
		while(tmp.charAt(0)==" ")
			tmp=tmp.substring(1);
		if (tmp==""){
			alert("Please enter the content for your enquiry!");
			temp.focus();
			return false;
		}
	}
return true;
}

function checkfrm_note(){
	temp = document.form_note.note_title;
	if (temp.value==""){
		alert("Please enter a title!");	
		temp.focus();
		return false;
	}else{
		tmp=temp.value;
		while(tmp.charAt(0)==" ")
			tmp=tmp.substring(1);
		if (tmp==""){
			alert("Please enter a title!");
			temp.focus();
			return false;
		}
	}
	temp = document.form_note.note_name;
	if (temp.value==""){
		alert("Please enter your name!");	
		temp.focus();
		return false;
	}else{
		tmp=temp.value;
		while(tmp.charAt(0)==" ")
			tmp=tmp.substring(1);
		if (tmp==""){
			alert("Please enter your name!");
			temp.focus();
			return false;
		}
	}
return true;
}

function MM_preloadImages() { 
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_swapImgRestore() { 
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_findObj(n, d) { 
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImage() { 
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}

function load()
  { if (form_shortcut.select2.selectedIndex > 0) location = form_shortcut.select2.options[form_shortcut.select2.selectedIndex].value;}