var xmlHttp

function chkuser(str)
{ 
	xmlHttp=GetXmlHttpObject()
	if (xmlHttp==null)
 	{
 		alert ("Browser does not support HTTP Request")
 		return
 	}
	if(!str== '')
	{
		var url="chkuser.php?step=1&username="+str
		xmlHttp.onreadystatechange=function stateChanged() 
		{ 
		 if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
		 { 
			response = xmlHttp.responseText			
			if(response == "True")
			{
			document.getElementById("chkuserid").innerHTML="<font color=#FF0000>This username already exists, choose another</font>" 
				document.frm.flg.value = "False";	
				//alert(document.getElementById("chkuserid").innerHTML)			
			}
			else
			{		
				document.getElementById("chkuserid").innerHTML="";
				document.frm.flg.value = "True";	
			}		
		 } 
		} 
		xmlHttp.open("GET",url,true)
		xmlHttp.send(null)
	}
}

function chkDealer(str)
{ 
	xmlHttp=GetXmlHttpObject()
	if (xmlHttp==null)
 	{
 		alert ("Browser does not support HTTP Request")
 		return
 	}
	var url="chkuser.php?step=2&dealer="+str
	if(str!='')
	{
		xmlHttp.onreadystatechange=function stateDealerChanged() 
		{ 
		 if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
		 { 
			response = xmlHttp.responseText		
			if(response == "True")
			{
				document.getElementById("dealerdiv").innerHTML="This dealer name already exists, choose another";
				document.frm.flg.value = "False";				
			}
			else
			{		
				document.getElementById("dealerdiv").innerHTML=""; 
				document.frm.flg.value = "True";
			}		
		 } 
		} 
		xmlHttp.open("GET",url,true)
		xmlHttp.send(null)
	}
}

function chkOldPass(str)
{ 
	xmlHttp=GetXmlHttpObject()
	if (xmlHttp==null)
 	{
 		alert ("Browser does not support HTTP Request")
 		return
 	}
	if(!str== '')
	{
		var url="chkuser.php?step=3&password="+str
		xmlHttp.onreadystatechange=function stateChgPass() 
		{ 
		 if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
		 { 
			response = xmlHttp.responseText	
			if(response == "True")
			{
				document.getElementById("chkPassid").innerHTML="";
				document.frm.flg.value = "True";				
			}
			else
			{		
				document.getElementById("chkPassid").innerHTML="<font color=#FF0000>Invalid old password</font>" 
				document.frm.flg.value = "False";	
			}		
		 } 
		}
		xmlHttp.open("GET",url,true)
		xmlHttp.send(null)
	}
}

function chkEmail(str)
{ 
	xmlHttp=GetXmlHttpObject()
	if (xmlHttp==null)
 	{
 		alert ("Browser does not support HTTP Request")
 		return
 	}
	var url="chkuser.php?step=4&email="+str
	if(str!='')
	{
		xmlHttp.onreadystatechange=function stateEmailChanged() 
		{ 
		 if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
		 { 
			response = xmlHttp.responseText			
			if(response == "True")
			{
				document.getElementById("chkEmailid").innerHTML="";
				document.frm.flg.value = "True";				
			}
			else
			{		
				document.getElementById("chkEmailid").innerHTML="<font color=#FF0000>Please entert a valid email address</font>" 
				document.frm.flg.value = "False";
			}		
		 } 
		}
		xmlHttp.open("GET",url,true)
		xmlHttp.send(null)
	}
}

function chkDealerOldPass(str)
{ 
	xmlHttp=GetXmlHttpObject()
	if (xmlHttp==null)
 	{
 		alert ("Browser does not support HTTP Request")
 		return
 	}
	if(!str== '')
	{
		var url="chkuser.php?step=5&password="+str
		xmlHttp.onreadystatechange=function stateChgPass() 
		{ 
		 if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
		 { 
			response = xmlHttp.responseText	
			if(response == "True")
			{
				document.getElementById("chkdealerPassid").innerHTML="";
				document.frm.flg.value = "True";				
			}
			else
			{		
				document.getElementById("chkdealerPassid").innerHTML="<font color=#FF0000>Invalid old password</font>" 
				document.frm.flg.value = "False";	
			}		
		 } 
		}
		xmlHttp.open("GET",url,true)
		xmlHttp.send(null)
	}
}

function chkDealerEmail(str)
{ 
	xmlHttp=GetXmlHttpObject()
	if (xmlHttp==null)
 	{
 		alert ("Browser does not support HTTP Request")
 		return
 	}
	var url="chkuser.php?step=6&email="+str
	if(str!='')
	{
		xmlHttp.onreadystatechange=function stateDealerEmail() 
		{ 
		 if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
		 { 
			response = xmlHttp.responseText			
			if(response == "True")
			{
				document.getElementById("chkDealerEmail").innerHTML="";
				document.frm.flg.value = "True";				
			}
			else
			{		
				document.getElementById("chkDealerEmail").innerHTML="<font color=#FF0000>Please entert a valid email address</font>" 
				document.frm.flg.value = "False";
			}		
		 } 
		}
		xmlHttp.open("GET",url,true)
		xmlHttp.send(null)
	}
}

