var xmlHttp;

function fnValidatePassword()	{
	
	fnPasswordStrength();
		
	fnConfirmPassword();
}

function fnPasswordStrength()
{ 
	var Password=document.getElementById("Password").value; 
	if (Password.length>0)	{
		xmlHttp=GetXmlHttpObject();
		if (xmlHttp==null)
		  {
		  alert ("Your browser does not support this feature.");
		  return;
		  }    
		 
		var url="asyncAuthent.php";
		url=url+"?Password="+Password+"";
		url=url+"&sid="+Math.random();
		xmlHttp.onreadystatechange=PasswordChanged;
		xmlHttp.open("GET",url,true);
		xmlHttp.send(null);
	}
	else	{
		document.getElementById("PasswordStrength").innerHTML="6-15 Characters";
	}
}


function PasswordChanged()
{ 
if (xmlHttp.readyState==4)
   {
   document.getElementById("PasswordStrength").innerHTML=xmlHttp.responseText;
   }
}

function fnConfirmPassword(ConfirmPassword)	{

	var UsrName=document.getElementById("EmailAddress").value;
	
	var Password=document.getElementById("Password").value;
	
	var ConfirmPassword=document.getElementById("ConfirmPassword").value;
	
	if (ConfirmPassword.length>0)	{
		
		xmlHttp1=GetXmlHttpObject();
		
		if (xmlHttp1==null)	{
		  
			alert ("Your browser does not support this feature.");
			
			return;
		}     
		
		var url="asyncPassMatch.php";
		
		url=url+"?UsrName="+UsrName+"&Password="+Password+"&ConfirmPassword="+ConfirmPassword+"";
		
		url=url+"&sid="+Math.random();
		
		xmlHttp1.onreadystatechange=function()	{
		
			if (xmlHttp1.readyState==4)	{
				
				if (xmlHttp1.responseText.search("Error!")!=-1)	{
					var ErrorMsg = xmlHttp1.responseText;
					ErrorMsg=ErrorMsg.replace(/Error! /i, "")
					alert(ErrorMsg);
					document.getElementById("ConfirmPassword").value="";
					document.getElementById("Password").value="";
					document.getElementById("PasswordStrength").innerHTML="6-15 Characters";
					document.getElementById("PasswordConfirmed").innerHTML="";
					return;
				}
				else	{
					document.getElementById("PasswordConfirmed").innerHTML=xmlHttp1.responseText;
					return;
				}
				
			}
		}
		
		xmlHttp1.open("GET",url,true);
		
		xmlHttp1.send(null);
	}
	else	{
		document.getElementById("PasswordConfirmed").innerHTML="";
	}
}
