// JavaScript Document
var xmlHttp

function showUserExists(str)
{
if (str.length==0)
  { 
  document.getElementById("txtUserHint").innerHTML="";
  return
  }
xmlHttp=GetXmlHttpObject()
if (xmlHttp==null)
  {
  alert ("Browser does not support HTTP Request")
  return
  } 
var url="register-check.php?check=username"
url=url+"&q="+str
url=url+"&sid="+Math.random()
xmlHttp.onreadystatechange=UserstateChanged 
xmlHttp.open("GET",url,true)
xmlHttp.send(null)
} 

function UserstateChanged() 
{ 
if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
 {
	 if(xmlHttp.responseText == "nameTaken"){
	 	document.getElementById("txtUserHint").innerHTML="That User Name already exists";
		document.getElementById("userName").focus();
		if((document.getElementById("txtUserHint").innerHTML=="That User Name already exists") && (document.getElementById("txtEmailHint").innerHTML=="That Email Address already exists")){
			document.getElementById("userName").focus();
		}
	 }else{
		 document.getElementById("txtUserHint").innerHTML="";
	 }
 } 
}

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 showEmailExists(str)
{
if (str.length==0)
  { 
  document.getElementById("txtEmailHint").innerHTML=""
  return
  }
xmlHttp=GetXmlHttpObject()
if (xmlHttp==null)
  {
  alert ("Browser does not support HTTP Request")
  return
  } 
var url="register-check.php?check=email"
url=url+"&q="+str
url=url+"&sid="+Math.random()
xmlHttp.onreadystatechange=EmailstateChanged 
xmlHttp.open("GET",url,true)
xmlHttp.send(null)
} 

function EmailstateChanged() 
{ 
if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
 { 
 	 if(xmlHttp.responseText == "emailTaken"){
	 	document.getElementById("txtEmailHint").innerHTML="That Email Address already exists";
		if((document.getElementById("txtUserHint").innerHTML=="That User Name already exists") && (document.getElementById("txtEmailHint").innerHTML=="That Email Address already exists")){
			document.getElementById("userName").focus();
		}else{
			document.getElementById("userEmail").focus();
		}
	 }else{
		 document.getElementById("txtEmailHint").innerHTML="";
	 }
 } 
}

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;
}
