// the following line is for submit button;
var google=document.getElementById("google_search");
google.setfocus();
function initial(){
	document.getElementById("google_search").focus();
	var fullname=document.getElementById("g_search");
	for(var i=0; i<=document.forms.length; i++){
		document.forms[i].onsubmit=function() {
		return chk_fullname();
		return chk_email();
		return chk_username();
		return chk_mobile();
		return chk_comp();
		return chk_password1();
		return chk_option(r_major, h_major);
		return chk_option(r_academic_degree, h_academic_degree);
		return chk_option(r_job, h_job);
		return chk_txt(r_country, h_country);
		return chk_txt(r_university, h_university);
		return chk_txt(r_college, h_college);
	}
	}
}

function chk_fullname(){
	var fullname=document.getElementById("R_fullname");
	var chk_fullname=document.getElementById("h_fullname");
	    
	if(fullname.value.length<=10 || fullname.value.search(' ')==-1){
	  fullname.style.backgroundColor="red";
	  chk_fullname.style.display="block";
	  dbl_check=false;
	  return dbl_check;
	   exit;
	 	  
  }
  else{
	  fullname.style.backgroundColor="lightgreen";
	  chk_fullname.style.display="none";
	  dbl_check=true;
	  return dbl_check;
  }
	
}
function chk_email(){
	var chk_email=document.getElementById("h_email");
	var email=document.getElementById("R_email");
 if(email.value.indexOf("@")==-1){
 email.style.backgroundColor="red";
	  chk_email.style.display="block";
	 dbl_check=false;
	  return dbl_check;
	  exit;
  }
  else{
	  email.style.backgroundColor="lightgreen";
	  chk_email.style.display="none";
	  dbl_check=true;
	  return dbl_check;
	   exit;
  }
}
function chk_username(){
	var myRegExp=/[أ-م]|\@|\%|\#|\$|\@|\^|\(|\)|\_|\+|\=/i;
		var chk_username=document.getElementById("h_username");
	var username=document.getElementById("R_username");
	if(username.value.search(myRegExp)!=-1)
	{
		username.style.backgroundColor="yellow";
	   username.value="استخدم حروف إنجليزية فقط ";
	dbl_check=false;
	  return dbl_check;
	  exit;
	  }
 else if(username.value.length<8){
 username.style.backgroundColor="red";
	  chk_username.style.display='block';
	  dbl_check=false;
	  return dbl_check;
	  exit;
  }
  else{
	  username.style.backgroundColor="lightgreen";
	  chk_username.style.display='none';
  dbl_check=true;
	  return dbl_check;
	
	  }
}
function chk_mobile(){
	var myRegExp=/[A-Z]|[أ-ن]|\@|\%|\#|\$|\@|\^|\(|\)|\_|\+|\=/i;
	var chk_mobile=document.getElementById("h_mobile");
	var mobile=document.getElementById("R_mobile");
	if(mobile.value.search(myRegExp)!=-1)
	{
		mobile.style.backgroundColor="yellow";
	   mobile.value="يجب إدخال إرقام فقط";
	   dbl_check=false;
	  return dbl_check;
	  exit;
	}
 else if(mobile.value.length<7){
 mobile.style.backgroundColor="red";
	  chk_mobile.style.display='block';
	  dbl_check=false;
	  return dbl_check;
	  exit;
  }
  else{
	  mobile.style.backgroundColor="lightgreen";
	  chk_mobile.style.display='none';
	  dbl_check=true;
	  return dbl_check;
	  
  }
}
function chk_password1(){
	var myRegExp=/[أ-ن]|\@|\%|\#|\$|\@|\^|\(|\)|\_|\+|\=/i;
	var password1=document.getElementById("R_password1");
	var chk_password1=document.getElementById("h_password1");
	var password2=document.getElementById("R_password2");
	var chk_password=document.getElementById("h_password");
	
	if(password1.value.search(myRegExp)!=-1)
	{
		password1.style.backgroundColor="red";
	    chk_password1.style.display='block';
		dbl_check=false;
	  return dbl_check;
	  exit;
		
	}
	else if(password1.value.length<=7){
		password1.style.backgroundColor="red";
        chk_password1.style.display='block';
        dbl_check=false;
	  return dbl_check;
	  exit; 
	 }
	 else if (password1.value!=password2.value){
 password1.style.backgroundColor="red";
 password2.style.backgroundColor="red";
 chk_password.style.display='block';
  dbl_check=false;
	  return dbl_check;
	  exit;
  }
 else {
 password1.style.backgroundColor="lightgreen";
 chk_password1.style.display='none';
 password2.style.backgroundColor="lightgreen";
	chk_password.style.display='none';
 dbl_check=true;
	  return dbl_check;
	
  }
  
}

function chk_option(text, hidden){
	var input=text;
	var output=hidden;
	var newoption=document.getElementById(input);
	var chk_newoption=document.getElementById(output);
	
if(newoption.options[newoption.selectedIndex].value.length==0){
	newoption.style.backgroundColor="red";
	  chk_newoption.style.display='block';
	  dbl_check=false;
	  return dbl_check;
	  exit;
}
else {
	newoption.style.backgroundColor="lightgreen";
	  chk_newoption.style.display='none';
	  dbl_check=true;
	  return dbl_check;

}
}
function chk_txt(text, hidden){
	var myRegExp=/[0-9]|\@|\%|\#|\$|\@|\^|\(|\)|\_|\+|\=/i;
	var input=text;
	var output=hidden;
	var college=document.getElementById(input);
	var chk_college=document.getElementById(output);
	if(college.value.search(myRegExp)!=-1){
		college.style.backgroundColor="red";
	  chk_college.style.display='block';
	  dbl_check=false;
	  return dbl_check;
	  exit;
	}
	else if(college.value.length<4){
		
	college.style.backgroundColor="red";
	  chk_college.style.display='block';
	  dbl_check=false;
	  return dbl_check;
	  exit;
	  
  }
  else{
	   college.style.backgroundColor="lightgreen";
	  chk_college.style.display='none';
	  dbl_check=true;
	  return dbl_check;
	
  }
}

