﻿function doNL() {
    fName = document.getElementById("fnm1").value;
    //alert(fName);
    if (fName == "") {
        msg = "נא למלא שם ";
        alert(msg);
        document.getElementById("fnm1").focus();
        return;
    }
    
    Email = document.getElementById("eml1").value;
    if ((Email == 'דוא"ל') || (Email == '')) {
        msg = "נא למלא דוא''ל";
        alert(msg);
        document.getElementById("eml1").focus();
        return;
    }

    if ((Email.indexOf("@") < 2) || (Email.lastIndexOf(".") <= (Email.indexOf("@") + 2) || ((Email.length < 8)) || (Email.charAt(0) == "-" || Email.charAt(0) == "_" || Email.charAt(0) == "@" || Email.charAt(0) == "-" || Email.charAt(0) == "_" || Email.charAt(0) == "."))) {
        msg = "נא למלא דוא''ל תקין";
        alert(msg);
        document.getElementById("eml1").select();
        return;
    }
    document.getElementById("formNL").submit();
    document.getElementById("formNL").reset();

}

function doDietSubmit() {
    fName = document.getElementById("fnm").value;
    if (fName == "") {
        msg = "נא למלא שם פרטי ";
        alert(msg);
        document.getElementById("fnm").focus();
        return;
    }
    lName = document.getElementById("lnm").value;
    if (lName == "") {
        msg = "נא למלא שם משפחה ";
        alert(msg);
        document.getElementById("lnm").focus();
        return;
    }
    addrss = document.getElementById("addrss").value;
    if (addrss == "") {
        msg = "נא למלא כתובת ";
        alert(msg);
        document.getElementById("addrss").focus();
        return;
    }
    cty = document.getElementById("cty").value;
    if (cty == "") {
        msg = "נא למלא עיר ";
        alert(msg);
        document.getElementById("cty").focus();
        return;
    }
//    
    Email = document.getElementById("eml").value;
    if ((Email == 'דוא"ל') || (Email == '')) {
        msg = "נא למלא דוא''ל";
        alert(msg);
        document.getElementById("eml").focus();
        return;
    }

    if ((Email.indexOf("@") < 2) || (Email.lastIndexOf(".") <= (Email.indexOf("@") + 2) || ((Email.length < 8)) || (Email.charAt(0) == "-" || Email.charAt(0) == "_" || Email.charAt(0) == "@" || Email.charAt(0) == "-" || Email.charAt(0) == "_" || Email.charAt(0) == "."))) {
        msg = "נא למלא דוא''ל תקין";
        alert(msg);
        document.getElementById("eml").focus();
        return;
    }
//    
    mahut = document.getElementById("mahut").value;
    if (mahut == '') {
        msg = "נא למלא את נושא הפנייה ";
        alert(msg);
        document.getElementById("mahut").focus();
        return;
    }
//    
    document.getElementById("formDiet").submit();
    document.getElementById("formDiet").reset();
//    //ClearContactForm();
}



	 function doServiceSubmit() {
	     fName = document.getElementById("fnm").value;
	     if (fName == "") {
	         msg = "נא למלא שם פרטי ";
	         alert(msg);
	         document.getElementById("fnm").focus();
	         return;
	     }
	     lName = document.getElementById("lnm").value;
	     if (lName == "") {
	         msg = "נא למלא שם משפחה ";
	         alert(msg);
	         document.getElementById("lnm").focus();
	         return;
	     }
	     addrss = document.getElementById("addrss").value;
	     if (addrss == "") {
	         msg = "נא למלא כתובת ";
	         alert(msg);
	         document.getElementById("addrss").focus();
	         return;
	     }
	     cty = document.getElementById("cty").value;
	     if (cty == "") {
	         msg = "נא למלא עיר ";
	         alert(msg);
	         document.getElementById("cty").focus();
	         return;
	     }
	     apn = document.getElementById("apn").value;
	     if (apn == "") {
	         msg = "נא למלא טלפון ";
	         alert(msg);
	         document.getElementById("apn").focus();
	         return;
	     }
	     pn = document.getElementById("pn").value;
	     if (pn == "") {
	         msg = "נא למלא טלפון ";
	         alert(msg);
	         document.getElementById("pn").focus();
	         return;
	     }
	     Email = document.getElementById("eml").value;
	     if ((Email == 'דוא"ל') || (Email == '')) {
	         msg = "נא למלא דוא''ל";
	         alert(msg);
	         document.getElementById("eml").focus();
	         return;
	     }

	     if ((Email.indexOf("@") < 2) || (Email.lastIndexOf(".") <= (Email.indexOf("@") + 2) || ((Email.length < 8)) || (Email.charAt(0) == "-" || Email.charAt(0) == "_" || Email.charAt(0) == "@" || Email.charAt(0) == "-" || Email.charAt(0) == "_" || Email.charAt(0) == "."))) {
	         msg = "נא למלא דוא''ל תקין";
	         alert(msg);
	         document.getElementById("eml").focus();
	         return;
	     }
//	     barcod = document.getElementById("barcod").value;
//	     if (barcod == '') {
//	         msg = "נא למלא ברקוד";
//	         alert(msg);
//	         document.getElementById("barcod").focus();
//	         return;
//	     }
//	     yld = document.getElementById("yld").value;
//	     mld = document.getElementById("mld").value;
//	     dld = document.getElementById("dld").value;
//	     if ((yld == '')&&(mld == '')&&(dld == '')) {
//	         msg = "נא למלא תאריך אחרון לשימוש";
//	         alert(msg);
//	         document.getElementById("barcod").focus();
//	         return;
//	     }
	     
//	     q1 = document.getElementById("q").value;
//	     if (q1 == '') {
//	         msg = "נא למלא כמות";
//	         alert(msg);
//	         document.getElementById("q").focus();
//	         return;
//	     }
	     mahut = document.getElementById("mahut").value;
	     if (mahut == '') {
	         msg = "נא למלא את נושא הפנייה ";
	         alert(msg);
	         document.getElementById("mahut").focus();
	         return;
	     }
//	     place = document.getElementById("place").value;
//	     if (place == '') {
//	         msg = "נא למלא את מקום הקנייה";
//	         alert(msg);
//	         document.getElementById("place").focus();
//	         return;
//	     }
	     document.getElementById("formService").submit();
	     document.getElementById("formService").reset();
	     //ClearContactForm();
	 }

function doContactSubmit(){
	fName=document.getElementById("fnm").value;
	if (fName=="")
	 	{ msg="נא למלא שם פרטי ";
		  alert(msg);
		  document.getElementById("fnm").focus();
		  return;}
	lName = document.getElementById("lnm").value;
	if (lName=="")
	 	{ msg="נא למלא שם משפחה ";
		  alert(msg);
		  document.getElementById("lnm").focus();
		  return;}
//	addrss = document.getElementById("addrss").value;
//	if (addrss=="")
//	 	{ msg="נא למלא כתובת ";
//		  alert(msg);
//		  document.getElementById("addrss").focus();
//		  return;}
	apn = document.getElementById("apn").value;
	if (apn=="")
	 	{ msg="נא למלא טלפון ";
		  alert(msg);
		  document.getElementById("apn").focus();
		  return;}
	pn = document.getElementById("pn").value;
	if (pn=="")
	 	{ msg="נא למלא טלפון ";
		  alert(msg);
		  document.getElementById("pn").focus();
		  return;}
	Email=document.getElementById("eml").value;
	if ((Email=='דוא"ל')||(Email==''))
	 	{ msg= "נא למלא דוא''ל";
		  alert(msg);
		  document.getElementById("eml").focus();
		  return;}
	
	if ((Email.indexOf("@")<2) || (Email.lastIndexOf(".")<=(Email.indexOf("@")+2) || ((Email.length<8)) || (Email.charAt(0) == "-" || Email.charAt(0) == "_" || Email.charAt(0) == "@" || Email.charAt(0) == "-" || Email.charAt(0) == "_" || Email.charAt(0) == "."))) 
	  	{ msg= "נא למלא דוא''ל תקין";
		  alert(msg);
		  document.getElementById("eml").focus();
		  return;}
	subject = document.getElementById("cmts").value;
	if (subject=='')
	 	{ msg= "נא למלא נושא";
		  alert(msg);
		  document.getElementById("cmts").focus();
		  return;}
	document.getElementById("formContact").submit();
	document.getElementById("formContact").reset();
	//ClearContactForm();
}

function ClearContactForm()
	{ 
	 var el = formContact.elements;
	 for(i=0;i<el.length;i++)
 	   {
 	   if ((el(i).type=="text")||(el(i).type=="textarea")||(el(i).type=="hidden"))
	   	 	el(i).value="";	   
	   if (el(i).type=="select-one")
	   	 	el(i).value="0";	 
		}	
	 }
	 
	 

function doHPSubmit(){
	Email=document.formHP.email.value;
	if ((Email=='דוא"ל')||(Email==''))
	 	{ msg= "נא למלא דוא''ל";
		  alert(msg);
		  document.formHP.email.select();
		  return;}
	
	if ((Email.indexOf("@")<2) || (Email.lastIndexOf(".")<=(Email.indexOf("@")+2) || ((Email.length<8)) || (Email.charAt(0) == "-" || Email.charAt(0) == "_" || Email.charAt(0) == "@" || Email.charAt(0) == "-" || Email.charAt(0) == "_" || Email.charAt(0) == "."))) 
	  	{ msg= "נא למלא דוא''ל תקין";
		  alert(msg);
		  document.formHP.email.select();
		  return;} 
	fullName=document.formHP.fullName.value;
	if ((fullName=="שם מלא")||(fullName==""))
	 	{ msg="נא למלא שם מלא";
		  alert(msg);
		  document.formHP.fullName.select();
		  return;}
	document.formHP.submit();
	ClearHPForm();
}

function ClearHPForm()
	{ 
	 var el = formHP.elements;
	 for(i=0;i<el.length;i++)
 	   {
 	   if ((el(i).type=="text")||(el(i).type=="textarea")||(el(i).type=="hidden"))
	   	 	el(i).value="";	   
		}	
	 }
	 
	 
function doHPSearchSubmit(){
	text1=document.formHPSearch.text1.value;
	
	if (text1=='טקסט חופשי')
	 	{ msg= "נא למלא את תיבת החיפוש";
		  alert(msg);
		  document.formHPSearch.text1.select();
		  return;}
	document.formHPSearch.submit();
	ClearHPSearchForm();
}
function ClearSearchForm()
	{ 
	 var el = formHPSearch.elements;
	 for(i=0;i<el.length;i++)
 	   {
 	   if ((el(i).type=="text")||(el(i).type=="textarea")||(el(i).type=="hidden"))
	   	 	el(i).value="";	
	   if (el(i).type=="select-one")   
			el(i).value="0";	
		}	
	 }	  
function doSearchSubmit(){
	RecCatId=document.formSearch.RecCatId.value;
	ProdCatId=document.formSearch.ProdCatId.value;
	text1=document.formSearch.text1.value;
	
	if ((RecCatId=='0')&&(ProdCatId=='0')&&((text1=='טקסט חופשי')||(text1=='')))
	 	{ msg= "נא למלא אחת מתיבות החיפוש";
		  alert(msg);
		  document.formSearch.text1.select();
		  return;}
	/*if ((RecCatId=='0')&&(ProdCatId=='0')&&(text1!='טקסט חופשי'))
		document.formSearch.action = "searchFT.asp";
	else
	if (text1=='טקסט חופשי')
		document.formSearch.text1.value='';*/
	document.formSearch.action = "search.asp";
	document.formSearch.submit();
	ClearSearchForm();
}

function ClearSearchForm()
	{ 
	 var el = formSearch.elements;
	 for(i=0;i<el.length;i++)
 	   {
 	   if ((el(i).type=="text")||(el(i).type=="textarea")||(el(i).type=="hidden"))
	   	 	el(i).value="";	
	   if (el(i).type=="select-one")   
			el(i).value="0";	
		}	
	 }	  
function doSubmitSend2Friend(){
	SenderName=document.getElementById("SenderName").value;
	if (SenderName=="")
	 	{ msg="נא למלא את השם שלך";
		  alert(msg);
		  document.getElementById("SenderName").focus();
		  return;}
	Email=document.getElementById("SenderEmail").value;
	if (Email=="")
	 	{ msg= "נא למלא את הדוא''ל שלך";
		  alert(msg);
		  document.getElementById("SenderEmail").focus();
		  return;}
	
	if ((Email.indexOf("@")<2) || (Email.lastIndexOf(".")<=(Email.indexOf("@")+2) || ((Email.length<8)) || (Email.charAt(0) == "-" || Email.charAt(0) == "_" || Email.charAt(0) == "@" || Email.charAt(0) == "-" || Email.charAt(0) == "_" || Email.charAt(0) == "."))) 
	  	{ msg= "נא למלא דוא''ל תקין";
		  alert(msg);
		  document.getElementById("SenderEmail").select();
		  return;} 	
	FriendName=document.getElementById("FriendName").value;
	if (FriendName=="")
	 	{ msg="נא למלא את שם החבר שלך";
		  alert(msg);
		  document.getElementById("FriendName").focus();
		  return;}	
	Email=document.getElementById("FriendEmail").value;
	if (Email=="")
	 	{ msg= "נא למלא את הדוא''ל של החבר שלך";
		  alert(msg);
		  document.getElementById("FriendEmail").focus();
		  return;}
	
	if ((Email.indexOf("@")<2) || (Email.lastIndexOf(".")<=(Email.indexOf("@")+2) || ((Email.length<8)) || (Email.charAt(0) == "-" || Email.charAt(0) == "_" || Email.charAt(0) == "@" || Email.charAt(0) == "-" || Email.charAt(0) == "_" || Email.charAt(0) == "."))) 
	  	{ msg= "נא למלא דוא''ל תקין";
		  alert(msg);
		  document.getElementById("FriendEmail").select();
		  return;} 	
	document.getElementById("formSendMail").submit();
	document.getElementById("formSendMail").reset();
	
}

function doAlert()
	{alert("הדוא''ל נשלח לחבר");}	 

function isTel(e){	
	var strCheck = '0123456789-';
	var whichCode = (window.Event) ? e.which : e.keyCode;	
	if (whichCode != 0){
		if (whichCode == 13) return true;
		key = String.fromCharCode(whichCode);
		if (strCheck.indexOf(key) >-1 ) return  true;
		else return false;
	}
}

function isMail(e){	
	var strCheck = '0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz-_.@';
	var whichCode = (window.Event) ? e.which : e.keyCode;		
	if (whichCode != 0){
		if (whichCode == 13) return true;
		key = String.fromCharCode(whichCode);
		if (strCheck.indexOf(key) == -1 ) return false;
		else return true;
	}
}
function isNmbr(e){	
	var strCheck = '0123456789';
	var whichCode = (window.Event) ? e.which : e.keyCode;	
	if (whichCode != 0){
		if (whichCode == 13) return true;
		key = String.fromCharCode(whichCode);
		if (strCheck.indexOf(key) >-1 ) return  true;
		else return false;
	}
}

function newWindow(winWidth,winHeight,imgName){
  myWindow=window.open(imgName,'mama','scrollbars=no,width='+winWidth+',height ='+winHeight+',left='+(screen.width/2-winWidth/2)+',top='+(screen.height/2-winHeight/2)+'');
  myWindow.focus();
}
function checkBirthDate(d, m, y) {
    if ((d < 0) || (d > 31))
    { getFalseDate(); return false; }
    if ((m < 0) || (m > 12))
    { getFalseDate(); return false; }
    var myDate = new Date();
    var CY = myDate.getFullYear();
    if ((y < 1900) || (y > CY))
    { getFalseDate(); return false; }
    if ((d > 30) && ((m == 4) || (m == 6) || (m == 9) || (m == 11)))
    { getFalseDate(); return false; }
    if (checkFeb(d, m, y))
    { getFalseDate(); return false; }
    return true;
}
function checkFeb(d1, m1, y1) {
    if (m1 != 2)
        return false;
    else {
        if ((y1 % 4 == 0) && (d1 > 29))
            return true;
        else if ((y1 % 4 != 0) && (d1 > 28))
            return true;
        else
            return false;
    }
}
function getFalseDate() {
    var msg = "התאריך לא תקין";
    alert(msg);
}

function ClearClubForm() {
    var el = formClub.elements;
    for (i = 0; i < el.length; i++) {
        if ((el(i).type == "text") || (el(i).type == "textarea") || (el(i).type == "hidden"))
            el(i).value = "";
        if (el(i).type == "select-one")
            el(i).value = "0";
        if (el(i).type == "checkbox")
            el(i).checked = false;
    }
}