var xmlHttp

function stateChanged() 
{ 
if (xmlHttp.readyState==4)
{
	if(xmlHttp.responseText==''){
		document.getElementById("emailerror").innerHTML=xmlHttp.responseText;			
	}
	
	if(document.getElementById("emailerror").innerHTML==''){
		document.getElementById("Submit").disabled=false;
	}
	
	if((xmlHttp.responseText=='Enter a valid email address') || (xmlHttp.responseText=='This email address is already in use'))
	{	
		document.getElementById("emailerror").innerHTML=xmlHttp.responseText;
		document.getElementById("Submit").disabled=true;
	}
}
}

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;
}

function confirma(str,str2)
{
	if (str.length==0)
	{
		document.getElementById("confirmerror").innerHTML="";
	}
	xmlHttp=GetXmlHttpObject()
	if(xmlHttp==null)
	{
		alert("This browser does not support AJAX.");
	}
	
	var url="valemail.php";
	url=url+"?str="+str;
	url=url+"&str2="+str2;
	url=url+"&sid="+Math.random();
	url=url+"&action=compare"
	xmlHttp.onreadystatechange=stateChanged;
	xmlHttp.open("GET",url,true);
	xmlHttp.send(null);

}
function checkemail(str)
{
	if (str.length==0)
	{ 
		document.getElementById("emailerror").innerHTML="";
		return;
	}
	xmlHttp=GetXmlHttpObject()
	if (xmlHttp==null)
	{
		alert ("Your browser does not support AJAX!");
		return;
	} 
	var url="valemail.php";
	url=url+"?q="+str;
	url=url+"&sid="+Math.random();
	url=url+"&action=email"
	xmlHttp.onreadystatechange=stateChanged;
	xmlHttp.open("GET",url,true);
	xmlHttp.send(null);
} 
