// JavaScript Document
//=========================================================
function ActionDeterminator() {
	var sfrm = document.form2;
	var sval = sfrm.cboStore.value; 
	
	if(sfrm.what[1].checked == true)
		sfrm.action = 'storeresults.asp';
	else
		{
		if (sfrm.cboMall.value != '' && document.form2.cboCategory.value != '')
			sfrm.action = 'storeresults.asp';
		else
			sfrm.action = 'mallresults.asp'; 
		 }
	
	//== Replace & with * (for search results pages) ==
	if (sval != '') {sfrm.cboStore.value = sval.replace("&","*");}
	
	return true; 
}
//=========================================================
function ClearHelpText() {
	if (document.form2.cboStore.value == "-- לפי שם --") {
		document.form2.cboStore.value = "";
	}
}
//=========================================================
function AddHelpText() {
	if (document.form2.cboStore.value == "") {
		document.form2.cboStore.value = "-- לפי שם --";
	}
}
//=========================================================
function ClearHelpText2(fld) {
	if (fld.value == "-- לפי שם --" || fld.value == "-- לפי שם קניון --" || fld.value == "-- לפי שם חנות --" || fld.value == "-- לפי שם מבצע --" || fld.value == "-- לפי שם אירוע --")
		 fld.value = "";
	else if (fld.value != "")
		 fld.value = fld.value.replace("&","*");	  
}
//=========================================================
function AddHelpText2(fld) {
	if (fld.value == "") {
		fld.value = "-- לפי שם --";
	}
}
//=========================================================
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_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_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];}
}
//=========================================================
var win= null;
//=========================================================
function NewWindow(mypage,myname,w,h,scroll){
  var winl = (screen.width-w)/2;
  var wint = (screen.height-h)/2;
  var settings  ='height='+h+',';
      settings +='width='+w+',';
      settings +='top='+wint+',';
      settings +='left='+winl+',';
      settings +='scrollbars='+scroll+',';
      settings +='resizable=no';
  win=window.open(mypage,myname,settings);
  if(parseInt(navigator.appVersion) >= 4){win.window.focus();}
}
//=========================================================
function NewWindow2(url,width,height,toolbar) {
	if(toolbar==1) {
		openWin(url,'Kenyonim','toolbar=yes,location=yes,directories=yes,status=yes,menubar=yes,scrollbars=yes,resizable=yes,width='+width+',height='+height)
		}
	else {
		openWin(url,'Kenyonim','toolbar=no,location=no,directories=no,status=yes,menubar=no,scrollbars=no,movable=yes,resizable=yes,width='+width+',height='+height)
		}
	}
//=========================================================
function openWin(url,title,attrib) {
	wref=window.open(url,title,attrib);
	if(MSIE_VER()>=5)wref.focus()
	}
//=========================================================
function hideMessage(divname) {
		document.getElementById(divname).style.display='none';
		return true;
		}
//=========================================================
function MSIE_VER() {
	agt=navigator.userAgent.toLowerCase();
	pos=agt.indexOf('msie')+1;
	if(pos)return agt.charAt(pos+4);
	return 0
	}
//=========================================================
function chkFormular(frm){
	
	if(frm.name.value == ""){
	  alert("לא מולא שם");
	  frm.name.focus();
	  return false;
	 }
	if(frm.lname.value == ""){
	  alert("לא מולא שם המשפחה");
	  frm.lname.focus();
	  return false;
	 }
	if(frm.email.value == ""){
	  alert("לא הוכנסה כתובת אימייל תקינה");
	  frm.email.focus();
	  return false;
	 }	 
	if(frm.details.value == ""){
	  alert("לא מולאו פרטי הפנייה");
	  frm.details.focus();
	  return false;
	 }
	
	return true;
 }
//=========================================================
function populatecities(value)
{
if(document.form2.cboArea != ""){
	var objHTTP = new ActiveXObject("Microsoft.XMLHTTP")
	objHTTP.Open('GET',m_dir+'xmlfor_cities.asp?areaid='+ value,false)
	objHTTP.Send()
	document.all['tdforcities'].innerHTML= objHTTP.responseText
}
if(document.form2.cboArea == ""){
	var objHTTP = new ActiveXObject("Microsoft.XMLHTTP")
	objHTTP.Open('GET',m_dir+'xmlfor_allcities.asp'+ value,false)
	objHTTP.Send()
	document.all['tdforcities'].innerHTML= objHTTP.responseText
}
}
//=========================================================
function populatemalls(value)
{
if(document.form2.cboArea.value != ""){
	var objHTTP = new ActiveXObject("Microsoft.XMLHTTP")
	objHTTP.Open('GET',m_dir+'xmlfor_malls.asp?areaid='+ value,false)
	objHTTP.Send()
	document.all['tdformalls'].innerHTML= objHTTP.responseText
}
if(document.form2.cboArea.value == ""){
	var objHTTP = new ActiveXObject("Microsoft.XMLHTTP")
	objHTTP.Open('GET',m_dir+'xmlfor_allmalls.asp'+ value,false)
	objHTTP.Send()
	document.all['tdformalls'].innerHTML= objHTTP.responseText
}
}
//=========================================================
function populatemallsbycity(value)
{
if(document.form2.cboCities.value != ""){
	var objHTTP = new ActiveXObject("Microsoft.XMLHTTP")
	objHTTP.Open('GET',m_dir+'xmlfor_mallsbycity.asp?cityid='+ value,false)
	objHTTP.Send()
	document.all['tdformalls'].innerHTML= objHTTP.responseText
}
if(document.form2.cboCities.value == ""){
	var objHTTP = new ActiveXObject("Microsoft.XMLHTTP")
	objHTTP.Open('GET',m_dir+'xmlfor_allmalls.asp'+ value,false)
	objHTTP.Send()
	document.all['tdformalls'].innerHTML= objHTTP.responseText
}
}
//=========================================================
function populatecities2(n,value){
	if(document.forms['form'+n].cboArea.value != ""){
		var objHTTP = new ActiveXObject("Microsoft.XMLHTTP")
		objHTTP.Open('GET',m_dir+'xmlfor_cities2.asp?areaid='+value+'&n='+n,false)
		objHTTP.Send()
		document.all['tdforcities'+n].innerHTML= objHTTP.responseText
	}
	if(document.forms['form'+n].cboArea.value == ""){
		var objHTTP = new ActiveXObject("Microsoft.XMLHTTP")
		objHTTP.Open('GET',m_dir+'xmlfor_allcities.asp'+ value,false)
		objHTTP.Send()
		document.all['tdforcities'+n].innerHTML= objHTTP.responseText
	}
}
//=========================================================
function populatemalls2(n,value,cname){
	if(document.forms['form'+n].cboArea.value != ""){
		var objHTTP = new ActiveXObject("Microsoft.XMLHTTP")
		objHTTP.Open('GET',m_dir+'xmlfor_malls.asp?areaid='+ value+'&cname='+cname,false)
		objHTTP.Send()
		document.all['tdformalls'+n].innerHTML= objHTTP.responseText
	}
	if(document.forms['form'+n].cboArea.value == ""){
		var objHTTP = new ActiveXObject("Microsoft.XMLHTTP")
		objHTTP.Open('GET',m_dir+'xmlfor_allmalls.asp?cname='+cname,false)
		objHTTP.Send()
		document.all['tdformalls'+n].innerHTML= objHTTP.responseText
	}
}
//=========================================================
function populatemallsbycity2(n,value) {
	if(document.forms['form'+n].cboCities.value != ""){
		var objHTTP = new ActiveXObject("Microsoft.XMLHTTP")
		objHTTP.Open('GET',m_dir+'xmlfor_mallsbycity.asp?cityid='+ value,false)
		objHTTP.Send()
		document.all['tdformalls'+n].innerHTML= objHTTP.responseText
	}
	
	if(document.forms['form'+n].cboCities.value == ""){
		var objHTTP = new ActiveXObject("Microsoft.XMLHTTP")
		objHTTP.Open('GET',m_dir+'xmlfor_allmalls.asp'+ value,false)
		objHTTP.Send()
		document.all['tdformalls'+n].innerHTML= objHTTP.responseText
	}
}

//=========================================================
function addBookmark(title,url) {
  if (window.sidebar)
    window.sidebar.addPanel(title, url,"");
  else if( document.all )
    window.external.AddFavorite( url, title);
  else
    return true;
}
//=========================================================
function chkFormularJoin()
{
 if(document.formix.name.value == "")
  {
   alert("שם");
   document.formix.name.focus();
   return false;
  }
 if(document.formix.famname.value == "")
  {
   alert("שם משפחה");
   document.formix.famname.focus();
   return false;
}
 if(document.formix.email.value == "")
  {
   alert("דאר אלקטרוני");
   document.formix.email.focus();
   return false;
  }
      if(document.formix.email.value.indexOf('@') == -1)
  {
   alert("דאר אלקטרוני");
   document.formix.email.focus();
   return false;
  }
if(document.formix.bdateday.value == "0")
 {
  alert("יום");
  document.formix.bdateday.focus();
  return false;
 }
if(document.formix.bdatemonth.value == "0")
{
 alert("חודש");
 document.formix.bdatemonth.focus();
 return false;
}
if(document.formix.bdateyear.value == "0")
{
 alert("שנה");
 document.formix.bdateyear.focus();
 return false;
}
 if(document.formix.secs[0].checked==false && document.formix.secs[1].checked==false)
  {
   alert("מין");
   return false;
  }
 if(document.formix.mall.value == "")
  {
   alert("מרכז קניות או קניון מועדף");
   document.formix.mall.focus();
   return false;
  }
}
//=========================================================
function grayOut(vis, options) {  
// Pass true to gray out screen, false to ungray  
// options are optional.  This is a JSON object with the following (optional) properties:  
// opacity:0-100       // Lower number = less grayout higher = more of a blackout   
// zindex: #   // HTML elements with a higher zindex appear on top of the gray out 
// bgcolor: (#xxxxxx)    // Standard RGB Hex color code  
// grayOut(true, {'zindex':'50', 'bgcolor':'#0000FF', 'opacity':'70'});  
// Because options is JSON opacity/zindex/bgcolor are all optional and can appear  
// in any order.  Pass only the properties you need to set.  
var options = options || {};   
var zindex = options.zindex || 50;  
var opacity = options.opacity || 70;  
var opaque = (opacity / 100);  
var bgcolor = options.bgcolor || '#000000';  
var dark=document.getElementById('darkenScreenObject');  
if (!dark) {    
	 // The dark layer doesn't exist, it's never been created.  So we'll    
	 // create it here and apply some basic styles.    
	 // If you are getting errors in IE see: http://support.microsoft.com/default.aspx/kb/927917    
	 var tbody = document.getElementsByTagName("body")[0];
	 var tnode = document.createElement('div');     // Create the layer.        
	 tnode.style.position='absolute';           // Position absolutely        
	 tnode.style.top='0px';                           // In the top        
	 tnode.style.left='0px';                          // Left corner of the page        
	 tnode.style.overflow='hidden';                   // Try to avoid making scroll bars                    
	 tnode.style.display='none';                      // Start out Hidden        
	 tnode.id='darkenScreenObject';                   // Name it so we can find it later    
	 tbody.appendChild(tnode);                            // Add it to the web page    
	 dark=document.getElementById('darkenScreenObject');  // Get the object.  
	 }  
if (vis) {    
	 // Calculate the page width and height     
	 if( document.body && ( document.body.scrollWidth || document.body.scrollHeight ) ) {        
	 	   var pageWidth = document.body.scrollWidth+'px';        
	 	   var pageHeight = document.body.scrollHeight+'px';    
	 	   } 
	 else if( document.body.offsetWidth ) {      
	 	   var pageWidth = document.body.offsetWidth+'px';      
		   var pageHeight = document.body.offsetHeight+'px';    
		   } 
	 else {       
	 		var pageWidth='100%';       
			var pageHeight='100%';    
			}       
			//set the shader to cover the entire page and make it visible.    
		dark.style.opacity=opaque;                          
		dark.style.MozOpacity=opaque;                       
		dark.style.filter='alpha(opacity='+opacity+')';     
		dark.style.zIndex=zindex;            
		dark.style.backgroundColor=bgcolor;      
		dark.style.width= pageWidth;    
		dark.style.height= pageHeight;    
		dark.style.display='block';                            
		} 
else {     
		dark.style.display='none';
		}
}
//=========================================================