﻿<!--

  function OpenWin(link)
  {
       window.open("show_product.asp?pid="+link,'myWindow', 'toolbar=no, menubar=no,scrollbars=no, resizable=yes, location=no, directories=no,width=560, height=450,top=150,left=150')
  }

  	function openPrintVersion(url)
	{
		window.open(url,"_blank","directories=no, height=220, location=no, menubar=no, resizable=no, scrollbars=yes, status=no, titlebar=no, toolbar=no, width=550");
	}

function submitSecure(url){
		document.getElementById("secureForm").action = url;
		document.getElementById("secureForm").submit();
}


function checkSearch(){
	if (document.getElementById("SearchForm").key.value == "" || document.getElementById("SearchForm").key.value == "חיפוש באתר"){
		alert("נא מלא טקסט לחיפוש");
		document.getElementById("SearchForm").key.focus();
		return false;
	}
	return true;
}

function checkReg(){
	if (document.getElementById("formReg").fname.value == ""){
		alert("נא מלא שם פרטי");
		document.getElementById("formReg").fname.focus();
		return false;
	}
	if (document.getElementById("formReg").lname.value == ""){
		alert("נא מלא שם משפחה");
		document.getElementById("formReg").lname.focus();
		return false;
	}
	if (document.getElementById("formReg").email.value == ""){
		alert("נא מלא כתובת דוא\"ל");
		document.getElementById("formReg").email.focus();
		return false;
	}
	if(!/^[\w\.\-]+@[\w\-]+(\.\w+)+$/.test(document.getElementById("formReg").email.value)){
		alert("כתובת הדוא\"ל שהוזנה אינה תקינה");
		document.getElementById("formReg").email.focus();
		return false;
	}
	if (document.getElementById("formReg").password.value == ""){
		alert("נא מלא סיסמה");
		document.getElementById("formReg").password.focus();
		return false;
	}
	if (document.getElementById("formReg").password2.value == ""){
		alert("נא מלא סיסמה שנית");
		document.getElementById("formReg").password2.focus();
		return false;
	}
	if (document.getElementById("formReg").password.value != document.getElementById("formReg").password2.value){
		alert("סיסמאות לא זהות - אנא מלא שנית");
		document.getElementById("formReg").password.value = "";
		document.getElementById("formReg").password2.value = "";
		document.getElementById("formReg").password.focus();
		return false;
	}
	return true;
}

function checkUpdateMember(){
	if (document.getElementById("formUpdateMember").fname.value == ""){
		alert("נא מלא שם פרטי");
		document.getElementById("formUpdateMember").fname.focus();
		return false;
	}
	if (document.getElementById("formUpdateMember").lname.value == ""){
		alert("נא מלא שם משפחה");
		document.getElementById("formUpdateMember").lname.focus();
		return false;
	}
	return true;
}

function checkUpdatePass(){
	if (document.getElementById("formUpdatePass").cur_pass.value == ""){
		alert("נא מלא סיסמה נוכחית");
		document.getElementById("formUpdatePass").cur_pass.focus();
		return false;
	}
	if (document.getElementById("formUpdatePass").password.value == ""){
		alert("נא מלא סיסמה חדשה");
		document.getElementById("formUpdatePass").password.focus();
		return false;
	}
	if (document.getElementById("formUpdatePass").password2.value == ""){
		alert("נא מלא סיסמה חדשה שנית");
		document.getElementById("formUpdatePass").password2.focus();
		return false;
	}
	if (document.getElementById("formUpdatePass").password.value != document.getElementById("formUpdatePass").password2.value){
		alert("סיסמאות לא זהות - אנא מלא שנית");
		document.getElementById("formUpdatePass").password.value = "";
		document.getElementById("formUpdatePass").password2.value = "";
		document.getElementById("formUpdatePass").password.focus();
		return false;
	}
	return true;
}

function cDate(str)
{
 var d;
 d= Date.parse(str.substr(3,2)+"/"+str.substr(0,2)+"/"+str.substr(6,4));
 return new Date(d);
}

	function init()
	{
	}

	function addFavs()
	{
		var url=document.location.href;
		var title=document.title;
		if (document.all) {
			// i.e.
			window.external.AddFavorite(url, title);
		} else if (window.sidebar) {
			// ns6 & mozilla
			window.sidebar.addPanel(title, url, "");
		}
	}


  function CheckPhoneNumber(TheNumber) {
      //alert(TheNumber);
      var valid = 1
      var GoodChars = "0123456789()- " //"+"
      var i = 0
      if (TheNumber=="") {
          // Return false if number is empty
          valid = 0
      }
      for (i =0; i <= TheNumber.length -1; i++) {
          if (GoodChars.indexOf(TheNumber.charAt(i)) == -1) {
  // Note: Remove the comments from the following line to see this
  // for loop in action.
  // alert(TheNumber.charAt(i) + " is no good.")
              valid = 0
          } // End if statement
      } // End for loop
      return valid
  }


  function CheckNumber(TheNumber) {
      //alert(TheNumber);
      var valid = 1
      var GoodChars = "0123456789 " //"+"
      var i = 0
      if (TheNumber=="") {
          // Return false if number is empty
          valid = 0
      }
      for (i =0; i <= TheNumber.length -1; i++) {
          if (GoodChars.indexOf(TheNumber.charAt(i)) == -1) {
  // Note: Remove the comments from the following line to see this
  // for loop in action.
  // alert(TheNumber.charAt(i) + " is no good.")
              valid = 0
          } // End if statement
      } // End for loop
      return valid
  }


function cartFormCheck(departure_date){

//var d = new Date()

var experation_date = cDate('01/'+document.getElementById("cc_exp_month").value +'/20'+ document.getElementById("cc_exp_year").value);
var departure_date = new Date();
//	alert(departure_date)
var year_num = document.getElementById("cc_exp_year").value
var month_num = experation_date.getMonth()+2

if (month_num < 10)
  month_num = "0" + month_num;
if (month_num == 13)
 {
   month_num = "01";
   year_num = parseInt(document.getElementById("cc_exp_year").value)+1;
   if (year_num < 10)
   year_num = "0" + year_num;
 }
  experation_date = cDate('01/'+month_num +'/20'+ year_num);

	if (document.getElementById("cartForm").cc_owner_name.value == ""){
		alert("נא מלא שם בעל הכרטיס");
		document.getElementById("cartForm").cc_owner_name.focus();
		return false;
	}
	if (document.getElementById("cartForm").cc_owner_id.value == ""){
		alert("נא מלא מס' ת.ז. של בעל הכרטיס");
		document.getElementById("cartForm").cc_owner_id.focus();
		return false;
	}

	if(CheckNumber(document.getElementById("cartForm").cc_owner_id.value)==0)
	{
	  alert("שדה ת.ז. הינו שדה מיספרי");
	  document.getElementById("cartForm").cc_owner_id.focus();
	  document.getElementById("cartForm").cc_owner_id.select();
	  return false;
	}

	if (document.getElementById("cartForm").cc_type.value == 0){
		alert("נא בחר סוג כרטיס אשראי");
		document.getElementById("cartForm").cc_type.focus();
		return false;
	}
	if (document.getElementById("cartForm").cc_num.value == ""){
		alert("נא מלא מס' כרטיס אשראי");
		document.getElementById("cartForm").cc_num.focus();
		return false;
	}
	if(CheckNumber(document.getElementById("cartForm").cc_num.value)==0)
	{
	  alert("שדה מספר כרטיס אשראי הינו שדה מיספרי");
	  document.getElementById("cartForm").cc_num.focus();
	  document.getElementById("cartForm").cc_num.select();
	  return false;
	}

	if (document.getElementById("cartForm").cc_exp_month.value == 0){
		alert("נא בחר חודש");
		document.getElementById("cartForm").cc_exp_month.focus();
		return false;
	}
	if (document.getElementById("cartForm").cc_exp_year.value == 0){
		alert("נא בחר שנה");
		document.getElementById("cartForm").cc_exp_year.focus();
		return false;
	}

	if (departure_date >= experation_date)
	{
		alert("תוקף הכרטיס צריך להיות גדול מהתאריך הנוכחי");
		document.getElementById("cc_exp_month").focus();
		return false;
	}

	if (document.getElementById("cartForm").phone.value == ""){
		alert("נא מלא טלפון");
		document.getElementById("cartForm").phone.focus();
		return false;
	}

	if(CheckPhoneNumber(document.getElementById("cartForm").phone.value)==0)
	{
	  alert("שדה טלפון הינו שדה מיספרי");
	  document.getElementById("cartForm").phone.focus();
	  document.getElementById("cartForm").phone.select();
	  return false;
	}

	if (document.getElementById("cartForm").delivery_id.value == 0){
		alert("נא בחר סוג משלוח");
		document.getElementById("cartForm").delivery_id.focus();
		return false;
	}
	return true;
}

function checkContactForm(){
	if (document.getElementById("contactForm").name.value == ""){
		alert("נא מלא שם");
		document.getElementById("contactForm").name.focus();
		return false;
	}
	if (document.getElementById("contactForm").email.value == ""){
		alert("נא מלא כתובת דוא\"ל");
		document.getElementById("contactForm").email.focus();
		return false;
	}
	if(!/^[\w\.\-]+@[\w\-]+(\.\w+)+$/.test(document.getElementById("contactForm").email.value)){
		alert("כתובת הדוא\"ל שהוזנה אינה תקינה");
		document.getElementById("contactForm").email.focus();
		return false;
	}
	if (document.getElementById("contactForm").phone.value == ""){
		alert("נא מלא טלפון");
		document.getElementById("contactForm").phone.focus();
		return false;
	}
	if (document.getElementById("contactForm").message.value == ""){
		alert("נא מלא תוכן ההודעה");
		document.getElementById("contactForm").message.focus();
		return false;
	}
	return true;
}

function checkForgotPassForm(){
	if (document.getElementById("ForgotPassForm").email.value == ""){
		alert("נא מלא כתובת דוא\"ל");
		document.getElementById("ForgotPassForm").email.focus();
		return false;
	}
	if(!/^[\w\.\-]+@[\w\-]+(\.\w+)+$/.test(document.getElementById("ForgotPassForm").email.value)){
		alert("כתובת הדוא\"ל שהוזנה אינה תקינה");
		document.getElementById("ForgotPassForm").email.focus();
		return false;
	}
	return true;
}

function checkLogin(){
	if (document.getElementById("loginForm").email.value == ""){
		alert("נא מלא כתובת דוא\"ל");
		document.getElementById("loginForm").email.focus();
		return false;
	}
	if(!/^[\w\.\-]+@[\w\-]+(\.\w+)+$/.test(document.getElementById("loginForm").email.value)){
		alert("כתובת הדוא\"ל שהוזנה אינה תקינה");
		document.getElementById("loginForm").email.focus();
		return false;
	}
	if (document.getElementById("loginForm").password.value == ""){
		alert("נא מלא סיסמה");
		document.getElementById("loginForm").password.focus();
		return false;
	}
	return true;
}

function showHideOrderDetails(o_id)
{
	document.getElementById("Footer").style.display = "none";

	if (document.getElementById("order_details"+o_id))
	{
		if (document.getElementById("order_details"+o_id).style.display == "none")
			{
			document.getElementById("order_details"+o_id).style.display = "";
			//alert("body="+document.body.clientHeight+", wrapper="+document.getElementById("wrapper").clientHeight);
			//document.getElementById("Footer").style.bottom = "0px";
			if (navigator.appName == "Microsoft Internet Explorer") {
				document.getElementById("wrapper").height = "100%";
				document.getElementById("Footer").style.bottom = "-1px";

			  } else {
				document.getElementById("wrapper").minHeight = "100%";
				document.getElementById("Footer").style.bottom = "0px";
			  }

			}

		else
		{
		document.getElementById("order_details"+o_id).style.display = "none";
		//alert("body="+document.body.clientHeight+", wrapper="+document.getElementById("wrapper").clientHeight);
		if (navigator.appName == "Microsoft Internet Explorer") {
			document.getElementById("wrapper").height = "100%";
			document.getElementById("Footer").style.bottom = "-1px";

		  } else {
			document.getElementById("wrapper").minHeight = "100%";
			document.getElementById("Footer").style.bottom = "0px";
		  }
		}
	}
	  document.getElementById("Footer").style.display = "";

}
//-->

