
var xmlhttp;

function getemail(str, WEBPATH)
{
xmlhttp=GetXmlHttpObject();
if (xmlhttp==null)
  {
  alert ("Browser does not support HTTP Request");
  return;
  }
var url= WEBPATH + "content/salesforce/getemail.php";
url=url+"?txtEmail="+str;
document.getElementById("showEmail").style.display = "block";
// url=url+"&qsrchtp="+category;
xmlhttp.onreadystatechange=stateEmailChanged;
xmlhttp.open("GET",url,true);
xmlhttp.send(null);
}

function stateEmailChanged()
{
if (xmlhttp.readyState==1)
	{
	
 	document.getElementById("showEmail").setAttribute("class", "searching");
				 document.getElementById("showEmail").innerHTML = "searching...";
	} else if (xmlhttp.readyState==4)
	{
		
		 var myarray = xmlhttp.responseText.split("<br>");  
		 
             	if(myarray[1].indexOf("None") == -1){ 
				
				//	alert(xmlhttp.responseText); 
				document.getElementById("showEmailStatus").setAttribute("class", "donotenter");
				document.getElementById("showEmail").setAttribute("class", "");
             document.getElementById("showEmail").innerHTML  = "You have an existing account.  Please recover your password."; 
			  // document.getElementById("showEmail").innerHTML  = xmlhttp.responseText;
			 // document.getElementById("showEmail").innerHTML  = myarray[1]; 
				document.getElementById("txtEmailRegistered").value = 1; 
	                
            }else{  
               //   alert(xmlhttp.responseText);  
                document.getElementById("showEmailStatus").setAttribute("class", "checkmark");
				document.getElementById("showEmail").setAttribute("class", "");
                document.getElementById("showEmail").innerHTML  = "Email not found, continue with registration";
			  //  document.getElementById("showEmail").innerHTML  = xmlhttp.responseText; 
			//   document.getElementById("showEmail").innerHTML  = myarray[1]; 
				 document.getElementById("txtEmailRegistered").value = 0; 
            }  
			
	} 
}

function GetXmlHttpObject()
{
if (window.XMLHttpRequest)
  {
  // code for IE7+, Firefox, Chrome, Opera, Safari
  return new XMLHttpRequest();
  }
if (window.ActiveXObject)
  {
  // code for IE6, IE5
  return new ActiveXObject("Microsoft.XMLHTTP");
  }
return null;
}



