function rusure(what) { 
	if(confirm(what)) { 
		return true;  
	}else { 
		return false; 
	} 
}

function delSpace(what){
  return what.replace(/ /g, "")
}


function goToPage(page,val){
   page = delSpace(page)
   val = delSpace(val)
   if(page!=""&&val!=""){
      document.location = page + val
   }
}

function PopWINwh(str,namei,w,h){
   window.open(str,namei,'top='+(screen.height-h)/2+',left='+(screen.width-w)/2+',width='+w+',height='+h+',scrollbars=Yes,status=no,toolbar=no,menubar=no,location=no,resizable=no,titlebar=no')
}

function refreshWin(){
   setTimeout("Rel()",60000)
}

function Rel(){
   document.location = document.location
}

function key3(){
    if(event.keyCode <= 46 || event.keyCode > 57 || event.keyCode == 47){event.returnValue = false;}
}

function enter(){
  if (event.keyCode == 13) document.formiSearch.submit()
}

function delSpace(what){
  return what.replace(/ /g, "")
}

function ContactHP(){
	var pNamei = document.formi.Namei.value;
	var pPhone = document.formi.Phone.value;
	var pTimei = document.formi.Timei.value;
	
	if(delSpace(pNamei)==""){
	   alert("אנא הזן שם")
	   document.formi.Namei.focus()
	   return false
	}
	
	if(delSpace(pPhone)==""||delSpace(pPhone).length<9){
	   alert("אנא הזן טלפון בעל 9 ספרות")
	   document.formi.Phone.focus()
	   return false
	}
	
	var url="Call.asp?sid=" + Math.random() + "&Namei=" + escape(pNamei) + "&Phone=" + escape(pPhone) + "&Timei=" + escape(pTimei)
    xmlHttp=GetXmlHttpObjectSubject(XMLContactHP)
    xmlHttp.open("GET", url , true)
    xmlHttp.send(null)
    return false
}

function XMLContactHP(){ 
   if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete"){ 
		pstrtohandle = xmlHttp.responseText
		alert("בקשתך התקבלה\nאנו ניצור עמך קשר בהקדם")
		document.formi.Namei.value = ""
		document.formi.Phone.value = ""
		document.formi.Timei.value = ""
   } 
}


function SetLeaf(who){
	document.getElementById("Topi_1").style.display = "none"
	document.getElementById("Topi_2").style.display = "none"
	document.getElementById("Topi_3").style.display = "none"
	document.getElementById("Topi_4").style.display = "none"
	document.getElementById("Topi_"+who).style.display = ""
	document.getElementById("Leaf").innerHTML = document.getElementById("Temp_"+who).value
}


function contact(){
    var pNamei = document.formi2.Namei.value;
	var pEmail = document.formi2.Email.value;
	var pSubject = document.formi2.Subject.value;
	var pMessage = document.formi2.Message.value;
	
	if(delSpace(pNamei)==""||delSpace(pEmail)==""||delSpace(pSubject)==""||delSpace(pMessage)==""){
	   alert("גולש יקר - כל השדות הינם שדות חובה. אנא מלא ושלח שוב")
	   return false
	}else{
	   if(pEmail.indexOf(".")==-1||pEmail.indexOf("@")==-1){
	      alert("כתובת הדוא\"ל אשר הזנת אינה חוקית")
		  return false
	   }
	}
	
	var url="ContactMail.asp?sid=" + Math.random() + "&Namei=" + escape(pNamei) + "&Email=" + escape(pEmail) + "&Subject=" + escape(pSubject) + "&Message=" + escape(pMessage)
    xmlHttp=GetXmlHttpObjectSubject(XMLContactMail)
    xmlHttp.open("GET", url , true)
    xmlHttp.send(null)
    return false
}


function XMLContactMail(){ 
   if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete"){ 
		pstrtohandle = xmlHttp.responseText
		alert("הטופס נשלח בהצלחה")
		document.formi2.Namei.value = ""
		document.formi2.Email.value = ""
		document.formi2.Subject.value = ""
		document.formi2.Message.value = ""
   } 
}

function OrderSetPro(who,what){
   document.getElementById("Products_"+who).value = what
   
   pVal1 = document.getElementById("Products_1").value*1
   pVal2 = document.getElementById("Products_2").value*1
   pVal3 = document.getElementById("Products_3").value*1
   pVal4 = document.getElementById("Products_4").value*1
   pVal5 = document.getElementById("Products_5").value*1
   pVal6 = document.getElementById("Products_6").value*1
   pVal7 = document.getElementById("Products_7").value*1
   pVal8 = document.getElementById("Products_8").value*1
   
   pTotal = (pVal1+pVal2+pVal3+pVal4+pVal5+pVal6+pVal7+pVal8)
   
   var url="SetNum.asp?sid=" + Math.random() + "&Ord=" + escape(pTotal)
   xmlHttp=GetXmlHttpObjectSubject(XMLSetNum)
   xmlHttp.open("GET", url , true)
   xmlHttp.send(null)
   return false
   
}

function XMLSetNum(){ 
   if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete"){ 
		pstrtohandle = xmlHttp.responseText
		document.getElementById("Cost").innerHTML = pstrtohandle
   } 
}


function DisCard(what){
   if(what==false){
	  document.formi2.CardNamei.disabled = false
	  document.formi2.CustID.disabled = false
	  document.formi2.CardID.disabled = false
	  document.formi2.ExpYear.disabled = false
	  document.formi2.ExpMonth.disabled = false
   }else{
      document.formi2.CardNamei.value = ""
	  document.formi2.CustID.value = ""
	  document.formi2.CardID.value = ""
	  document.formi2.ExpYear.options[0].selected = true
	  document.formi2.ExpMonth.options[0].selected = true
	  document.formi2.CardNamei.disabled = true
	  document.formi2.CustID.disabled = true
	  document.formi2.CardID.disabled = true
	  document.formi2.ExpYear.disabled = true
	  document.formi2.ExpMonth.disabled = true
   }
}

function placeOrder(){
	var pProducts_1 = document.formi2.Products_1.value*1;
	var pProducts_2 = document.formi2.Products_2.value*1;
	var pProducts_3 = document.formi2.Products_3.value*1;
	var pProducts_4 = document.formi2.Products_4.value*1;
	var pProducts_5 = document.formi2.Products_5.value*1;
	var pProducts_6 = document.formi2.Products_6.value*1;
	var pProducts_7 = document.formi2.Products_7.value*1;
	var pProducts_8 = document.formi2.Products_8.value*1;
	var pNamei = document.formi2.Namei.value;
	//var pEmail = document.formi2.Email.value;
	var pPhone = document.formi2.Phone.value;
	var pPrePhone = document.formi2.PrePhone.value;
	var pAddress = document.formi2.Address.value;
	var pCity = document.formi2.City.value;
	var pZip = document.formi2.Zip.value;
	
	var pPhoneDetails = document.formi2.PhoneDetails.checked;
	
	var pCardNamei = document.formi2.CardNamei.value;
	var pCustID = document.formi2.CustID.value;
	var pCardID = document.formi2.CardID.value;
	var pExpYear = document.formi2.ExpYear.value;
	var pExpMonth = document.formi2.ExpMonth.value;
	
	pTotal = (pProducts_1+pProducts_2+pProducts_3+pProducts_4+pProducts_5+pProducts_6+pProducts_7+pProducts_8)*1
	
	if(pTotal==0){
	   alert("אנא בחר לפחות קמע אחד להזמנה")
	   return false
	}
	
	if(delSpace(pNamei)==""){
	   alert("אנא הזן שם מלא")
	   document.formi2.Namei.focus()
	   return false
	}
	
	/*
	if(delSpace(pEmail)==""){
	   alert("אנא הזן כתובת דוא\"ל")
	   document.formi2.Email.focus()
	   return false
	}else{
	   if(pEmail.indexOf(".")==-1||pEmail.indexOf("@")==-1){
	      alert("כתובת הדוא\"ל אשר הזנת אינה חוקית")
		  document.formi2.Email.focus()
		  return false
	   }
	}
	*/
	
	if(delSpace(pPrePhone)==""){
	   alert("אנא הזן קידומת לטלפון")
	   document.formi2.PrePhone.focus()
	   return false
	}
	
	if(delSpace(pPhone)==""){
	   alert("אנא הזן מספר טלפון")
	   document.formi2.Phone.focus()
	   return false
	}
	
	if(delSpace(pAddress)==""){
	   alert("אנא הזן כתובת")
	   document.formi2.Address.focus()
	   return false
	}
	
	if(delSpace(pCity)==""){
	   alert("אנא הזן עיר מגורים")
	   document.formi2.City.focus()
	   return false
	}
	
	if(pPhoneDetails==false){
	   
	   if(delSpace(pCardNamei)==""){
		 alert("אנא הזן שם בעל הכרטיס")
		 document.formi2.CardNamei.focus()
		 return false
	   }
	   
	   if(delSpace(pCustID)==""){
		 alert("אנא הזן ת.ז")
		 document.formi2.CustID.focus()
		 return false
	   }
	   
	   if(delSpace(pCardID)==""){
		 alert("אנא הזן מספר כרטיס")
		 document.formi2.CardID.focus()
		 return false
	   }
	   
	   if(delSpace(pExpYear)==""||delSpace(pExpMonth)==""){
		 alert("אנא הזן תוקף")
		 if(delSpace(pExpYear)==""){
		    document.formi2.ExpYear.focus()
		 }else{
		    document.formi2.ExpMonth.focus()
		 }
		 return false
	   }
	   
	}
	
	document.formi2.action = "OrderExec.asp"
	
	document.formi2.sendi.disabled = true
	
}


function showTR(who){
    if(document.getElementById("OrdTr_"+who).style.display==""){
	   document.getElementById("OrdTr_"+who).style.display = "none"
	}else{
	   document.getElementById("OrdTr_"+who).style.display = ""
	}
}


function OrderStatus(who,what){
    var url="OrderStatus.asp?sid=" + Math.random() + "&who=" + escape(who) + "&what=" + escape(what)
    xmlHttp=GetXmlHttpObjectSubject(XMLOrderStatus)
    xmlHttp.open("GET", url , true)
    xmlHttp.send(null)
    return false
}

function XMLOrderStatus(){ 
   if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete"){ 
		pstrtohandle = xmlHttp.responseText
   } 
}

function GetXmlHttpObjectSubject(handler){ 
var objXmlHttp=null

if (navigator.userAgent.indexOf("MSIE")>=0){ 
var strName="Msxml2.XMLHTTP"
if (navigator.appVersion.indexOf("MSIE 5.5")>=0){
strName="Microsoft.XMLHTTP"
} 
try{ 
objXmlHttp=new ActiveXObject(strName)
objXmlHttp.onreadystatechange=handler 
return objXmlHttp
} 
catch(e){ 
alert("Error. Scripting for ActiveX might be disabled") 
return 
} 
} 

objXmlHttp=new XMLHttpRequest()
objXmlHttp.onload=handler
objXmlHttp.onerror=handler 
return objXmlHttp

}

function playMusic(what){
   if(what=="images/speaker.gif"){
	  document.getElementById("NSPlaySound").Stop()
	  document.getElementById("iconMusic").src = "images/speaker_Off.gif"
   }else{
      document.getElementById("NSPlaySound").Play()
	  document.getElementById("iconMusic").src = "images/speaker.gif"
   }
}

function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}


