﻿$(document).ready (init);
function init()
{
	$("div#mainMenu ul li").not(".selected").hover( 
		function () {
			$(this).addClass("over");
		}, 
		function () {
			$(this).removeClass("over");
		}
    );
	$("input#searchSubmit").bind("mouseover",function(){
		tempStr = this.src.split(".gif");
		newURI = tempStr[0]+"-hover.gif";
		this.src = newURI;
	});
	$("input#searchSubmit").bind("mouseout",function(){
		tempStr = this.src.split("-hover.gif");
		newURI = tempStr[0]+".gif";
		this.src = newURI;
	});
	$("input#searchSubmit").bind("click",function(){
		var el = document.getElementById("v");
		if(el.value.indexOf("...") > 0){
			$("input#v").focus()
			return false
		}
		else {
			return true
		}
	});
	$("input#v").bind("focus",function(){
		if(this.value.indexOf("...") > 0) {
			this.value = "";
		}
	});
	$("input#v").bind("blur",function(){
		if(this.value == "") {
			this.value = "חפש...";
		}
	});
	var q = location.search.toString();
	if(q.indexOf("=") > 0) {
		getResults(q)
	}
}
	
function getResults(s){
	showLoad(1)
	var tm = new Date()
	var doAjax = new tempAjax();
	//var strUrl = "http://"+location.host+"/search/"+s+"&amp;dt="+tm;
	var strUrl = "http://"+location.host+"/search/"+s;
	doAjax.doGet(strUrl,fillHtm,"text");
}
function fillHtm(resp)
{
	//alert(resp)
	document.getElementById("results").innerHTML = resp;
	showLoad(0)
}
function showLoad(a) {
	//var o=$('loading-indicator');
	if (a == 1) {
		document.getElementById('loading-indicator').style.display='block';
	}
	else {
		document.getElementById('loading-indicator').style.display='none';
	}
	//alert (document.getElementById('loading-indicator').style.toString())
}

