var xmlHttp
	
function chkusr(str)
{ 
	if(str == "")
		return
	xmlHttp=GetXmlHttpObject()
	if (xmlHttp==null){
		alert ("Browser does not support HTTP Request")
	return
	} 
	var url="chkusr.php?act=chku"
	url=url+"&u="+str
	url=url+"&sid="+Math.random()
	xmlHttp.onreadystatechange=CHKUSR 
	xmlHttp.open("GET",url,true)
	xmlHttp.send(null)
}

function CHKUSR() 
{ 
 if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
 { 
 	document.getElementById("myid").innerHTML=xmlHttp.responseText 
 } 
}
function CheckUName(Uname)
{ 
	if(Uname == "")
		return
	xmlHttp=GetXmlHttpObject()
	if (xmlHttp==null){
		alert ("Browser does not support HTTP Request")
	return
	} 
	var url="chkusr.php"
	url=url+"?u="+Uname+"&act=chku"
	xmlHttp.onreadystatechange=stateChanged 
	xmlHttp.open("GET",url,true)
	xmlHttp.send(null)
}

function stateChanged() 
{ 
 if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
 { 
 	var Response =xmlHttp.responseText 
	if(Response == "1"){
		document.form1.isExistUname.value = "yes"
		alert("Username already exist. Please choose another username.")
		document.form1.agent_email1.value = ""
		document.form1.username.value = ""
		document.form1.agent_email1.focus()
	}
	else
		document.form1.isExistUname.value = "no"
 } 
}
/****************************************************/
function CheckGroup(Code)
{ 
	if(Code == "")
		return
	xmlHttp=GetXmlHttpObject()
	if (xmlHttp==null){
		alert ("Browser does not support HTTP Request")
	return
	} 
	
	var url="chkusr.php"
	url=url+"?g="+Code+"&act=g";
	xmlHttp.onreadystatechange=checkgroup
	xmlHttp.open("GET",url,true)
	xmlHttp.send(null)
}

function checkgroup() 
{ 
 if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
 { 
 	
 	var Response = xmlHttp.responseText 
	if(Response == '0'){
		document.form1.isExistGroup.value = "no"
		
		alert("The Group ID Number entered does not exist.  Please enter a valid group number.")
		document.form1.idnum.value = ""
		document.form1.idnum.focus()
		document.form1.isExistGroup.value = "no"
		document.form1.agent_number.value = ""
		document.form1.company_name.value=""
		document.form1.bid.value = ""
		document.form1.online11.value = ""
		document.form1.flag.value = 0
		document.form1.company_email.value = ""
		document.getElementById("pro").style.display="none";
	
		
	}
	else {		
		var Temp = Response.split('|')
	
		document.form1.isExistGroup.value = "yes"
		document.form1.agent_number.value = Temp[0]		
		document.form1.company_name.value=Temp[1]
		document.form1.bid.value = Temp[2]
		document.form1.online11.value = Temp[3]
		document.form1.company_email.value = Temp[4]
		document.form1.flag.value = 1
		document.getElementById("pro").style.display="none";
	}
		
 } 
 else
 {
 	document.getElementById("pro").style.display="block";
	document.form1.flag.value = 0
 }

}
/*************************************************************************************/
function GetXmlHttpObject()
{
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;
}
