
// sha2fet ajaxeye
var hand = function(str){
	window.document.getElementById('response_span').innerHTML=str;
}
function validateUsername(user){
	var strDomain='';
	window.document.getElementById('response_span').innerHTML="Validating username...";
	var ajax = new Ajax();
	ajax.doGet(strDomain+'check_username.php?action=validateUsername&username='+user,hand,'text');
}

var hand2 = function(str){
	window.document.getElementById('response_email_span').innerHTML=str;
}
function validateEmail(email){
	var strDomain='';
	window.document.getElementById('response_email_span').innerHTML="Validating email...";
	var ajax = new Ajax();
	ajax.doGet(strDomain+'check_username.php?action=validateEmail&email='+email,hand2,'text');
}

function check_form(){
	//alert(document.form.username.value);
	
	var a=document.getElementById('age').value;
	var regex1=/^[0-9]*$/;  //this is the pattern of regular expersion
 
	if(document.form.action.value == "new"){
		if(document.form.username.value == 0){
			alert("Please insert username");
			document.form.username.focus();
			return false;
		}
	}
	if(document.form.email.value == 0){
		alert("Please insert Email");
		document.form.email.focus();
		return false;
	}
	if((document.form.email.value.indexOf("@") == -1) & (document.form.email.value.indexOf(".") == -1)){
		alert("Invalid Email adress, please check your email address");
		document.form.email.focus();
		return false;
	}
	
	if(document.form.area_country.value == ""){
		alert("Please select Country Area");
		document.form.area_country.focus();
		return false;
	}
	
	if(document.form.action.value == "new"){
		if(document.form.password.value == 0){
			alert("Please insert password");
			document.form.password.focus();
			return false;
		}
		if(document.form.password.value.length < 6){
			alert("Please check password");
			document.form.password.focus();
			return false;
		}
	}
	if(document.form.password.value != document.form.password2.value){
		alert("please check your password");
		document.form.password.focus();
		return false;
	}
	if((a!='') && (regex1.test(a)== false)){  
 alert('Please enter numeric value in age ');
 age.focus();  
 return false;
 }
	
}

