// JavaScript Document

var xmlHttp;
function showUser(str)
{ 
xmlHttp=GetXmlHttpObject();
if (xmlHttp==null)
 {
 alert ("Browser does not support HTTP Request");
 return;
 }
var url="getuser.php";
url=url+"?q="+str;
url=url+"&sid="+Math.random();
xmlHttp.onreadystatechange=stateChanged;
xmlHttp.open("GET",url,true);
xmlHttp.send(null);
}


function showMail(str)
{ 
xmlHttp=GetXmlHttpObject();
if (xmlHttp==null)
 {
 alert ("Browser does not support HTTP Request");
 return;
 }
var url="getuser.php";
url=url+"?mail="+str;
url=url+"&sid="+Math.random();
xmlHttp.onreadystatechange=stateChanged2;
xmlHttp.open("GET",url,true);
xmlHttp.send(null);
}

function stateChanged() 
{ 
if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
 {
 if (xmlHttp.responseText == "Successful")
 	{
	document.getElementById("user").value = document.getElementById("user").value.replace(/[^a-zA-Z0-9]+/g,'');
	if (document.getElementById("user").value.length > 2)
 		{
 		document.getElementById("userc").innerHTML= "This username is available.";
		document.getElementById("userimg").innerHTML= '<img src="images/Checkmark.png" width="20" height="17" alt="Successful" />';
 		document.getElementById("userc").style.color = "#30cd20";
		document.getElementById("user").style.border = "2px solid #30cd20";
		}
	else
		{
		document.getElementById("userc").innerHTML= "Your username must have at least 3 characters.";
		document.getElementById("userimg").innerHTML= '<img src="images/error.png" width="20" height="20" alt="Error" />';
   		document.getElementById("userc").style.color = "#FB4A4A";
		document.getElementById("user").style.border = "2px solid red";
		}
	}
 else
 	{
	document.getElementById("userc").innerHTML=xmlHttp.responseText;
	document.getElementById("userimg").innerHTML= '<img src="images/error.png" width="20" height="20" alt="Error" />';
   	document.getElementById("userc").style.color = "#FB4A4A";
	document.getElementById("user").style.border = "2px solid red";
	}
 } 
}






function isValidEmail(str) {
   return (str.indexOf(".") > 2) && (str.indexOf("@") > 0);
}

function stateChanged2() 
{ 
if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
 {
 if (xmlHttp.responseText == "Successful")
 	{
	document.getElementById("email").value = document.getElementById("email").value.replace(/[^a-zA-Z0-9.@_-]+/g,'');
		if (isValidEmail(document.getElementById("email").value))
 		{
 		document.getElementById("emailc").innerHTML=xmlHttp.responseText;
		document.getElementById("emailimg").innerHTML= '<img src="images/Checkmark.png" width="20" height="17" alt="Successful" />';
 		document.getElementById("emailc").style.color = "#30cd20";
		document.getElementById("email").style.border = "2px solid #30cd20";
		}
	else
		{
		document.getElementById("emailc").innerHTML= "Please use a valid email.";
		document.getElementById("emailimg").innerHTML= '<img src="images/error.png" width="20" height="20" alt="Error" />';
   		document.getElementById("emailc").style.color = "#FB4A4A";
		document.getElementById("email").style.border = "2px solid red";
		}
	}
 else
 	{
	document.getElementById("emailc").innerHTML=xmlHttp.responseText;
	document.getElementById("emailimg").innerHTML= '<img src="images/error.png" width="20" height="20" alt="Error" />';
   	document.getElementById("emailc").style.color = "#FB4A4A";
	document.getElementById("email").style.border = "2px solid red";
	}
 } 
}




function checkPWD(pwd) 
{ 
if (document.getElementById("pwd").value.length < 6)
 {
   document.getElementById("pwdc").innerHTML= "Your password must have at least 6 characters.";
   document.getElementById("pwdimg").innerHTML= '<img src="images/error.png" width="20" height="20" alt="Error" />';
   document.getElementById("pwdc").style.color = "#FB4A4A";
   document.getElementById("pwd").style.border = "2px solid red";
 } 
 else
 {
 document.getElementById("pwdc").innerHTML= "Successful";
 document.getElementById("pwdimg").innerHTML= '<img src="images/Checkmark.png" width="20" height="17" alt="Successful" />';
 document.getElementById("pwdc").style.color = "#30cd20";
 document.getElementById("pwd").style.border = "2px solid #30cd20";
 }
if (document.getElementById("pwdverify").value != document.getElementById("pwd").value)
 {
 checkPWD2(document.getElementById("pwdverify").value);
 } 
else
 {
 checkPWD2(document.getElementById("pwdverify").value);
 }
}






function checkPWD2(pwd) 
{
if (document.getElementById("pwdverify").value.length < 6)
 {
 if (document.getElementById("pwd").value.length < 6)
   {
   document.getElementById("pwdverifyc").innerHTML= "Your password must have at least 6 characters.";
   document.getElementById("pwdverifyimg").innerHTML= '<img src="images/error.png" width="20" height="20" alt="Error" />';
   document.getElementById("pwdverifyc").style.color = "#FB4A4A";
   document.getElementById("pwdverify").style.border = "2px solid red";
   }
 else
   {
   document.getElementById("pwdverifyc").innerHTML= "Your passwords do not match.";
   document.getElementById("pwdverifyimg").innerHTML= '<img src="images/error.png" width="20" height="20" alt="Error" />';
   document.getElementById("pwdverifyc").style.color = "#FB4A4A";
   document.getElementById("pwdverify").style.border = "2px solid red";
   }
 }
else
 {
if (document.getElementById("pwdverify").value != document.getElementById("pwd").value)
 {
 document.getElementById("pwdverifyc").innerHTML= "Your passwords do not match.";
 document.getElementById("pwdverifyimg").innerHTML= '<img src="images/error.png" width="20" height="20" alt="Error" />';
 document.getElementById("pwdverifyc").style.color = "#FB4A4A";
 document.getElementById("pwdverify").style.border = "2px solid red";
 } 
 else
 {
 document.getElementById("pwdverifyc").innerHTML= "Successful";
 document.getElementById("pwdverifyimg").innerHTML= '<img src="images/Checkmark.png" width="20" height="17" alt="Successful" />';
 document.getElementById("pwdverifyc").style.color = "#30cd20";
 document.getElementById("pwdverify").style.border = "2px solid #30cd20";
 }
}
}




function checkname(id) 
{ 
document.getElementById(id).value = document.getElementById(id).value.replace(/[^a-zA-Z .'-]+/g,'');
if (document.getElementById(id).value == "")
 {
 document.getElementById("fnamec").innerHTML= "Please enter your name.";
 document.getElementById("fnameimg").innerHTML= '<img src="images/error.png" width="20" height="20" alt="Error" />';
 document.getElementById("fnamec").style.color = "#FB4A4A";
 document.getElementById(id).style.border = "2px solid red";
 } 
 else
 {
 document.getElementById("fnamec").innerHTML= "Successful";
 document.getElementById("fnameimg").innerHTML= '<img src="images/Checkmark.png" width="20" height="17" alt="Successful" />';
 document.getElementById("fnamec").style.color = "#30cd20";
 document.getElementById(id).style.border = "2px solid #30cd20";
 }
}


function dob() {
if (document.getElementById("month").value == "" || document.getElementById("day").value == "" || document.getElementById("year").value == "")
	{
	document.getElementById("dobimg").innerHTML= '<img src="images/error.png" width="20" height="20" alt="Error" />';
	}
else
	{
	document.getElementById("dobimg").innerHTML= '<img src="images/Checkmark.png" width="20" height="17" alt="Successful" />';
	}
}




function gender1() {
document.getElementById("genderimg").innerHTML= '<img src="images/Checkmark.png" width="20" height="17" alt="Successful" />';
}


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;
}



var RecaptchaOptions = {
   theme : 'clean'
   //theme : 'blackglass'
};

