//---- function check only num pressed  -------------------------------------------------
var Ver4 = parseInt(navigator.appVersion) >= 4 
var Nav4 = ((navigator.appName == "Netscape") && Ver4)
var IE4 = ((navigator.userAgent.indexOf("MSIE") != -1) && Ver4)
if (Nav4) {
	var origWidth = window.innerWidth ;
	var origHeight = window.innerHeight ;
}
function ValidPhoneMask(curER, e){
	var key = Nav4 ? e.which : e.keyCode;
	if((key>=48 && key<=57)||(key>=45 && key<=45))return true;
	return false;
}

function ValidAgeMask(curER, e){
	var key = Nav4 ? e.which : e.keyCode;
	if((key>=48 && key<=57)||(key>=46 && key<=46))return true;
	return false;
}

function ValidNumberMask(curER, e){
	var key = Nav4 ? e.which : e.keyCode;
	if(key>=48 && key<=57)return true;
	return false;
}

function ValidNameMask(curER, e){
	var key = Nav4 ? e.which : e.keyCode;
	if((key>=65 && key<=90) ||(key>=97 && key<=122)||(key>=1188 && key<=1514)||(key==32))return true;
	//(key>=65 && key<=90) //english big
	//(key>=97 && key<=122) //english small
	//(key>=1188 && key<=1514)//hebrew
	return false;
}

function ValidEmailMask(curER, e){
	var key = Nav4 ? e.which : e.keyCode;
	if((key>=95 && key<=95) ||(key>=45 && key<=46) ||(key>=64 && key<=90) ||(key>=97 && key<=122)||(key>=48 && key<=57))return true;
	//(key>=48 && key<=57) //numbers
	//(key>=65 && key<=90) //english big
	//(key>=97 && key<=122) //english small
	return false;
}
//----- This function decide if the length of item is equel or more then len------------
function ValidLength(item, len){
        return (item.length >= len);
}
//----- This function decide if the length of Phone field is equel or more then len------------
function ValidPhoneLength(item){
        //return (item.length == 7);
        //return (item.length ==6)||(item.length == 7);
        return (item.length ==6)||(item.length == 7);
}
//----- function to validate an email address -------------------------------------------
function ValidEmail(item){
        if (!ValidLength(item, 6)) return false;
        if (item.indexOf ('@', 0) == -1) return false;
        if (item.indexOf ('.', 0) == -1) return false;
       return true; 
}
//----This function check if the parameters in TellFriend window are fill corectly -------
function ValidateTellFriend(){
	var msg = "";
	if(!ValidLength(document.frmTellFriend.MemberName.value,2)){
		msg = msg + "אנא מלא/י את שמך\n"
	}
	if(!ValidEmail(document.frmTellFriend.MemberEmail.value)){
		msg = msg + "אנא מלא/י את כתובת הדואר האלקטרוני שלך\n";
	}
	if(!ValidLength(document.frmTellFriend.FriendName.value,2)){
		msg = msg + "אנא מלא/י את שם חברך\n";
	}
	if(!ValidEmail(document.frmTellFriend.FriendEmail.value)){
		msg = msg + "אנא מלא/י את כתובת הדואר האלקטרוני של החבר/ה\n";
	}
	if (msg!=""){
		alert (msg);
		void(0);
		return false;
		}
	else{
		document.frmTellFriend.submit();
		}
}

//----This function check if the parameters in ContactUs are fill corectly -------
function ValidateContactUs(){
	var msg = "";
	if(!ValidLength(document.frmContactUS.fullname.value,2)){
		msg = msg + "אנא מלא/י את שמך\n"
	}
	if(!ValidLength(document.frmContactUS.cell.value,10)&&!ValidLength(document.frmContactUS.phone.value,9)&&!ValidEmail(document.frmContactUS.email.value)){
		msg = msg + "אנא מלא/י מספר טלפון או כתובת דואר אלקטרוני\n"
	}
	if (msg!=""){
		alert (msg);
		void(0);
		return false;
		}
	else{
		document.frmContactUS.submit();
		}
}

//----This function check if the parameters in Join Frm are fill corectly -------
function ValidateClub(){
	var msg = "";
	if(!ValidLength(document.frmCustomer.fname.value,2)){
		msg = msg + "אנא מלא/י את שמך הפרטי\n";
	}
	if(!ValidLength(document.frmCustomer.lname.value,2)){
		msg = msg + "אנא מלא/י את שם המשפחה\n";
	}
	if((document.frmCustomer.phone.value=="")&&(document.frmCustomer.cell.value=="")){
		msg = msg + "יש להקליד מספר טלפון או סלולרי\n";
	}
	if(!ValidEmail(document.frmCustomer.email.value)){
		msg = msg + "אנא מלא/י את כתובת הדואר האלקטרוני שלך\n";
	}
	if (msg!=""){
		alert (msg);
		void(0);
		return false;
		}
	else{
		document.frmCustomer.submit();
		}
}

