var overviewMap = 1;

function openFullSize(url)
	{
		//var url="http://192.168.99.107/?page=";//'[%Link_ResultsFromDmap(1)%]';
		/*if(vJHeadingCode!="")
		{
			url+="Business-Results";
		}
		else
		{
			url+="Summaries";
		}*/
		url+="&page=Business-Results";
		url+=urlParamaters.replace("&isJson=1","");
		if (vJHeadingCode!="")
		{
			url+="&headingCode="+vJHeadingCode;
		}
		
		var a = window.open(url,'_blank','toolbar=no,location=no,scrollbars=yes,status=no,resizable=no,fullscreen=yes' + ((browser == "safari")? (",width=" + screen.width + ",height=" + screen.height): ""));
	}
function pageLoad() 
{
	setFullScreen();
	$(".mapDiv").height(windowHeight - 211);
	$(".mapBussinesResults").height(windowHeight - 211 - 120);
	$(".BSRightButton").css("background-image" , "url(/Hebrew/images/Buttons/rightGreyArrow.gif)");
	//$(".rightSideDiv").hide();
	sorter_init_closeToMe();
	var mapWidth=(window.screen.width-parseInt($(".rightSideDiv").css("width")))/2;
	var mapHeight=(parseInt($(".mapDiv").css("height"))-parseInt($(".bottomStripDiv").css("height")))/2;
	$(".loadingProgresMaps").css("top",mapHeight);
	$(".loadingProgresMaps").css("left",mapWidth);

	screenWidth=window.screen.width;
	var width=0;
	var ua = navigator.userAgent;
		if (ua.indexOf("MSIE")!=-1){ width=33; } else { width = "17"; }
	//$("#bottomStripDiv").width(window.screen.width-parseInt($(".RSContent").css("width"))-width);

	$("#bottomStripDiv").css("width", 510);
	var bottomStripDivWidth=parseInt($("#bottomStripDiv").css("width"))-68;
	if (ua.indexOf("MSIE 6.0;") !== -1 && $("#bottomStripDiv").css("width") === "690px")
        {
		bottomStripDivWidth = 510 - 68;
	}
	$(".resultsButtomCont").css("width",bottomStripDivWidth);//($("#bottomStripDiv").css("width")-68)	
	
	//BRBoxWidth=parseInt(parseInt($(".resultsButtomCont").css("width"))/sumResultsInStrip);
	BRBoxWidth=220;
	$(".BRBox").width(BRBoxWidth);
	
	$(".rsbScroller").css("left",0);
	
	
	$(".BSRightButton").click(
		function()
		{
			
			if(parseInt($(".rsbScroller").css("left"))>0)
			{
				$(".rsbScroller").css("left",parseInt($(".rsbScroller").css("left"))-(BRBoxWidth*sumResultsInStrip));
				$(".BSLeftButton").css("background-image" , "url(/Hebrew/images/Buttons/leftArrow.gif)");
			}
			else
			{
				if(pageBottomNum-20==0)
				{
					var url;
					pageBottomNum-=20;
					urlParamaters="&multipage__startIndex="+pageBottomNum;
					$(".rsbScroller").css("left",(sumResults-sumResultsInStrip)*BRBoxWidth);
					searchBussinesResults("pagingBottom");
					$(".BSLeftButton").css("background-image" , "url(/Hebrew/images/Buttons/leftArrow.gif)");
				}
				else
				{
					$(".BSRightButton").css("background-image" , "url(/Hebrew/images/Buttons/rightGreyArrow.gif)");//url(///Hebrew/images/Buttons/rightArrow.gif)");
				}
			}
				
		}
	)
	
	$(".BSLeftButton").click(
		function()
		{
			if(parseInt($(".rsbScroller").css("left"))<parseInt($(".rsbScroller").css("width"))-(sumResultsInStrip*BRBoxWidth))
			{
				$(".rsbScroller").css("left",parseInt($(".rsbScroller").css("left"))+(BRBoxWidth*sumResultsInStrip));
				$(".BSRightButton").css("background-image" , "url(/Hebrew/images/Buttons/rightArrow.gif)");
			}
			else
			{
				if(pageBottomNum+20<parseInt($("#sumBottomResults")[0].innerHTML))
				{
					var url;
					pageBottomNum+=20;
					urlParamaters="&multipage__startIndex="+pageBottomNum;
					$(".rsbScroller").css("left",0);
					searchBussinesResults("pagingBottom");
					$(".BSRightButton").css("background-image" , "url(/Hebrew/images/Buttons/rightArrow.gif)");
				}
				else
				{
					$(".BSLeftButton").css("background-image" , "url(/Hebrew/images/Buttons/leftGreyArrow.gif)");//url(/Hebrew/images/Buttons/leftArrow.gif)");
				}
			}
			
		}
	)
		
if(!hasReqestedVersion)	
{
	$(".upgrade_flash").css("margin-right", (windowWidth - 350) / 2);
	$(".upgrade_flash").css("margin-top", (windowHeight - 211 - 280) / 2);
	$(".upgrade_flash").show();
}
else
	search("home");

$(".closeToMeMaps, .closeToMeBox").hover(
	function () {
		$(".closeToMeBox").show();
	} 
	,
	function () {
		$(".closeToMeBox").hide();
	}
);

$(".zoomResultsMaps, .zoomInResults_container").hover(
	function () {
		$(".zoomInResults_container").show();
	} 
	,
	function () {
		$(".zoomInResults_container").hide();
	}
);
var t;
$(".zoomOutResultsMaps, .zoomOutResults_container").hover(
	function () {
		$(".zoomOutResults_container").show();
		if ($(".zoomOutMaps .resultsListMaps").html()=="" && $(".zr_uploadImg").css("display")!="inline")
		{
			$(".zr_uploadImg").show();
			t=setTimeout("loadSorterAjaxZoom("+totalResults+")",1000);
		}
	} 
	,
	function () {
		clearTimeout(t);
		$(".zr_uploadImg").hide();
		$(".zoomOutResults_container").hide();
	}
);

$(".sorterTab").hover(
	function () {
		$(this).addClass("selected");
	} 
	,
	function () {
		$(this).removeClass("selected");

	}
);

}

/*===ATLAS===*/
/*===Map===*/
var screenWidth, map = new Map("100%","100%"),
    overviewMap = new OverviewMap(152,96,map,8), isSetIntervalDone = true,	
    k = 0.5, isRouteDescriptionVisible = false, isOverviewVisible = true,
    markedManeuver = "tr1", mapView = "Map";
	
// Creating overlay objects.
// The properties are defined within onMapFlashInitalize()
// and within dpz_map_assist.js
// Other overlay objects are created in overlayInitialization.js.
// Route is in dpz_map_assist.js.
var bottomStripOverlayObj = {overlayOpen: {}};

// Previous Right Side Overlays (Results, Junction, Traffic).
// rightSideOverlayObj = {};
// junctionOverlayObj = {};
// trafficOverlayObj = {};
        
function onMapFlashInitialize()
{
 map_assist =  dz_map_assist.getInst();//new dz_map_ass();
 map_assist.set_map(map); 
 
 mapLoad = 1;
 if (resultsLoad == 1)
 {
    map_assist.add_points_arr(arrRightResults);
 }
 addFlashButtons(new ScreenCoordinate(620,8));

 var bottomStripDivOverlay = new Overlay("bottomStripDivOverlay");
 var bottomStripDiv = document.getElementById("bottomStripDiv");
 bottomStripDivOverlay.setDomElement(bottomStripDiv);
 map.addOverlayToScreen(
  bottomStripDivOverlay, Map.ALIGN_BOTTOM_LEFT, new ScreenCoordinate(0, 117));
 bottomStripOverlayObj.overlay = bottomStripDivOverlay;
 bottomStripOverlayObj.div = bottomStripDiv;
 bottomStripOverlayObj.position = Map.ALIGN_BOTTOM_LEFT;
 bottomStripOverlayObj.screenCoordinate = new ScreenCoordinate(0, 117);
 bottomStripOverlayObj.openPosY = 117;
 bottomStripOverlayObj.closePosY = 28;

 var rightSideDivOverlay = new Overlay("rightSideDivOverlay");
 var rightSideDiv = document.getElementById("rightSideDiv");
 rightSideDivOverlay.setDomElement(rightSideDiv);
 map.addOverlayToScreen(
  rightSideDivOverlay,Map.ALIGN_TOP_RIGHT, new ScreenCoordinate(320, 0));
 overlayStates.objects.rightSideOverlayObj.overlay =
  rightSideDivOverlay;
 overlayStates.objects.rightSideOverlayObj.div=rightSideDiv;
 overlayStates.objects.rightSideOverlayObj.position =
  Map.ALIGN_TOP_RIGHT;
 overlayStates.objects.rightSideOverlayObj.screenCoordinate =
  new ScreenCoordinate(320, 0);
 overlayStates.objects.rightSideOverlayObj.openPosX = 320;
 overlayStates.objects.rightSideOverlayObj.closePosX = 17;
 overlayStates.closeTab("results");
 //$("#rightSideDiv").hide();
 if (resultsLoad == 1)
 {
  overlayStates.changeTab("results");
 }
 //$("#rightSideDiv").show();
               
 var junctionOverlayDivObj = new Overlay("junctionOverlayDivObj");
 var junctionDiv = document.getElementById("junctionDiv");
 junctionOverlayDivObj.setDomElement(junctionDiv);
 map.addOverlayToScreen(
  junctionOverlayDivObj, Map.ALIGN_TOP_RIGHT, new ScreenCoordinate(320, 0));
 overlayStates.objects.junctionOverlayObj.overlay = junctionOverlayDivObj;
 overlayStates.objects.junctionOverlayObj.div=junctionDiv;
 overlayStates.objects.junctionOverlayObj.position = Map.ALIGN_TOP_RIGHT;
 overlayStates.objects.junctionOverlayObj.screenCoordinate =
  new ScreenCoordinate(320, 0);
 overlayStates.objects.junctionOverlayObj.openPosX = 320;
 overlayStates.objects.junctionOverlayObj.closePosX = 17;
 overlayStates.closeTab("junction");
 //$("#junctionDiv").hide();

 var trafficOverlayDivObj = new Overlay("trafficOverlayDivObj");
 var trafficDiv = document.getElementById("trafficDiv");
 trafficOverlayDivObj.setDomElement(trafficDiv);
 map.addOverlayToScreen(
  trafficOverlayDivObj, Map.ALIGN_TOP_RIGHT, new ScreenCoordinate(320, 0));
 overlayStates.objects.trafficOverlayObj.overlay = trafficOverlayDivObj;
 overlayStates.objects.trafficOverlayObj.div = trafficDiv;
 overlayStates.objects.trafficOverlayObj.position = Map.ALIGN_TOP_RIGHT;
 overlayStates.objects.trafficOverlayObj.screenCoordinate =
  new ScreenCoordinate(320,0);
 overlayStates.objects.trafficOverlayObj.openPosX = 320;
 overlayStates.objects.trafficOverlayObj.closePosX = 17;
 overlayStates.closeTab("traffic");
 //$("#trafficDiv").hide();
 
 
 var OverviewMap = new Overlay("OverviewMap");
 var OverviewMapDiv = document.getElementById("OverviewMapDiv");
 OverviewMap.setDomElement(OverviewMapDiv);
 map.addOverlayToScreen(
  OverviewMap,Map.ALIGN_TOP_LEFT, new ScreenCoordinate(24, 27));
  
 map.addFlashOverlayToScreen(0, 0, "/Hebrew/flash/Map/topbar.swf");
 map.addFlashOverlayToScreen(10, 125, "/Hebrew/flash/Map/modeZoomBar.swf","mode",5);
 //map.addFlashOverlayToScreen(10, 120, "/Hebrew/flash/Map/zoombar.swf","zoom",7);

 var closeToMeBoxOverlay = new Overlay("closeToMeBoxOverlay");
 var closeToMeBoxDiv = document.getElementById("closeToMeBox")
 closeToMeBoxOverlay.setDomElement(closeToMeBoxDiv)
 map.addOverlayToScreen(closeToMeBoxOverlay,Map.ALIGN_TOP_RIGHT, new ScreenCoordinate(497,49));
 
 $(".closeToMeBox").hide();

 var zoomBoxOverlay = new Overlay("zoomBoxOverlay");
 var zoomBoxDiv = document.getElementById("zoomBox")
 zoomBoxOverlay.setDomElement(zoomBoxDiv)
 map.addOverlayToScreen(zoomBoxOverlay,Map.ALIGN_TOP_RIGHT, new ScreenCoordinate(497,77));
 $("#zoomBox").hide();

 var zoomOutBoxOverlay = new Overlay("zoomOutBoxOverlay");
 var zoomOutBoxDiv = document.getElementById("zoomOutBox")
 zoomOutBoxOverlay.setDomElement(zoomOutBoxDiv)
 map.addOverlayToScreen(zoomOutBoxOverlay,Map.ALIGN_TOP_RIGHT, new ScreenCoordinate(497,103));
 $("#zoomOutBox").hide();

 var mapWidth = windowWidth / 2;
 var mapHeight =
  (windowHeight - parseInt($(".bottomStripDiv").css("height"), 10) - 164) / 2;
 var loadingProgresMapsOverlay = new Overlay("loadingProgresMapsOverlay");
 var loadingProgresMapsDiv = document.getElementById("loadingProgresMaps");
 loadingProgresMapsOverlay.setDomElement(loadingProgresMapsDiv);
 map.addOverlayToScreen(loadingProgresMapsOverlay,Map.ALIGN_TOP_RIGHT, new ScreenCoordinate((mapWidth),(mapHeight)));
 var errAlertOverlay = new Overlay("errAlertOverlay");
 var errAlertDiv = document.getElementById("errAlert")
 errAlertOverlay.setDomElement(errAlertDiv)
 map.addOverlayToScreen(errAlertOverlay,Map.ALIGN_right_top, new ScreenCoordinate((mapWidth),(mapHeight)));
 $("#errAlert").hide(); 
 $("#bottomStripDiv").hide();
 if (resultsLoad == 1)
 {
  if ($("#rightSideDiv")[0].className == "rightSideDiv cCloseRightDiv")
  {
   $(".closeRightDiv").click();
  }
  $("#loadingProgresMaps").hide(); 
 }
  
 if (vSearchText === "")
 {
    $("#loadingProgresMaps").hide(); 
    showHideForm(overlayStates.objects.rightSideOverlayObj,'closeRightDiv');
    //$('#rm')[0].style.display!='none'?showHideForm(rmOverlayObj,'closeRightDiv'):true;
    //$(".closeRightDiv").click();
    //$(".rightSideDiv").hide();
 }
    //else
    //{
    //$(".rightSideDiv").show();
    //}

 $("#resultMap").css("margin-top", "-3px");
}
	
map.addListener(Flash.EVENT_FLASH_INITIALIZE, onMapFlashInitialize);


map.addListener(Flash.EVENT_FLASH_INITIALIZE, onMapFlashInitialize);

function loadSorterZoom(data, totalResults)
{	
	sorter_ajax_insertResults(data, ".zoomInMaps");
	if (helpers.isCountryWide($("#_where_name").val()) ||
     $("#_where_name").val() === "")
	{
		sorter_ajax_insertResults(data, ".zoomOutMaps");
	}
}
function loadSorterAjaxZoom(totalResults)
{
	var whereNameVal = $("#_where_name").val(),
	    urlSorter =
	     "/?page=Business-Ajax-Sorter-AjaxSorterCities" +
	     "&isJson=1&showMap=1&resultsNum=" + totalResults +
	     "&search_text=" + vSearchHeading +
	     "&where_name=" + whereNameVal + "&headingCode=" + vJHeadingCode +
	     "&search_type=" + getSearchType() + "&streetName=" +
	     ($("#streetName").attr("value") == "שם רחוב"?
	       "":
	       $("#streetName").attr("value")) +
	     "&cityName=" +
	     ($("#cityName").attr("value") == "שם יישוב / עיר"?
	       "":
	       $("#cityName").attr("value"));
	$.ajax(
	 {
		 url: urlSorter,
		 cache: false,
		 dataType: "json",
		 success: function (data)
		 {
 			sorter_ZoomResultsMaps(data);
		 },
		 error: function ()
		 {
 			$(".zr_uploadImg").hide();
		 }
	 });
}
function sorter_ZoomResultsMaps(data)
{
	sorter_ajax_insertResults(data.GeoFilterResults.ZoomOut, ".zoomOutMaps");
	$(".zr_uploadImg").hide();
}
function sorter_ajax_insertResults(data, append_div)
{
 $('<div></div>')
  .addClass("show4results")
  .append(
     $("<div></div>")
      .addClass("zoomInresult")
      .append(
         $("<span></span>")
         .click(
          function ()
          {
           if (typeof data.whereName !== "undefined")
           {
            searchEngineChangeWN(data.whereName);
           }
          })
         .addClass("resultTitle selected")
         .html(
          typeof data.whereName === "undefined"?
           ($("#_where_name").attr("value") || "כל הארץ"):
           data.whereName)
         .append(
          $("<span></span>")
           .addClass("noOfResult")
           .html(" (" + data.noOfResults + ")")
         )
        )
    )
  .appendTo($(append_div+" .resultsListMaps"));

 $.each(
  data.List,
  function (i, item)
  {
   $("<div></div>")
    .addClass("zoomInresult")
    .append(
      $("<span></span>")
      .click(
       function ()
       {
        searchEngineChangeWN(item.resultTitle);
       })
      .addClass("resultTitle")
      .html(item.resultTitle)
      .append(
         $("<span></span>")
         .addClass("noOfResult")
         .html(" (" + item.noOfResults + ")")
        )
      )
    .appendTo($(append_div + " .show4results"));
   if (i == 1)
   {
    return false;
   }				
  }
 )
 var index, idNum = -1;
 $.each(
  data.List,
  function(i, item)
  {
   if (i % 8 === 0)
   {
    $("<div></div>")
     .addClass("show10results")
     .appendTo($(append_div + " .resultsListMaps"));
    idNum++;
   }
   $("<div></div>")
    .addClass("zoomInresult")
    .append(
      $("<span></span>")
      .click(
       function()
       {
        searchEngineChangeWN(item.resultTitle);
       })
      .addClass("resultTitle")
      .html(item.resultTitle)
      .append(
         $("<span></span>")
         .addClass("noOfResult")
         .html(" (" + item.noOfResults + ")")
        )
      )
    .appendTo($(append_div + " .show10results:eq(" + idNum + ")"));
   index = i;
  });
		
 var numOfContDivs = Math.floor(index / 3) + 1;
 if (index > 2)
 {
  $(append_div +" .zoom_more").click(
   function()
   {
    $(append_div + " .show10results:eq(0)").show();
    $(append_div + " .show4results").hide();
    $(append_div + " .zoom_more").hide();
    if ($(append_div + " .show10results").length > 1)
    {
     $(append_div + " .zoom_prev").click(
      function()
      {
       sorter_zoomResultsChangeShowDiv(
        $(append_div + " .show10results:visible"), false);
      }).show();
     $(append_div + " .zoom_next").click(
      function()
      {
       sorter_zoomResultsChangeShowDiv(
        $(append_div + " .show10results:visible"), true);
      }).show();
    }
   }).show();
 }
}
function notify_dz_on_circle(x, y, r)
{
	urlParamaters = "&radius=" + r + "&zoneX=" + x + "&zoneY=" + y;
	search("circle");
}
function clearSorterZoom()
{
 sorter_deleteResults(
  ".whereZoomIn .resultsListMaps", ".whereZoomIn .navCont");
 sorter_deleteResults(
  ".whereZoomOut .resultsListMaps", ".whereZoomOut .navCont");
}
function sorter_deleteResults(contDivClass_results,contDivClass_more)
{
	$(contDivClass_results).html("");
	$(contDivClass_more + " .zoom_more").hide();
	$(contDivClass_more + " .zoom_prev").hide();
	$(contDivClass_more + " .zoom_next").hide();
}

function sorter_zoomResultsChangeShowDiv(showDiv, isNext)
{
	if (isNext && $(showDiv).next().length !== 0)
 {
  $(showDiv).hide();
  $(showDiv).next().show();
 }
 else
 {
  if (!isNext && $(showDiv).prev().length !== 0)
  {
   if ($(showDiv).prev().attr("class") === "show10results")
   {
    $(showDiv).hide();
    $(showDiv).prev().show(); 
   }
  }
 }
}

function sorter_zoomResultsContDiv(
 numOfContDivs, contDiv, cssName, divId)
{
 var i = 0;
 for (; i < numOfContDivs; i++)
 {
  $('<div></div>')
   .addClass(cssName)
   .css("overflow", "hidden")
   .hide()
   .appendTo($(contDiv));
 }
}

function sorter_appendZoomResults(
 resultTitle, noOfResult, url, appendToObj, cssName)
{
 $('<div></div>')
  .click(
   function()
   {
    select_city_sorter(resultTitle);
   })
   .addClass("zoomInresult")
   .append(
    $("<span></span>")
     .addClass("resultTitle")
     .addClass(cssName)
     .html(resultTitle)
     .append(
      $("<span></span>")
       .addClass("noOfResult")
       .html(" (" + noOfResult + ")")
     )
   )
   .appendTo($(appendToObj));
}
function select_city_sorter(city)
{
	$("#_where_name").attr("value", city);
	search("engine");
}
 /*===/Map===*/

 /*===Bubble===*/

/*   start */

/*   /start */

/*===/Bubble===*/

/*===/ATLAS===*/

