var xmlHttp

function chkcustlog(){
	
	cun = document.custlogform.custun.value;
	cpwd = document.custlogform.custpwd.value;
	
xmlHttp=GetXmlHttpObject();

var url="cust_loging.php";
url=url+"?un="+cun+"&pwd="+cpwd;
url=url+"&sid="+Math.random();
xmlHttp.onreadystatechange=stateChanged_chklog;
xmlHttp.open("GET",url,true);
xmlHttp.send(null);
} 

function stateChanged_chklog() 
{ 
if (xmlHttp.readyState==4)
{
	var restxt=xmlHttp.responseText;
	if(restxt=="no") {
		alert("Wrong Username or Password. Try Again.");
	}
		
	else {
		if(restxt=="admin") {
			document.custlogform.action = "cpanel.php";
		}
	
		else if(restxt=="other") {
			document.custlogform.action = "custpage.php";	
		}
		document.custlogform.submit();
	}
	
}
}

function GetXmlHttpObject() //Creating XMLHttp Object
{
var xmlHttp=null;
try
  {
  // Firefox, Opera 8.0+, Safari
  xmlHttp=new XMLHttpRequest();
  }
catch (e)
  {
  // Internet Explorer
  try
    {
    xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
    }
  catch (e)
    {
    xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
    }
  }
return xmlHttp;
}