// JavaScript Document
function checkform(){


	if(document.form1.FullName.value==''){
			alert(' Please type full name  ');
			document.form1.FullName.focus();
			return false;
	}


  if(document.form1.Country.value==''){
			alert('Please select Country ');
			document.form1.Country.focus();
			return false;
		}

 
		if(document.form1.UserName.value==''){
			alert('Please type username');
			document.form1.UserName.focus();
			return false;
	}
	 
		if(document.form1.Password.value==''){
			alert('Please type password ');
			document.form1.Password.focus();
			return false;
	} 

	
	
	if(document.form1.Password.value != document.form1.rePassword.value){
				alert('password not match !  ');
				document.form1.rePassword.focus();
				return false;
		}
		
		if(document.form1.birth_date_y.value==''){
			alert('please type birth year  ');
			document.form1.birth_date_y.focus();
			return false;
	} 
 	
	
	
	if(document.form1.Email.value==""){
		alert(" Please type email ");
		document.form1.Email.focus();
		return false;
		}

		else{
	    var str=document.form1.Email.value;
	    var at="@";
		var dot=".";
		var lat=str.indexOf(at);
		var lstr=str.length;
		var ldot=str.indexOf(dot);
		
		
		
		
		 if (str.indexOf(at)==-1 || str.indexOf(at)==0 || str.indexOf(at)==lstr){
		   alert(" Email not Valid !");
		   	document.form1.Email.focus();
		 return false;
		}
		
		
			if (str.indexOf(dot)==-1 || str.indexOf(dot)==0 || str.indexOf(dot)==lstr){
		   alert("Email not Valid !");
		    return false;
				document.form1.Email.focus();

		}
		
		if (str.substring(lat-1,lat)==dot || str.substring(lat+1,lat+2)==dot){
		    alert(" Email not Valid ! ");
		    return false;
				document.form1.Email.focus();

		 }


	 if (str.indexOf(dot,(lat+2))==-1){
		   alert("Email not Valid ! ");
		   document.form1.Email.focus();
		   return false;
		 }
		
	 if (str.indexOf(" ")!=-1){
		   alert(" Email not Valid ! ");
		   document.form1.Email.focus();
		   return false;
		 }
		
		
	if (str.indexOf(at,(lat+1))!=-1){
		   alert(" Email not Valid ! ");
			document.form1.Email.focus();
		    return false;
		 }
		
		
}// check email end  here 


	

/*

if(document.form1.Phone.value !=""){
var isnum;
isnum=isNaN(document.form1.Phone.value) 
		if(isnum == true){
		alert(" من فضلك اكتب رقم تليفون صحيح  ");
		document.form1.Phone.focus();

		return false;
		}

}


if(document.form1.HS_Name.value==""){
		alert(" من فضلك اكتب اسم المدرسة الثانوية ");
		document.form1.HS_Name.focus();
		return false;
		}


if(document.form1.HS_Year.value==""){
		alert(" من فضلك اختار سنة الانتهاء من المدرسة الثانوية ");
		document.form1.HS_Year.focus();
		return false;
		}
	


/*
var fullname=document.form1.fullname.value;
var Country_ID=document.form1.Country_ID.value;
var city_id=document.form1.city_id.value;
var username=document.form1.username.value;
var password=document.form1.password.value;
var Address=document.form1.Address.value;
var email=document.form1.email.value;
var Address=document.form1.Address.value;
var phone=document.form1.phone.value;
var mobile=document.form1.mobile.value;
var bdd=document.form1.bdd.value;
var bdm=document.form1.bdm.value;
var bdy=document.form1.bdy.value;
var job=document.form1.job.value;
var gender=document.form1.gender.value;


document.form1.method='post';
document.form1.action='function.php';
document.form1.submit();


var url="function.php?f=add_member&fullname="+fullname+"&Country_ID="+Country_ID+"&city_id="+city_id+"&username="+username+"&password="+password+"&Address="+Address+"&email="+email+"&phone="+phone+"&mobile="+mobile+"&bdd="+bdd+"&bdm+"+bdm+"&bdy="+bdy+"&job="+job+"&gender="+gender;

location.href=url;
			startajax();			
			xmlhttp.onreadystatechange = adduser; 
			sendajax(url);
		alert(url);
	*/		
	
		
}// end check function 

function IsNumeric(sText)
{
   var ValidChars = "0123456789.";
   var IsNumber=true;
   var Char;

 
   for (i = 0; i < sText.length && IsNumber == true; i++) 
      { 
      Char = sText.charAt(i); 
      if (ValidChars.indexOf(Char) == -1) 
         {
         IsNumber = false;
         }
      }
   return IsNumber;
   
}



