﻿// 29/03/2011 slCheck
// JScript File
// hide articles and show selected
function ShowArticle(nart)
{
	var hpos = YAHOO.util.Dom.getXY('noShow');
	//var hposPic = YAHOO.util.Dom.getXY('noShowPic');
	var doShow = document.getElementById('doShow')
		doShow.innerHTML = "" ;
	var doShowPic = document.getElementById('doShowPic')
		//doShowPic.innerHTML = "" ;
	
	var DoShowPicHide = document.getElementById('doShowPicHide')
			DoShowPicHide.style.visibility="hidden";
	
	YAHOO.util.Dom.setXY('imgP1', hpos);
	YAHOO.util.Dom.setXY('imgP2', hpos);
	YAHOO.util.Dom.setXY('imgP3', hpos);
	YAHOO.util.Dom.setXY('imgP4', hpos);
	var sposPic = YAHOO.util.Dom.getXY('doShowPic');
	YAHOO.util.Dom.setXY('imgP'+nart, sposPic);
	
	YAHOO.util.Dom.setXY('Li1', hpos);
	YAHOO.util.Dom.setXY('Li2', hpos);
	YAHOO.util.Dom.setXY('Li3', hpos);
	YAHOO.util.Dom.setXY('Li4', hpos);
	var spos = YAHOO.util.Dom.getXY('doShow');
	YAHOO.util.Dom.setXY('Li'+nart, spos);
	
	document.getElementById('td1').className = "MainBoxCubeOff";
	document.getElementById('td2').className = "MainBoxCubeOff";
	document.getElementById('td3').className = "MainBoxCubeOff";
	document.getElementById('td4').className = "MainBoxCubeOff";
	document.getElementById('td'+nart).className = "MainBoxCubeOffh";
}
// מטפל בהכנסת קבצים שצריכים אקטיב-איכס
function FixAX(strSRC,w,h,type)
{
switch (type)
	{
		case "flash":
			{
				document.write("<OBJECT classid=clsid:D27CDB6E-AE6D-11cf-96B8-444553540000 codebase=http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,0,0 WIDTH=" + w + " HEIGHT=" + h + " id=searc>")
				document.write("<PARAM NAME=movie VALUE=" + strSRC)
				document.write("><PARAM NAME=quality VALUE=high><PARAM NAME=bgcolor VALUE=#FFFFFF><EMBED src=" + strSRC + " WIDTH=" + w + " HEIGHT=" + h + " NAME=searc ALIGN= TYPE=application/x-shockwave-flash PLUGINSPAGE=http://www.macromedia.com/go/getflashplayer></EMBED></OBJECT>")
			}
			break;
		  case "tranflash":
			{
				document.write("<OBJECT classid=clsid:D27CDB6E-AE6D-11cf-96B8-444553540000 codebase=http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,0,0 WIDTH=" + w + " HEIGHT=" + h + " id=searc>")
				document.write("<PARAM NAME=movie VALUE=" + strSRC)
				document.write("><PARAM NAME=quality VALUE=high><param name=\"wmode\" value=\"transparent\" /><EMBED wmode=\"transparent\" src=" + strSRC + " WIDTH=" + w + " HEIGHT=" + h + " NAME=searc ALIGN= TYPE=application/x-shockwave-flash PLUGINSPAGE=http://www.macromedia.com/go/getflashplayer></EMBED></OBJECT>")
			}
			break;
	}
}
function printIT(Str) { 
	b = "";
	b = b + "<HTML><HEAD><TITLE>2eat.co.il - אתר המסעדות הישראלי</TITLE>";
	b = b + "<META content='text/html;charset=windows-1255' http-equiv=Content-Type><link rel='STYLESHEET' type='text/css' href='app_theme/2eat/2eat.css'>";
	b = b + "</head><Body dir='rtl' lang='he'><div align='right' dir='rtl'>"
	b = b + eval(Str+".innerHTML");
	b = b + "</div></body></html>"
	frames.Printer.document.body.innerHTML = b;
	frames.Printer.focus();
	frames.Printer.print();
}
function printITHideOther(Str,hideItems,clearTextItem) { 
	if(clearTextItem.length>0){
	var clrMe = document.getElementById(clearTextItem).innerHTML;
	document.getElementById(clearTextItem).innerHTML = "";
	}
	var hideThis = hideItems.split(" ");
	for(i = 0; i < hideThis.length; i++){
			document.getElementById(hideThis[i]).style.visibility='hidden';
			document.getElementById(hideThis[i]).style.height='0px';
		}
	b = "";
	b = b + "<HTML><HEAD><TITLE>2eat.co.il - אתר המסעדות הישראלי</TITLE>";
	b = b + "<META content='text/html;charset=windows-1255' http-equiv=Content-Type>";
	b = b + "</head><Body style='padding-top:5px;padding-bottom:5px;margin-top:0px;'><div dir='rtl' align='right'>"
	b = b + eval(Str+".innerHTML");
	b = b + "<br /><h1>2eat.co.il - אתר המסעדות הישראלי. לחפש. לטעום. להתאהב</h1>"
	b = b + "</div></body></html>"
// old - stuck ie7
	frames.Printer.document.body.innerHTML = b;
	frames.Printer.focus();
	frames.Printer.print();

// new
//var window_Print = window.open('tempprint.htm','window_Print','screenX=0,screenY=0,top=0,left=0,resizable=yes,scrollbars=yes'); 
//window_Print.ptxt.innerHTML = b;
//window_Print.close()
	for(i = 0; i < hideThis.length; i++){
		document.getElementById(hideThis[i]).style.visibility='visible';
		document.getElementById(hideThis[i]).style.height='';
	}
	if(clearTextItem.length>0){
	document.getElementById(clearTextItem).innerHTML = clrMe;
	}
}
// אוטופליי כתבות
iArt = 0;
timeout = 5000;
timerid = 0;
function ArtPlay()
{
	iArt = iArt + 1;
	ShowArticle(iArt);
	if(iArt==4){iArt=0};
}
function ArtStop()
{
	clearInterval(timerid);
	iArt=0;
}
function FirstArtPlay()
{
	timerid = setInterval("ArtPlay()",timeout);
}
function checkidnum(source, arguments){
	while (arguments.Value.length<9){
		arguments.Value="0"+arguments.Value;
	}
	idnum1=arguments.Value.substr(0,1)*1;
	idnum2=arguments.Value.substr(1,1)*2;
	idnum3=arguments.Value.substr(2,1)*1;
	idnum4=arguments.Value.substr(3,1)*2;
	idnum5=arguments.Value.substr(4,1)*1;
	idnum6=arguments.Value.substr(5,1)*2;
	idnum7=arguments.Value.substr(6,1)*1;
	idnum8=arguments.Value.substr(7,1)*2;
	idnum9=arguments.Value.substr(8,1)*1;
 
	if (idnum1>9) idnum1=(idnum1%10)+1
	if (idnum2>9) idnum2=(idnum2%10)+1
	if (idnum3>9) idnum3=(idnum3%10)+1
	if (idnum4>9) idnum4=(idnum4%10)+1
	if (idnum5>9) idnum5=(idnum5%10)+1
	if (idnum6>9) idnum6=(idnum6%10)+1
	if (idnum7>9) idnum7=(idnum7%10)+1
	if (idnum8>9) idnum8=(idnum8%10)+1
	if (idnum9>9) idnum9=(idnum9%10)+1
 
	var sumval=idnum1+idnum2+idnum3+idnum4+idnum5+idnum6+idnum7+idnum8+idnum9;
 
	sumval=sumval%10
	if (sumval>0){
		arguments.IsValid = false;
	}
	else
		arguments.IsValid = true;
}
function ScroolObj(obj)
{
    var scroolMtTo;
    scroolMtTo = document.documentElement.scrollTop;
    if (scroolMtTo == null || scroolMtTo == 0 || scroolMtTo == '')
	    scroolMtTo = document.body.scrollTop;
		//alert(scroolTo);
//    if(scroolTo<77)
//    scroolTo=77;
	//if((document.body.offsetHeight + 405 ) > scroolTo && document.body.offsetHeight > 540)
	//document.getElementById("iii").innerText = document.body.offsetHeight
	//this.status = scroolTo
	if ((document.body.offsetHeight - 500) > scroolMtTo)
	    document.getElementById(obj).style.marginTop = scroolMtTo;

	    document.getElementById(obj).setAttribute("style", "margin-top:" + scroolMtTo + "px");
}
function isOver800(){ 
   if(screen.width>1000)
	{
		document.getElementById("sbnr").style.width = 150;
	}
	else
	{
		document.getElementById("sbnr").style.visibility="hidden";
		document.getElementById("sbnr").innerHTML="";
	}
}

var my_eMapAPI;
var map0;
//var mapPoints = new Array();
function mapAddPoint(i,x,y,lbl,bdy,ttl,id,img)
{
	//mapPoints[i] = '\'' + x + '\',\'' + y + '\',\'' + lbl + '\',\'' + bdy + '\',\'' + ttl + '\',\'' + id + '\',\'' + img + '\'';
	//alert(mapPoints[i]);
}
function showMap()
{
	map0.RefreshMap()
}
function startMap(w,h,div)
{
	my_eMapAPI=new emapAPI();
	map0 = my_eMapAPI.AddElement('Map',div);
	map0.ResizeMap(w , h);
	//map0.SetLevel(3)
	map0.ShowTitles();
	//map0.Features.Add (x,y,identifier,header,body,label,icon);
	//map0.RefreshMap();
}
//function focusMap(oMap,inum,div)
//{
//    document.getElementById(div).Focus();
//    oMap.ShowDetails('G',inum);
//    //alert(document.getElementById(div).Focus());
//    //alert(document.getElementById(div).innerHTML);
//    //return false;
//}
function ShowLinkClickATableSearch(restaurantGuid, refID)
{
	document.write("<a title=\"חינם\" href=\"http://www.clickatable.co.il/ClickATable/SearchPage.aspx?RestaurantId={"+refID+"}&ref="+restaurantGuid+"&portal=2eat\" target=\"_blank\"><img src=\"images/ClickATable.gif\" alt=\"הזמן מקום\" /></a>");
}
function ShowLinkClickATableHref(restaurantGuid, refh)
{
	document.write("<a title=\"חינם\" href=\"" + refh + "\" target=\"_blank\"><img src=\"images/ClickATable.gif\" alt=\"הזמן מקום\" /></a>");
}
function ForceCheckBox(oSrc, args) { 
	var iBox = 0; // our collection index
	var bChecked = false; // the switch to flip when we get a checked box 

	var sCheckBoxID = args.Value;  //value in the textbox 

	while(document.getElementById(sCheckBoxID + iBox) && !bChecked) { 

	// only stay in the loop while we have additional boxes but no checks yet 
	if(document.getElementById(sCheckBoxID + iBox).checked) { bChecked = true; } 
	iBox++;

	}


	args.IsValid = bChecked; 


}
function showClc(tbox) {
	//document.getElementById('clca').style.visibility = 'visible';
	if (tbox.value.length > 0) {
		if (document.getElementById('clcb').style.visibility != 'visible') {
			track("חיפוש", "בחירת תאריך", "כללי");
		}
		document.getElementById('clcb').style.visibility = 'visible';
		document.getElementById('clcc').style.visibility = 'visible';
	}
	else
		showSrc(); 
	
}
function showSrc() {
	//document.getElementById('clca').style.visibility = 'hidden';
	document.getElementById('clcb').style.visibility = 'hidden';
	document.getElementById('clcc').style.visibility = 'hidden';
}

function valSrc(SrcBtn, searchText, dinersCheck, cdate, chour, cmin, srvDate, areaId, cityId, ftypeId){ //,subMe,hideMe) --Canceled - Wizard {
	// wizard visabillty
    //document.getElementById(hideMe).style.visibility = "visible"; --Canceled - Wizard
	if (document.getElementById('clcb').style.visibility == 'visible') {
//		if (document.getElementById(dinersCheck).selectedIndex == '') {
//			document.getElementById(dinersCheck).focus();
//			alert("אנא בחר כמות סועדים");
//			return false;
//		}
//		else {
			if (CheckTimeAndDate(cdate, chour, cmin, srvDate) != true) {
				alert('אנא הכנס תאריך עתידי');
				return false;
			}
		//}
		track("חיפוש", "חיפוש רוחבי", "כללי");
		SrcBtn.className = 'submitSearch_Click';
		//document.getElementById(hideMe).style.visibility = "hidden"; --Canceled - Wizard
		document.getElementById(subMe).click();
	}
	else {
		if (document.getElementById(searchText).value.length > 0) {
			track("חיפוש", "חיפוש מסעדה", "כללי");
		}
		else
			track("חיפוש", "חיפוש ללא מסעדה", "כללי");
//		// wizard -- CANCEL
//		var txt; var sel;
//		txt = "";
//		if ((sel = document.getElementById(ftypeId).selectedIndex) > 0) {
//			txt += " " + document.getElementById(ftypeId).options[sel].text;
//		}

//		if ((sel = document.getElementById(cityId).selectedIndex) > 0) {
//			txt += " ב-" + document.getElementById(cityId).options[sel].text;
//		}
//		else {
//			if ((sel = document.getElementById(areaId).selectedIndex) > 0) {
//				txt += " ב-" + document.getElementById(areaId).options[sel].text;
//			}
//		}
//		if (txt.length > 0) {
//			txt = "חיפוש מסעדות" + txt;
//		}
//		document.getElementById("wizQ").innerText = txt;
	}
	//SrcBtn.className = 'submitSearch_Click';
	// cancel if src txt
	if (document.getElementById(searchText).value != "") {
		SrcBtn.className = 'submitSearch_Click';
		//document.getElementById(hideMe).style.visibility = "hidden"; --Canceled - Wizard
		document.getElementById(subMe).click();
	}
	return true; 
   }
	 
   function CheckTimeAndDate(cdate, chour, cmin,srvDate) {

	//var dt = $get("<%=txtDate.ClientID %>")
//   	if (isDate(dt.value) == false) {

//   		dt.focus();
//   		args.IsValid = false;
//   		return;
//   	}

	var hdnServerTime = srvDate; //document.getElementById('<%=hdnServerTime.ClientID %>').value;
	var s = hdnServerTime.split('/');
	var serverDate = new Date(s[1] + "/" + s[0] + "/" + s[2]);

	var hdnTextDate = document.getElementById(cdate).value;
	var h = hdnTextDate.split('/');
	var myDate = new Date(h[1] + "/" + h[0] + "/" + h[2]);
	var hour = document.getElementById(chour).value;
	myDate.setHours(hour);
	var minutes = document.getElementById(cmin).value;
	myDate.setMinutes(minutes);
	myDate.setSeconds(0);
	if (myDate > serverDate) {//args.IsValid = true;
		return true;
	}
	else {
		//args.IsValid = false;
		return false;
	}
}


function ReplaceShowControls(hideControl, showControl) {
	document.getElementById(hideControl).style.display = 'none';
	document.getElementById(showControl).style.display = 'inline';

}

function track(page, action, restaurant) {
	if (typeof (pageTracker) != "undefined")
		pageTracker._trackEvent(page, action, restaurant);
}

function closePopBanner() {
	var popup = document.getElementById('popupBanner');
	if(popup)
		popup.style.display = 'none';
}

function BtnNewClick() {
	window.location = "http://www.2eat.co.il/%d7%94%d7%96%d7%9e%d7%a0%d7%aa_%d7%9e%d7%a7%d7%95%d7%9d.aspx#search";
}

function valSrc2(cdate, chour, cmin, srvDate) {

	if (CheckTimeAndDate(cdate, chour, cmin, srvDate) != true) {
		alert('אנא הכנס תאריך עתידי');
		return false;
	}

	track("חיפוש", "חיפוש מקום פנוי", "כללי");
	return true;
}
function Register() {
if(navigator.userAgent.toLowerCase().indexOf('chrome') > -1)
{alert ("הדפדפן לא תומך בפעולה");return;}
//      if ((typeof window.external == "object") && ((typeof window.external.AddSearchProvider == "unknown") || (typeof window.external.AddSearchProvider == "function"))) {
// if (window.external.IsSearchProviderInstalled ) {
//		var isInstalled = window.external.IsSearchProviderInstalled ("http://www.2eat.co.il"); /// multi domain prob
//			if (!isInstalled) {
window.external.AddSearchProvider("http://www.2eat.co.il/RestaurantSearchEngine.xml");
track('סרגל ימין', 'חיצוני', 'חיפוש לדפדפן-הצעה');
//				if(isInstalled){
//					track('סרגל ימין','חיצוני','חיפוש לדפדפן-הותקן');
//					}
//				}
//			}
//			else {
//				alert ("הדפדפן לא תומך בפעולה");
//			}
		}
		function getSilverlightVersion() {
		    var version = 'No Silverlight';
		    var container = null;

		    try {
		        var control = null;
		        var product = 'Silverlight';

		        if (navigator.userAgent.indexOf("Linux") != -1) {
		            product = "Silverlight (Moonlight)";
		        }

		        if (window.ActiveXObject) {
		            control = new ActiveXObject('AgControl.AgControl');
		        }
		        else {
		            if (navigator.plugins['Silverlight Plug-In']) {
		                container = document.createElement('div');
		                document.body.appendChild(container);
		                container.innerHTML = '<embed type="application/x-silverlight" src="data:," />';
		                control = container.childNodes[0];
		            }
		        }

		        if (control) {
		            if (control.isVersionSupported('5.0')) {
		                version = product + '/5.0';
		            }
		            else if (control.isVersionSupported('4.0')) {
		                version = product + '/4.0';
		            }
		            else if (control.isVersionSupported('3.0')) {
		                version = product + '/3.0';
		            }
		            else if (control.isVersionSupported('2.0')) {
		                version = product + '/2.0';
		            }
		            else if (control.isVersionSupported('1.0')) {
		                version = product + '/1.0';
		            }
		        }
		    }
		    catch (e) { }

		    if (container) {
		        document.body.removeChild(container);
		    }

		    return version;
		}
