$(document).ready(function() {
		function findValue(li) {
		if( li == null ) return alert("אין תוצאות!");
	
		// if coming from an AJAX call, let's use the CityId as the value
		if( !!li.extra ) var sValue = li.extra[0];
	
		// otherwise, let's just display the value in the text box
		else var sValue = li.selectValue;
	
		//alert("The value you selected was: " + sValue);
		$("form[action='/חיפוש/']").submit();
	  }
	
	  function selectItem(li) {
			findValue(li);
	  }
	
	  function formatItem(row) {
			//return row[0] + " (id: " + row[1] + ")";
			return row[0];
	  }
	
	  function lookupAjax(){
		var oSuggest = $("#CityAjax")[0].autocompleter;
		oSuggest.findValue();
		return false;
	  }
	
	  function lookupLocal(){
			var oSuggest = $("#CityLocal")[0].autocompleter;
	
			oSuggest.findValue();
	
			return false;
	  }
	
	$("#CityAjax").autocomplete(
      "/includes/autocomplete.php",
      {
  			delay:10,
  			minChars:3,
  			matchSubset:1,
  			matchContains:1,
  			cacheLength:10,
  			onItemSelect:selectItem,
  			onFindValue:findValue,
  			formatItem:formatItem,
  			autoFill:false
  		}
    );
	
(function($){$.fn.Hover = function(event,image){ return this.each(function(){$(this).bind(event, function(){$(this).parent('div').css("background-image","url('"+image+"')");});	});};})(jQuery);

		$("#darom").Hover('mouseover','images/map_darom.png')
		$("#tzafon").Hover('mouseover','images/map_tzafon.png');
		$("#merkaz").Hover('mouseover','images/map_merkaz.png');
		$("#galil").Hover('mouseover','images/map_galil.png');
		$("#jerusalem").Hover('mouseover','images/map_jerusalem.png');
		$(".area_map div div").live('mouseout', function(){
		$(this).parent('div').css("background-image", "");
		});

		$(".area_map div div").live('click', function(){
				var root = $(".PRTOP").children('a').attr('href');
				window.location = $(this).children('a').attr('href') ;
				
		});

$(function(){
    $("ul#marquee").liScroll({travelocity: 0.05});
});



	var RowsPerCol = 5 ;
	$(".MENU ul li").live('mouseover',function(){
	var rows = $(this).children("ul").children("li").children("div").children("span").length;
	var cols = rows / RowsPerCol;
		cols = Math.ceil(cols);
	var ColWidth = cols*115;
	$(this).children("ul").css('width',ColWidth);
	});

});
