function validateNonBlank(FieldName,AlertText)
{
	var Control=document.getElementById(FieldName);
	if(Control.value==""){alert(AlertText);Control.focus();return false;}else{return true;}
}
function validatePhoneNumber(FieldName,AlertText)
{
	var Control=document.getElementById(FieldName);
	var regexp = /^[0-9]+$/;
	if(regexp.test(Control.value)&&Control.value.length==10)
	{
		return true;
	}
	else
	{
		alert(AlertText);
		return false;
	}
}
function validateSelect(FieldName,AlertText)
{
	var Control=document.getElementById(FieldName);
	if(Control.options[Control.selectedIndex].value==""){alert(AlertText);Control.focus();return false;}else{return true;}
}
function validateEmail(FieldName,AlertText)
{
	var Control=document.getElementById(FieldName);
	var str=Control.value;
	var at="@";
	var dot=".";
	var lat=str.indexOf(at);
	var lstr=str.length;
	var ldot=str.indexOf(dot);
	if (str.indexOf(at)==-1){alert(AlertText);Control.focus();return false;}
	if (str.indexOf(at)==-1 || str.indexOf(at)==0 || str.indexOf(at)==lstr){alert(AlertText);Control.focus();return false;}
	if (str.indexOf(dot)==-1 || str.indexOf(dot)==0 || str.indexOf(dot)==lstr){alert(AlertText);Control.focus();return false;}
	if (str.indexOf(at,(lat+1))!=-1){alert(AlertText);Control.focus();return false;}
	if (str.substring(lat-1,lat)==dot || str.substring(lat+1,lat+2)==dot){alert(AlertText);Control.focus();return false;}
	if (str.indexOf(dot,(lat+2))==-1){alert(AlertText);Control.focus();return false;}
	if (str.indexOf(" ")!=-1){alert(AlertText);Control.focus();return false;}
	return true;					
}
function checkForUniqueEmail(email)
{
	var url="aindex.php?function=checkForUniqueEmail&email="+email;
	http.open("GET",url,true);
	http.onreadystatechange=function(){
		if(http.readyState==4)
		{	
			var unique_email=document.getElementById("unique_email");
			unique_email.innerHTML=http.responseText;
		}
	}
	http.send(null);
}
function checkPasswordStrength(password)
{
	var url="aindex.php?function=checkPasswordStrength&password="+password;
	http.open("GET",url,true);
	http.onreadystatechange=function(){
		if(http.readyState==4)
		{	
			var strong_password=document.getElementById("strong_password");
			strong_password.innerHTML=http.responseText;
		}
	}
	http.send(null);
}
function checkPasswordMatch(matchbox,password2)
{
	var password=document.getElementById("password"); 
	var password_match=document.getElementById("password_match"); 
	if(password_match.value!=password.value)
	{
		alert ("Passwords do not match. Please retype both the password and the matching word");
		password.value="";
		password_match.value="";
	}
}
