var request

function checkuser(evalue)
{
	
if(document.frm.txtusrname.value=="")	
{
//document.frm.uname.focus();	
document.getElementById('imgunm').style.visibility="hidden";
document.getElementById('imgunm').style.position="absolute";
document.getElementById('wrgunm').style.visibility="hidden";
document.getElementById('wrgunm').style.position="absolute";
return false;	
}
else
	{
	request=checkbrowser();
		if(request==null)
		{
			alert("please check Your Browser");
			return;
		}
	
	url="email.php?user="+evalue+"&mth="+Math.random();
	request.onreadystatechange=checkusr;	
	request.open("GET",url,true);
	request.send(null);
 	}
}
function checkusr()
{
if(request.readyState==4)
	{
	//	alert(request.responseText);
	var resp=request.responseText;
	
	if(resp==0)
	{ 
		//document.frm.uname.focus();
		document.frm.txtusrname.value="";		
		document.getElementById('unm').innerHTML="Username already exits";
		document.getElementById('wrgunm').style.visibility="visible";
		document.getElementById('wrgunm').style.position="static";
		document.getElementById('imgunm').style.visibility="hidden";
		//document.getElementById('imgunm').style.position="absolute";
	}
	else
		{
 		document.getElementById('unm').innerHTML="";
		document.getElementById('wrgunm').style.visibility="hidden";
		//document.getElementById('wrgunm').style.position="absolute";
		document.getElementById('imgunm').style.visibility="visible";
		document.getElementById('imgunm').style.position="static";
		}

	}	
}

function validemail(evalue)
{

if(document.frm.txtemail.value=="")	
{
//	document.frm.email.focus();	
document.getElementById('emlwrgunm').style.visibility="hidden";
//document.getElementById('emlwrgunm').style.position="absolute";
document.getElementById('emlimgunm').style.visibility="hidden";
//document.getElementById('emlimgunm').style.position="absolute";
return false;	
}
else
	{
		request=checkbrowser();
			if(request==null)
			{
				alert("please check Your Browser");
				return;
			}
		
		url="email.php?em="+evalue+"&mth="+Math.random();
		request.onreadystatechange=checkemail;	
		request.open("GET",url,true);
		request.send(null);
	}
		
}

function checkemail()
{
var echeck;
if(request.readyState==4)
	{
		var resp=request.responseText;
		if(resp==0)
		{
		//document.frm.email.focus();
		//document.frm.txtemail.value="";
		document.getElementById('emaildiv').innerHTML="Enter correct format";	
		//document.getElementById('emlwrgunm').style.visibility="visible";
		//document.getElementById('emlwrgunm').style.position="static";
		//document.getElementById('emlimgunm').style.visibility="hidden";
		//document.getElementById('emlimgunm').style.position="absolute";
		}
		else if(resp==2 || resp==0)
		{
		//document.frm.email.focus();
		document.frm.txtemail.value="";
		document.getElementById('emaildiv').innerHTML="Already Exits ";	
 		//document.getElementById('emlwrgunm').style.visibility="visible";
		//document.getElementById('emlwrgunm').style.position="static";
		//document.getElementById('emlimgunm').style.visibility="hidden";
		//document.getElementById('emlimgunm').style.position="absolute";	
		}
		else
		{
 		document.getElementById('emaildiv').innerHTML="";
		document.getElementById('emlwrgunm').style.visibility="hidden";
		//document.getElementById('emlwrgunm').style.position="absolute";
		document.getElementById('emlimgunm').style.visibility="visible";
		document.getElementById('emlimgunm').style.position="static";
		
		}
 	
	}	
}


// function for checking the browser compatibility of the code
function checkbrowser()
{
var request;

try
{
request=new XMLHttpRequest();
}
catch (e)
  {
	   try
		{
		request=new ActiveXObject("Msxml2.XMLHTTP");
		}
	  catch (e)
		{
			try
			  {
			  request=new ActiveXObject("Microsoft.XMLHTTP");
			  }
			catch (e)
				  {
				  alert("Your browser does not support AJAX!");
				  return false;
				  }
		}
  }
  return request;
}
 


