// Background Flicker Function
(function(){

	/*Use Object Detection to detect IE6*/
	var  m = document.uniqueID /*IE*/
	&& document.compatMode  /*>=IE6*/
	&& !window.XMLHttpRequest /*<=IE6*/
	&& document.execCommand ;
	
	try{
		if(!!m){
			m("BackgroundImageCache", false, true) /* = IE6 only */ 
		}
		
	}catch(oh){};
})();

// Hompage Button //make some error????
function homepage () {
	window.external.AddFavorite('http://glz.co.il/','גלי צהל און-ליין');
	}
	
function GetObj(id){
return document.getElementById(id);
}

//Popup Function
var pop
function popup(url,p)//opens a winow in pop up with param: p
{
	if(pop!=null && !pop.closed) { pop.close(); pop = null; }
	pop=window.open(url,"pop",p)
	pop.focus()
}

function Show_Hide(obj){
	stat=GetObj(obj).style.display
	GetObj(obj).style.display=(stat=="block")? "none":"block"
}

function Paging(CurPage){
   // alert(CurPage);
    document.f.CurPage.value=CurPage;	
   var  pageUrl  = document.location.href;
   //alert(pageUrl);	
   pageUrl= pageUrl.replace(/[?&]PageNum=[0-9]{1,9}/g,"");
  // alert(document.f.action);
   if(pageUrl.indexOf("?")>0)	
      document.f.action=pageUrl+ "&PageNum="+CurPage;
    else
      document.f.action=pageUrl+ "?PageNum="+CurPage;	
   //alert(document.f.action);	
   document.f.submit();
   return false;
}

function search_site(frm){
	if (chk_empty(frm.q)){
		return false;
	};
	return true;
}

function chk_empty(form_obj){
	switch(form_obj.type){
		case "text" :
		case "textarea" :
		case "password" :
		case "hidden" :
		case "file" :
			return (replaceChar(form_obj.value," ","")=="")
		case "select-one" :	
			return (form_obj.options.selectedIndex==0)
		case "select-multiple" :
			return (form_obj.options.selectedIndex==-1)
	}
}

function textCounter(field, maxlimit) {
	if (field.value.length > maxlimit) // if too long...trim it!
	field.value = field.value.substring(0, maxlimit)
}

function replaceChar(str,from,to)
{
	var tmp=str.split(from);
	str="";
	for (var i=0;i<tmp.length;i++)
	{
		str+=tmp[i]+to;
	}
	str = str.substring(0,str.length-to.length);
	return  str
}

function SetSearch(obj,value)
{
    $("a[searchType="+$("#typeSearch").val()+"]*").removeClass("selectded"); 
    $("a[searchType="+value+"]*").addClass("selectded"); 
    $("#typeSearch").val(value);
}
function GetGeneralSearch(val)
{
    var serchType = $("#typeSearch").val();
    var searchQ =   $("#"+val).val();
    
    if (searchQ != "")
    {
    
        switch(serchType)
        {
            case 'limudim':
                
                document.location.href = "/LimudimSearch.aspx?q="+ escape(searchQ);
                break;
            case 'web':
                //document.charset = 'UTF-8';
                 document.location.href = "/websearch.aspx?cx=partner-pub-2962055511856263:9r2c4l-aktc&cof=FORID%3A11&ie=windows-1255&sa=חיפוש&q="+searchQ;
                 
                break;
            default : // site
                 document.location.href = "/SearchResults.aspx?q="+ escape(searchQ);
                break;
            
        }
          
    }
    return false;
}
