var g_oHttp;
if (window.XMLHttpRequest)     // Object of the current windows
{
    g_oHttp = new XMLHttpRequest();     // Firefox, Safari, ...
}
else
    if (window.ActiveXObject)   // ActiveX version
{
    //g_oHttp = new ActiveXObject("Microsoft.XMLHTTP");  // Internet Explorer
    g_oHttp =  new ActiveXObject('Msxml2.XMLHTTP');
} 


var g_aBannerIndex = new Array();

function fFlash(sFile, nWidth, nHeight){
	document.write('<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,40,0" width="' + nWidth + '" height="' + nHeight + '"><param name="movie" value="' + sFile + '" /><param name="wmode" value="transparent" /><embed src="'+sFile+'" quality="high" width="'+nWidth+'" height="'+nHeight+'" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash"></embed></object>');
	
	
}

function fPopUp(sHref, nMode){
	var winPopup;
	switch(nMode){
		case 0: // Generic
			winPopup = window.open(sHref, 'winPopup', 'toolbar=no, status=no, menubar=no, scrollbars=yes, resizable=yes, width=600, height=400');
		case 1: // Coupon
			winPopup = window.open(sHref, 'winPopup', 'toolbar=no, status=no, menubar=no, scrollbars=yes, movable=yes, resizable=no, width=480, height=350');
		case 2: // Send to a Friend
			winPopup = window.open(sHref, 'winPopup', 'toolbar=no, status=no, menubar=no, scrollbars=yes, movable=yes, resizable=no, width=360, height=470');
		case 3: // Update Us
			winPopup = window.open(sHref, 'winPopup', 'toolbar=no, status=no, menubar=no, scrollbars=yes, movable=yes, resizable=no, width=400, height=630');
		case 4: // Ask the Chef
			winPopup = window.open(sHref, 'winPopup', 'toolbar=no, status=no, menubar=no, scrollbars=yes, width=450, height=400');
		case 5: // eMap
			winPopup = window.open(sHref, 'winPopup', 'toolbar=no, status=no, menubar=no, scrollbars=no, movable=yes, resizable=yes, width=850, height=650');
		case 6: // Job
			winPopup = window.open(sHref, 'winPopup', 'toolbar=no, status=no, menubar=no, scrollbars=yes, movable=yes, resizable=no, width=390, height=350');
		case 7: // Update Us
		    winPopup = window.open(sHref, 'winPopup', 'toolbar=no, status=no, menubar=no, scrollbars=yes, movable=yes, resizable=no, width=400, height=650');
		case 8: // Update Us
		    winPopup = window.open(sHref, 'winPopup', 'toolbar=no, status=no, menubar=no, scrollbars=yes, movable=yes, resizable=no, width=690, height=780');	
		default:
			winPopup = window.open(sHref, 'winPopup', 'toolbar=no, status=no, menubar=no');
	}
}

function fImagePopup(sPath){
	winPopup = window.open('/magazine/ImagePopup.asp?txtImagePath=' + sPath, 'winPopup', 'toolbar=no, status=no, menubar=no, scrollbars=no, movable=yes, resizable=yes, width=300, height=300');
}

function fCenterWindow(oWindow){
	var nY = new Number((window.screen.availHeight - oWindow.document.body.offsetHeight) / 2 - 200);
	var nX = new Number((window.screen.availWidth - oWindow.document.body.offsetWidth) / 2);
	oWindow.moveTo(nX, nY);
}

function fGetX(oElement){
	return(oElement.offsetParent == null ? oElement.offsetLeft : oElement.offsetLeft + fGetX(oElement.offsetParent));
}

function fGetY(oElement){
	return(oElement.offsetParent == null ? oElement.offsetTop : oElement.offsetTop + fGetY(oElement.offsetParent));
}

function fSwitch(oElement){
	if(oElement.style.display == 'none'){
		oElement.style.display = 'block';
	}else{
		oElement.style.display = 'none';
	}
}

function fCheckEmail(oField){
	var sEmail=oField.value;
	var reFilter=/^([\w-]+(?:\.[\w-]+)*)@((?:[\w-]+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$/i;
	if (reFilter.test(sEmail)){
		return true;
	}else{
		return false;
	}
}

function fClearForm(oForm){
	for(var a = 0; a < oForm.elements.length; a++){
		if(oForm.elements[a].type == 'text' || oForm.elements[a].type == 'hidden'){oForm.elements[a].value = '';}
		if(oForm.elements[a].type == 'select'){oForm.elements[a].selectedIndex = 0;}
		if(oForm.elements[a].type == 'checkbox'){oForm.elements[a].checked = false;}
	}
}

function fParseForm(oForm) {
    var sQS = new String('');
    
	for (var nIndex = 0; nIndex < oForm.elements.length; nIndex++){
		if(oForm.elements[nIndex].name != ''){
			switch(oForm.elements[nIndex].type){
				case 'checkbox':
					if(oForm.elements[nIndex].checked){
						sQS += (sQS == '') ? '' : '&';
						sQS += oForm.elements[nIndex].name + '=' + escape(oForm.elements[nIndex].value);
					}
					break;
					
				case 'radio':
					if(oForm.elements[nIndex].checked){
						sQS += (sQS == '') ? '' : '&';
						sQS += oForm.elements[nIndex].name + '=' + escape(oForm.elements[nIndex].value);
					}
					break;
					
				default:
					sQS += (sQS == '') ? '' : '&';
					sQS += oForm.elements[nIndex].name + '=' + escape(oForm.elements[nIndex].value);
				
			}
		}
	}
	sQS += '\n';
	return sQS;
}

function fGetCheckboxes(oForm, sSetDelimiter){
	var sContent = new String('');
	var nChecks = new Number(0);
	var sDelimiter = 'undefined' ? ', ' : sSetDelimiter
	for (var nIndex = 0; nIndex < oForm.elements.length; nIndex++){
		if(oForm.elements[nIndex].name != '' && oForm.elements[nIndex].type == 'checkbox'){
			if(oForm.elements[nIndex].checked){
				sContent += (nChecks > 0) ? sDelimiter : '';
				sContent += escape(oForm.elements[nIndex].value);
				nChecks++;
			}
		}
	}
	return sContent;
}

function fShowItems(sElement1, sElement2, sValue, nActionID){
	var oElement = eval(sElement1);
	var oFrame = document.all['ifrItems'];
	
	if(oElement.value.length > 0){
		oFrame.style.width = oElement.offsetWidth;
		oFrame.style.height = '80px';
		oFrame.style.top = fGetY(oElement) + oElement.offsetHeight;
		oFrame.style.left = fGetX(oElement);

		var frame = document.getElementById("ifrItems");
		frame.src = '/!!/Process.aspx?txtActionID=' + nActionID + '&txtItemName=' + sValue + '&txtRef1=' + sElement1 + '&txtRef2=' + sElement2;
		oFrame.style.visibility = 'visible';
	}else{
		fHideFrame();
	}
}

function fSetField(sValue, nItemID, sElement1, sElement2){
	var oElement1 = eval(sElement1);
	var oElement2 = eval(sElement2);
	oElement1.value = sValue;
	oElement2.value = nItemID;
	fHideFrame();
}

function fHideFrame(){
	var oFrame = document.all['ifrItems'];
	oFrame.style.visibility = 'hidden';
}

function fHpSearchSubmit(nActionID){
	var oForm = frmHpSearch;
	var bValid = new Boolean(true);

	oForm.txtActionID.value = nActionID;

	if(bValid && nActionID == 3 && oForm.txtRestName.value.length < 1){
		alert('נא הזן/י לפחות תו אחד בשם המסעדה');
		bValid = false;
	}

	if(bValid){
		if(oForm.txtAddress){
			if(oForm.txtAddress.value == '--כל הרחובות--'){
				oForm.txtAddress.value = '';
			}
		}
		oForm.submit();
	}
}

function fHpSearchSubmitWithStats(nActionID,category,action,optional_label){
	var oForm = frmHpSearch;
	var bValid = new Boolean(true);

	oForm.txtActionID.value = nActionID;

	if(bValid && nActionID == 3 && oForm.txtRestName.value.length < 1){
		alert('נא הזן/י לפחות תו אחד בשם המסעדה');
		bValid = false;
	}

	if(bValid){
		if(oForm.txtAddress){
			if(oForm.txtAddress.value == '--כל הרחובות--'){
				oForm.txtAddress.value = '';
			}
		}
		
		pageTracker._trackEvent(category, action, optional_label);
		oForm.submit();
	}
}

function fHpSearchRegionChanged(nRegionID, sTargetContainer, sSecondTargetContainer, nWidth){
	var sResponse = new String();
	var oContainer = document.all[sTargetContainer];

	//oContainer.innerHTML = '<span style="FONT-SIZE: 8pt;">מעדכן נתונים...</span>';

	g_oHttp.open('POST', '/search/Default.asp', false);
	g_oHttp.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
	g_oHttp.send('txtActionID=1&txtRegionID=' + nRegionID);
	
	sResponse = g_oHttp.responseText;
	
	if(sResponse.indexOf('##') != 0){
		if(document.getElementById('txtErrorBuffer')) document.getElementById('txtErrorBuffer').innerText = sResponse;
		if (nRegionID != 3){
		  oContainer.innerHTML = '<select name="txtCityID" style="FONT-SIZE: 8pt; WIDTH: ' + nWidth + 'px;" onchange="fHpSearchCityChanged(this.value, \'' + sSecondTargetContainer + '\', \'' + nWidth + '\');"><option value="0">--כל הישובים--</option>' + unescape(sResponse) + '</select>';}
		else {
		 oContainer.innerHTML = '<select name="txtCityID" style="FONT-SIZE: 8pt; WIDTH: ' + nWidth + 'px;" onchange="fHpSearchCityChanged(this.value, \'' + sSecondTargetContainer + '\', \'' + nWidth + '\');">' + unescape(sResponse) + '</select>';}
		if(sSecondTargetContainer.length > 0){
			//fHpSearchCityChanged(0, sSecondTargetContainer, nWidth);
		}
	}else{
		alert(sResponse);
	}
}

function RegionChanged(nRegionID, sTargetContainer,  nWidth) {
    var sResponse = new String();
    var oContainer = document.all[sTargetContainer];

    oContainer.innerHTML = '<span style="FONT-SIZE: 8pt;">מעדכן נתונים...</span>';

    g_oHttp.open('POST', '/search/Default.asp', false);
    g_oHttp.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
    g_oHttp.send('txtActionID=1&txtRegionID=' + nRegionID);

    sResponse = g_oHttp.responseText;


    if (sResponse.indexOf('##') != 0) {
        oContainer.innerHTML = '<select name="txtCityID" style="WIDTH:' + nWidth + 'px;">' + unescape(sResponse) + '</select>';
    } else {
        alert(sResponse);
    }
}

function fHpSearchCityChanged(nCityID, sTargetContainer, nWidth){
	/*var sResponse = new String();
	var oContainer = document.all[sTargetContainer];

	if(sTargetContainer.length > 0){
		if(!oContainer){
			oContainer = eval(sTargetContainer);
		}
		
		oContainer.innerHTML = '<span style="FONT-SIZE: 8pt;">מעדכן נתונים...</span>';
	
		g_oHttp.open('POST', '/search/Default.asp', false);
		g_oHttp.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
		g_oHttp.send('txtActionID=2&txtCityID=' + nCityID);
		
		sResponse = g_oHttp.responseText;
		
		if(sResponse.indexOf('##') != 0){
			//alert(sResponse);
			oContainer.innerHTML = '<select name="txtTypeID" style="FONT-SIZE: 8pt; WIDTH: ' + nWidth + 'px;"><option value="0">--כל הסוגים--</option>' + unescape(sResponse) + '</select>';
		}else{
			alert(sResponse);
		}
	}*/
}

function fCreateBanner(sSourceDiv, nWidth, nHeight, sURL){
	var sContent = new String('');
	if(sSourceDiv == 'argusBanner103' || sSourceDiv == 'argusBanner104' || sSourceDiv == 'argusBanner105'){
		sContent = '<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000"' +
				'	codebase="https://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,0,0"' +
				'	width="' + nWidth + '" height="' + nHeight + '" id="flash_' + sSourceDiv + '" align="middle">' +
				'		<param name="allowScriptAccess" value="sameDomain" />' + 
				'		<param name="movie" value="' + sURL + '" />' +
				'		<param name="quality" value="high" />' +
				'		<param name="bgcolor" value="#ffffff" />' + 
				'		<embed src="' + sURL + '" quality="high" bgcolor="#ffffff" width="' + nWidth + '" height="' + nHeight + '" name="flash_' + sSourceDiv + '" align="middle" allowScriptAccess="sameDomain" type="application/x-shockwave-flash" pluginspage="http://www.adobe.com/go/getflashplayer" />' +
				'</object>'
	}else{
		sContent = '<object ' +
				'	classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" ' +
				'	codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,40,0" ' +
				'	width="' + nWidth + '" ' +
				'	height="' + nHeight + '">' +
				'	<param ' +
				'		name="movie" ' +
				'		value="' + sURL + '" />' +
				'	<param name="wmode" value="transparent" />' +
				'</object>';
	}
	if(document.getElementById(sSourceDiv)) document.getElementById(sSourceDiv).innerHTML = sContent;
}

function fInitRotateBanners(sBannerArray){
	var aBanners = eval('aArgusBanner' + sBannerArray);
	if(!g_aBannerIndex[sBannerArray]) g_aBannerIndex[sBannerArray] = 0;
	if(aBanners[g_aBannerIndex[sBannerArray]] != null){
		fCreateBanner(aBanners[g_aBannerIndex[sBannerArray]][0], aBanners[g_aBannerIndex[sBannerArray]][2], aBanners[g_aBannerIndex[sBannerArray]][3], aBanners[g_aBannerIndex[sBannerArray]][1]);
		window.setTimeout('fInitRotateBanners(\'' + sBannerArray + '\');', (aBanners[g_aBannerIndex[sBannerArray]][4] * 1000));
	}else{
		window.setTimeout('fInitRotateBanners(\'' + sBannerArray + '\');', 1000);
	}
	g_aBannerIndex[sBannerArray]++;
	g_aBannerIndex[sBannerArray] = g_aBannerIndex[sBannerArray] >= aBanners.length ? 0 : g_aBannerIndex[sBannerArray];
}

function fAlignFloatBanner(sBannerRef){
	var oBanner = document.getElementById(sBannerRef);
	oBanner.style.left = (document.body.offsetWidth / 2) - (oBanner.offsetWidth / 2) - 50;
	oBanner.style.top = '250px';
	/*oBanner.style.top = '100px';
	if(oBanner){
		if(document.body.offsetWidth < 870){
			oBanner.style.display = 'none';
		}else{
			oBanner.style.left = document.body.offsetWidth - 70 - 22;
			oBanner.style.display = 'block';
		}
	}
	
	if(sBannerRef == 'argusBanner97'){
		//window.setTimeout('document.getElementById(\'' + sBannerRef + '\').style.display = \'none\';', 6000)
	}*/
}

function isMatchCookie(cookie)
{
    var result = document.cookie.match ( cookie + '=(.*?)(;|$)' );
    if (result)
      {     
            if ((result[1] != ""))
            {     
                return true;
            }
      }
      return false;           
}

 

function createCookie(cookieName, cookieValue, days)
{
    if (days) {
            var date = new Date();
            date.setTime(date.getTime()+(days*24*60*60*1000));
            var expires = "; expires="+date.toGMTString();
      }
      else var expires = "";
      document.cookie = cookieName+"="+cookieValue+expires+"; path=/";    
}

function checkFlashCookie(sSourceDiv, nWidth, nHeight, sURL)
{
	var cookieName = "flashEarth";
	var cookieValue = "true";
	if (isMatchCookie(cookieName)) return true
	else 
	{
		createCookie(cookieName, cookieValue, 2);
		fCreateBanner(sSourceDiv, nWidth, nHeight, sURL);
	}
}

function fAlignFloatBanner42(sBannerRef){	
	var oBanner = document.getElementById(sBannerRef);
	oBanner.style.left = (document.body.offsetWidth / 2) - (oBanner.offsetWidth / 2) - 88;
	oBanner.style.top = '-0px';
}

function fUncoverPhone(nRestID){
	g_oHttp.open('POST', '/search/Default.asp', false);
	g_oHttp.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
	g_oHttp.send('txtActionID=6&txtRestID=' + nRestID);

	document.getElementById('divPhoneLbl' + nRestID).innerHTML = document.getElementById('divPhoneNum' + nRestID).innerText;
}

function openfold(){
	fUnfoldBanner();
}

function closefold(){
	fFoldBanner();
}

/*
	Argus Ticker
*/

var g_nArgusTickerTimerID = new Array();

var fArgusTicker_scroll = function(nTickerID, nSpeed){
	var oTicker = document.getElementById('argusTicker' + nTickerID);
	var oContainer = document.getElementById('argusTickerContainer' + nTickerID);
	var nMoveTo = new Number(oContainer.style.top.replace('px', ''));
	var oBufferNode = new Object();

	nMoveTo -= 1;
	oContainer.style.top = nMoveTo;
	
	//alert(oContainer.childNodes[0].offsetHeight);
	if(oContainer.childNodes[0].offsetHeight > 0 && Math.abs(nMoveTo) >= oContainer.childNodes[0].offsetHeight){
		//alert(oContainer.childNodes[0].offsetHeight + '\n' + Math.abs(nMoveTo));
		oBufferSlide = oContainer.childNodes[0].cloneNode(true);
		oContainer.removeChild(oContainer.childNodes[0]);
		oContainer.style.top = '0px';
		oContainer.appendChild(oBufferSlide);
	}
			
	g_nArgusTickerTimerID[nTickerID] = window.setTimeout('fArgusTicker_scroll(' + nTickerID + ', ' + nSpeed + ');', nSpeed);
}

var fArgusTicker_pause = function(nTickerID){
	window.clearInterval(g_nArgusTickerTimerID[nTickerID]);
}
var fArgusTicker = function(aSlides, nWidth, nHeight, sSeperator, nSpeed, nTickerID){
	document.write('<div id="argusTicker' + nTickerID + '" style="WIDTH: ' + nWidth + 'px; HEIGHT: ' + nHeight + 'px; OVERFLOW-Y: hidden;" onmouseover="fArgusTicker_pause(' + nTickerID + ');" onmouseout="fArgusTicker_scroll(' + nTickerID + ', ' + nSpeed + ');">');
	document.write('	<div id="argusTickerContainer' + nTickerID + '" style="POSITION: relative;">');
	for(var nIndex = 0; nIndex < aSlides.length; nIndex++){
		document.write('		<div id="argusTickerSlide' + nTickerID + '_' + nIndex + '" style="POSITION: relative;">');
		document.write('			<div style="COLOR: #A10000; FONT-SIZE: 8pt; PADDING: 0px 3px 3px 6px;" lign="left">' + aSlides[nIndex][1] + '</div>');
		document.write('			<div style="FONT-SIZE: 9pt; PADDING: 0px 3px 15px 0px;">' + aSlides[nIndex][2] + '</div>');
		if(sSeperator.length > 1){
			//document.write('			<div style="PADDING: 3px 0px 3px 0px;">' + sSeperator + '</div>');
		}
		document.write('		</div>');
	}
	document.write('	</div>');
	document.write('</div>');
	fArgusTicker_scroll(nTickerID, nSpeed);
}


                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                
