	
	function validEmail(email){
		invalidChars = " /:,;";
		
		if (email == ""){
			alert(email+" [ Invalid e-Mail Address ]");
			return false;
		}
		
		for (i=0; i<invalidChars.length; i++){
			badChar = invalidChars.charAt(i);
			if (email.indexOf(badChar,0) > -1){
				alert(email+" [ Invalid e-Mail Address ]");				
				return false;
			}
		}
		atPos = email.indexOf("@",1);
		if (atPos == -1){
			alert(email+" [ Invalid e-Mail Address ]");
			return false;
		}
		if (email.indexOf("@",atPos+1) > -1){
			alert(email+" [ Invalid e-Mail Address ]");
			return false;
		}
		periodPos = email.indexOf(".",atPos);
		if (periodPos+3 > email.length){
			alert(email+" [ Invalid e-Mail Address ]");
			return false;
		}
		return true;
	}
	
	
	//Function to create an XMLHttp Object.
	function getxmlhttp (){
		//Create a boolean variable to check for a valid microsoft active X instance.
		var xmlhttp = false;
		
		//Check if we are using internet explorer.
		try {
			//If the javascript version is greater than 5.
			xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
		} catch (e) {
			//If not, then use the older active x object.
			try {
				//If we are using internet explorer.
				xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
			} catch (E) {
				//Else we must be using a non-internet explorer browser.
				xmlhttp = false;
			}
		}
		
		//If we are using a non-internet explorer browser, create a javascript instance of the object.
		if (!xmlhttp && typeof XMLHttpRequest != 'undefined') {
			xmlhttp = new XMLHttpRequest();
		}
		
		return xmlhttp;
	}
	
	//Function to process an XMLHttpRequest.
	function processajax (obj){
		if(obj == "delItem"){
			if(confirm("Are you sure you want to delete this/these item(s)?")){	
				document.obj.submit();
				return true;
			}
			return false;
		}else{
			if(confirm("NB: \n Pls, are you sure that all input with red asteriks \n are correctly entered?")){
				document.obj.submit();
				return true;
			}
			return false;
		}
		return false;
	}
	
	//Function to process an XMLHttpRequest.
	
	function ajaxLoadMain(serverPage, obj,obj1,obj2){
		
		showLoadMsg ('Loading...',obj);
		document.getElementById(obj).style.visibility = "visible";
		
		xmlhttp = getxmlhttp();
		var url = serverPage+"?ID="+obj1+"&action="+obj2;
		//alert(url);
		xmlhttp.open("POST", url, true);
		xmlhttp.onreadystatechange = function() {
			if (xmlhttp.readyState == 4 && xmlhttp.status == 200) {
				document.getElementById(obj).innerHTML = xmlhttp.responseText;
			}
		}
		xmlhttp.send(null);
		
	}
	
	
	function ajaxLoadMainPagnate(serverPage, obj,obj1,obj2,obj3){
		
		showLoadMsg ('Loading...',obj);
		document.getElementById(obj).style.visibility = "visible";
		if(obj2 == 'delete'){
			if(confirm("Are you sure you want to delete this item(s)?")){
				xmlhttp = getxmlhttp();
				var url = serverPage+"?ID="+obj1+"&action="+obj2+"&page="+obj3;
				//alert(url);
				xmlhttp.open("POST", url, true);
				xmlhttp.onreadystatechange = function() {
					if (xmlhttp.readyState == 4 && xmlhttp.status == 200) {
						document.getElementById(obj).innerHTML = xmlhttp.responseText;
					}
				}
				xmlhttp.send(null);
			}else{
				xmlhttp = getxmlhttp();
				var url = serverPage+"?ID="+obj1+"&action=disp&page=1";
				//alert(url);
				xmlhttp.open("POST", url, true);
				xmlhttp.onreadystatechange = function() {
					if (xmlhttp.readyState == 4 && xmlhttp.status == 200) {
						document.getElementById(obj).innerHTML = xmlhttp.responseText;
					}
				}
				xmlhttp.send(null);
			}
		}else{
			xmlhttp = getxmlhttp();
			var url = serverPage+"?ID="+obj1+"&action="+obj2+"&page="+obj3;
			//alert(url);
			xmlhttp.open("POST", url, true);
			xmlhttp.onreadystatechange = function() {
				if (xmlhttp.readyState == 4 && xmlhttp.status == 200) {
					document.getElementById(obj).innerHTML = xmlhttp.responseText;
				}
			}
			xmlhttp.send(null);
		}
		
	}
	
	function ajaxLoadMainAction(serverPage, obj,obj1,obj2){
		showLoadMsg ('Loading...',obj);
		document.getElementById(obj).style.visibility = "visible";
		if(obj2 == 'delete'){
			if(confirm("Are you sure you want to delete this item(s)?")){
				xmlhttp = getxmlhttp();
				var url = serverPage+"?ID="+obj1+"&action="+obj2;
				//alert(url);
				xmlhttp.open("POST", url, true);
				xmlhttp.onreadystatechange = function() {
					if (xmlhttp.readyState == 4 && xmlhttp.status == 200) {
						//alert(obj);
						document.getElementById(obj).innerHTML = xmlhttp.responseText;	
					}
				}
				xmlhttp.send(null);
			}else{
				ajaxLoadMain(serverPage, obj,obj1,'disp');
			}
		}
	}
	
	//Function to output a loading message.
	function showLoadMsg (msg,obj){
		//var addobj = '';
		document.getElementById(obj).innerHTML = '<img src="images/wait.gif" alt="Loading..." /> ' + msg;
	}

	function processajaxFORM (serverPage, obj, str, theform){
		showLoadMsg ('Loading...',obj);
		document.getElementById(obj).style.visibility = "visible";
		
		xmlhttp = getxmlhttp();
		xmlhttp.open("POST", serverPage, true);
		xmlhttp.setRequestHeader("Content-Type","application/x-www-form-urlencoded; charset=UTF-8");
		xmlhttp.onreadystatechange = function() {
			if (xmlhttp.readyState == 4 && xmlhttp.status == 200) {
				document.getElementById(obj).innerHTML = xmlhttp.responseText;
				//ajaxLoadMain(serverPage, 'main','','disp');
			}
		}
		xmlhttp.send(str);
	}
	
	//function ajax search
	function processajaxSEARCH (serverPage, obj, str, theform){
		showLoadMsg ('Loading...',obj);
		document.getElementById(obj).style.visibility = "visible";
		
		xmlhttp = getxmlhttp();
		xmlhttp.open("POST", serverPage, true);
		xmlhttp.setRequestHeader("Content-Type","application/x-www-form-urlencoded; charset=UTF-8");
		xmlhttp.onreadystatechange = function() {
			if (xmlhttp.readyState == 4 && xmlhttp.status == 200) {
				document.getElementById(obj).innerHTML = xmlhttp.responseText;
			}
		}
		xmlhttp.send(str);
	}
	
	//Functions to submit a form.
	function getformvalues (fobj){
		
		var str = "";
				
		//Run through a list of all objects contained within the form.
		//alert(fobj);
		for(var i = 0; i < fobj.elements.length; i++){
			str += fobj.elements[i].name + "=" + escape(fobj.elements[i].value) + "&";
		}
		//Then return the string values.
		return str;
	}
	
	function SetChecked(val,chkName, form) {
		dml=document.forms[form];
		len = dml.elements.length;
		var i=0;
		for( i=0 ; i<len ; i++) {
			if (dml.elements[i].type=='checkbox') {
				dml.elements[i].checked=val;
			}
		}
	}
	
	function go_there(){
	 var where_to= confirm("Do you really want to delete this message(s)");
		 if (where_to== true){
			document.form1.submit();
		 }
	}
	
	function dispModeTitle (title,obj){
		document.getElementById(obj).innerHTML = title;	
	}
	
	
	function shw(obj){
		if(document.getElementById(obj).style.display == 'none'){
			document.getElementById(obj).style.display = 'block';
		}else if(document.getElementById(obj).style.display == 'block'){
			document.getElementById(obj).style.display = 'none';
		}
	}
		
	
	function f_desc(obj){
		if(document.getElementById(obj)){ 		
          	document.getElementById(obj).src='../images/desc.png';
        }
	}
	
	function f_asc(obj){
		if(document.getElementById(obj)){ 
			document.getElementById(obj).src='../images/asc.png';
		}
	}
	
	function getNotice(id,disp){
		document.getElementById(id).innerHTML = "&nbsp; &raquo;&nbsp;"+disp;
	}
	
	function validateFormCLT(){
		if(	document.deptRegFrom.client_ID.value == '' ||
			document.deptRegFrom.contact_person.value == '' ||
			document.deptRegFrom.contactNumber.value == '' ||
			document.deptRegFrom.eMail.value == '' ||
			document.deptRegFrom.address.value == '' //||
			//document.deptRegFrom.client_station.value != ''
			){
			alert("NB.\n All fields with red asteriks must be properly filled in.");
		}else if(confirm("Are you sure that you want to submit this form?")){
				processajaxFORM ('import.class/department.setup.php', 'main', getformvalues(document.deptRegFrom),document.deptRegFrom);
				return false;
		}
	}
	
	function processFormM(){
		if(	document.clientForm.schl_name.value == '' ||
			document.clientForm.schl_addres.value == '' ||
			document.clientForm.schl_state.value == '' ||
			document.clientForm.schl_lga.value == '' ||
			document.clientForm.schl_phone.value == '' ||
			document.clientForm.schl_mail.value == '' ||
			document.clientForm.agVLD.value == '' ||
			document.clientForm.ref_agent_ID.value == '' ||
			document.clientForm.fee_per_student.value == '' ||
			document.clientForm.no_student.value == '' ||
			document.clientForm.total_cost.value == ''
			
			){
			alert("NB.\n All fields with red asteriks must be properly filled in.");
		}else if(confirm("Are you sure that you want to start processing data?")){
				processajaxFORM ('import.class/client.setup.php', 'main', getformvalues(document.clientForm),document.clientForm);
				return false;
		}
	}
	
	function processFormM2(){
		if(	document.clientForm.schl_name.value == '' ||
			document.clientForm.schl_addres.value == '' ||
			document.clientForm.schl_state.value == '' ||
			document.clientForm.schl_lga.value == '' ||
			document.clientForm.schl_phone.value == '' ||
			document.clientForm.schl_mail.value == '' ||
			document.clientForm.ref_agent_ID.value == ''
			
			){
			alert("NB.\n All fields with red asteriks must be properly filled in.");
		}else if(confirm("Are you sure that you want to request for setup?")){
				processajaxFORM ('import.class/agent_client_req.php', 'main', getformvalues(document.clientForm),document.clientForm);
				return false;
		}
	}
	
	function calcFEE(){
		var fee = parseInt(document.clientForm.fee_per_student.value) * 1;
		var no_std = parseInt(document.clientForm.no_student.value) * 1;
		var costFee = fee * no_std;
		document.getElementById('tsd').value = costFee;
	}
	
	function loadLog(url){
		window.open(url,'_parent','','');	
	}
	
	function loadLog2(url){
		window.open(url,'_blank','','');	
	}
	
	var popUpWin=0;

	function popUpWindow(URLStr, left, top, width, height){
		if(popUpWin){
			if(!popUpWin.closed) popUpWin.close();
		}

  		popUpWin = open(URLStr, 'popUpWin', 'toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=no,copyhistory=yes,width='+width+',height='+height+',left='+left+', top='+top+',screenX='+left+',screenY='+top+'');
	}
	
	function doNavigate(url){
    	open(url,'_parent');
	}
	
	function lDT(obj){
			document.getElementById('lTitle').innerHTML = '<b>&raquo;</b>&nbsp;'+obj;
	}
	
	// load moon shadow effect on object
	function display(id){
		var DivMain=document.getElementById(id)
		
		if (DivMain !=null)
		{
			DivMain.style.display="block";
		}
	}
	//hide the modal form
	function unDisplay(id){
		var DivMain=document.getElementById(id)
		
		if (DivMain !=null)
		{
			DivMain.style.display="none";
		}
	}
	
	function regVal(){
		if(document.membForm.fName.value == '' || 
		   document.membForm.sName.value == '' || 
		   document.membForm.dob.value == '' || 
		   document.membForm.phoneNo.value == '' || 
		   document.membForm.eMail.value == '' || 
		   document.membForm.m_acctName.value == '' || 
		   document.membForm.m_acctNumber.value == '' || 
		   document.membForm.m_bank.value == '' || 
		   document.membForm.m_bank_brnch.value == '' || 
		   document.membForm.captcha.value == ''
		   ){
                alert('All field with red asterik must be properly filled in.');
				return false;
		}else{ 
			processajaxFORM ('import.class/agent.master.profile.php', 'main', getformvalues(document.membForm),document.membForm);
			return false;
		}	
	}
	
	function calcRq(){
		var balb4 = parseInt(document.pmntRQ.curr_bal_amt.value);
		var mntrq = parseInt(document.pmntRQ.amnt_req.value);
		if(balb4 > mntrq){
			 document.pmntRQ.curr_bal_amt_nw.value = balb4 - mntrq;
			 document.getElementById('sb').style.display = 'block';
		}else{
			alert('No fund or amount requested is higher than you balance');
			document.getElementById('sb').style.display = 'none';
			return false;
		}
	}
