	function CheckForm_me(prevdiv, nextdiv){

	id = document.Reg.id;
	first_name = document.Reg.first_name;
	last_name = document.Reg.last_name;
	center = document.Reg.center;
	school = document.Reg.schools;
	//oschool = document.Reg.other_school;
	gender = document.Reg.gender;
	y = document.Reg.y;
	m = document.Reg.m;
	d = document.Reg.d;

		if ( ! document.getElementById('noid').checked ) {
			if(id.value.length == 9) {

				if(checkidnum(id.value)==false) {

						alert("תעודת זהות שגוייה");
						id.select();
						return false;
				}

			} else {
				alert("תעודת הזהות צריכה להכיל 9 ספרות בדיוק");
				id.select();
				return false;
			}
		} else {
			if  ( !is_num (id.value) ) {
				alert ("אנא הזן דרכון חוקי");
				id.select();
				return false;
			}
		}


		if(validletter(first_name.value) == false) {
			alert("אנא הזן שם פרטי בעברית");
			first_name.select();
			return false;
		}

		if(validletter(last_name.value) == false) {
			alert("אנא הזן שם משפחה בעברית");
			last_name.select();
			return false;
		}

		if(center.value == "-1") {
			alert("אנא בחר ישוב");
			center.select();
			return false;
		}

		if ( typeof school == 'object'  ) {
			if (school.value == "-1") {
				if (document.Reg.other_school.length == 0) {
					alert ("אנא רשום את שם בית ספרך");
					oschool.select();
					return false;
				} else {
					if (validletter(document.Reg.other_school.value) == false) {
					 	alert ("אנא הזן בית ספר בעברית");
						oschool.select();
						return false;
					}
				}
			}
		} else {
			center.selectedIndex = 0;
			alert ("אנא בחר יישוב ובית ספר");
			return false;
		}
		

		x=0;
		for (i=0; i<gender.length; i++) {
			if(gender[i].checked == true) 
			x=1;
		}

		if(x == 0) {
			alert("אנא בחר את מינך");
			gender.select();
			return false;
		}

		if((y.value == "-1") || (m.value == "-1") || (d.value == "-1")) {
			alert("אנא בחר תאריך לידה");
			return false;
		}

		showDiv(prevdiv, nextdiv);
	}

	function CheckForm_family(prevdiv, nextdiv){

	immigration_country = document.Reg.immigration_country;
 	mother_name = document.Reg.mother_name;
	mother_work = document.Reg.mother_work;
	father_name = document.Reg.father_name;
	father_work = document.Reg.father_work;
	y = document.Reg.y1;
	m = document.Reg.m1;
	d = document.Reg.d1;

		if(immigration_country.value != "israel") { 

			if((y.value == "-1") || (m.value == "-1") || (d.value == "-1")) {
				alert("אנא בחר ארץ לידה ותאריך עליה");
				return false;
			}
		}

		if (mother_name.length > 0) {
			if(validletter(mother_name.value) == false) {
				alert("אנא הזן את שם האם בעברית");
				mother_name.select();
				return false;
			}
		}


		if (father_name.length > 0) {
			if(validletter(father_name.value) == false) {
				alert("אנא הזן את שם האב בעברית");
				father_name.select();
				return false;
			}
		}


		if (mother_work.length > 0) {
			if(validletter(mother_work.value) == false) {
				alert("אנא הזן את עיסוק האם בעברית");
				mother_work.select();
				return false;
			}
		}


		if (father_work.length > 0) {
			if(validletter(father_work.value) == false) {
				alert("אנא הזן את עיסוק האב בעברית");
				father_work.select();
				return false;
			}
		}


		showDiv(prevdiv, nextdiv);
	}

	function CheckForm_contact(){

 	street = document.Reg.street;
 	street_num = document.Reg.street_num;
 	city = document.Reg.city;
 	mikod = document.Reg.mikod;
 	phone = document.Reg.phone;
 	cell = document.Reg.cell;
 	kidomet_phone = document.Reg.kidomet_phone;
 	kidomet_cell = document.Reg.kidomet_cell;
 	email = document.Reg.email;

		if((street.value == "") || (street_num.value == "") || (city.value == "")){
			alert("אנא הזן כתובת, מספר בית, ועיר");
			return false;
		}

		if((phone.value == "") || (kidomet_phone.value == "-1")){
			phone.select();
			phone_ok = false;
		} else if(is_num(phone.value) == false) {
			phone.select();
			phone_ok = false;
		} else {
			phone_ok = true;
		}

		if((cell.value == "") || (kidomet_cell.value == "-1")){
			cell.select();
			cell_ok = false;
		} else if(is_num(cell.value) == false) {
			cell.select();
			cell_ok = false;
		} else {
			cell_ok = true;
		}

		if (!cell_ok && !phone_ok) {
			alert ("אנא הזן מספר נייד או מספר טלפון אחד לפחות");
			return false;
		}

		if(email.value != "") {
			if(validemail(email.value) == false) {
				alert("האימייל שהוקש לא  תקני");
				email.select();
				return false;
			}
		}

		
	return true;
	}


	function CheckForm_app(){

		place = document.getElementById("place");
		address = document.getElementById("address");
		num_place = document.getElementById("num_place");
		m = document.getElementById("m");
		n = document.getElementById("n");
		h = document.getElementById("h");
		d = document.getElementById("d");
		app_form= document.getElementById("app_form");
		if ( place.value == "") {
			place.select();
			alert ("שכחתם לציין את המיקום");
			return false;
		}

		if (address.value == "" ) {
			address.select();
			alert("שכחתם לציין את הכתובת בו יתקיים המועד");
			return false;
		}

	 	if ( num_place.value == "" || ! is_num(num_place.value) ) {

			num_place.select();
			alert("יש לציין את מספר המקומות במועד. נא הזינו ערך מספרי");
			return false;
		}
		if (m.value == -1 || n.value == -1 || d.value == -1 || h.value == -1 ) {
		 	alert ("אנא בחר בתאריך חוקי");
			return false;
		}

		app_form.submit();
			
	}

	function is_num(str){
		for (i=0; i<str.length; i++) {
			if((str.charAt(i)>'9') || (str.charAt(i)<'0'))
			return false;
		}
	return true;
	}

	function validletter(str){
	var rExp=/[א-ת]+/;
		if (!rExp.test(str))
		return false;
	return true;
	}

	function validemail(str){
	var rExp=/^[\w\-\.]+\@[\w\-\.]+\.[\w\-]+$/i;
		if (!rExp.test(str))
		return false;
	return true;
	}

function checkidnum(idnum){
 
    while (idnum.length<9){
        idnum="0"+idnum;
    }
    idnum1=idnum.substr(0,1)*1;
    idnum2=idnum.substr(1,1)*2;
    idnum3=idnum.substr(2,1)*1;
    idnum4=idnum.substr(3,1)*2;
    idnum5=idnum.substr(4,1)*1;
    idnum6=idnum.substr(5,1)*2;
    idnum7=idnum.substr(6,1)*1;
    idnum8=idnum.substr(7,1)*2;
    idnum9=idnum.substr(8,1)*1;
 
    if (idnum1>9) idnum1=(idnum1%10)+1
    if (idnum2>9) idnum2=(idnum2%10)+1
    if (idnum3>9) idnum3=(idnum3%10)+1
    if (idnum4>9) idnum4=(idnum4%10)+1
    if (idnum5>9) idnum5=(idnum5%10)+1
    if (idnum6>9) idnum6=(idnum6%10)+1
    if (idnum7>9) idnum7=(idnum7%10)+1
    if (idnum8>9) idnum8=(idnum8%10)+1
    if (idnum9>9) idnum9=(idnum9%10)+1
 
    var sumval=idnum1+idnum2+idnum3+idnum4+idnum5+idnum6+idnum7+idnum8+idnum9;
 
    sumval=sumval%10
    if (sumval>0){
        return false;
    }
 
  return true;
}

