function TargetBlankLinks() 
{
     	if(!document.getElementsByTagName) return;
     
	var a = document.getElementsByTagName("a");
     
	for (var i=0; i<a.length; i++) 
	{
          		if(a[i].getAttribute("href") && a[i].getAttribute("rel") == "blank_window")
		{
               			a[i].target = "_blank";
		}
     }
}

function MoveTo(url)
{
	if(url)
		window.location = url;
}

function GetThisPage(url , id)
{ 
  	var xmlHttp;
  
	try
    	{    
		// Firefox, Opera 8.0+, Safari    
		xmlHttp=new XMLHttpRequest();    
	}
  	catch (e)
    	{    
		// Internet Explorer    
		try
      		{      
			xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");      
		}
    		catch (e)
      		{      
			try
        			{        
				xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");        
			}
      			catch (e)
        			{        
				alert("Your browser does not support AJAX!");        
				return false;        
			}      
		}
	}


	xmlHttp.onreadystatechange=function()
	 {
		if(xmlHttp.readyState==4)
		{
			if( id ) 
				document.getElementById(id).innerHTML=xmlHttp.responseText;
			//alert(xmlHttp.responseText);
		}
	}

	xmlHttp.open("GET",url,true);
 	xmlHttp.setRequestHeader("Cache-Control", "no-cache");
	xmlHttp.setRequestHeader( "If-Modified-Since", "Sat, 1 Jan 2000 00:00:00 GMT" );
	xmlHttp.send(null); 
}

function addBookmark(title, url) 
{
        	if (window.sidebar) 
	{ 
		// firefox
              		window.sidebar.addPanel(title, url,"");
        	} 
	else if( document.all ) 
	{ 
		//MSIE
                		window.external.AddFavorite(url, title);
        	} 
	else 
	{
               		alert("Sorry, your browser doesn't support this");
	}	
}

function PopUp(url , width , height) 
{
	page = url;
	window.open(page,'c','toolbar=0,scrollbars=1,location=0,statusbar=0,menubar=0,resizable=0,width=' + width + ',height=' + height)
}

function switchCat(id)
{
	elementIdentifiers = js_tabs;
	name = 'tab' + id;

	for(var i in elementIdentifiers)
	{
		var currentElement = document.getElementById(elementIdentifiers[i]);
		if (!currentElement) continue;

		var nextStyle = (elementIdentifiers[i] == name) ? 'selected' : '';
		currentElement.className = nextStyle;
	}

	GetThisPage( js_url + 'AjaxReq.php?t=' + id , 'n' );
}

function setToFavorites(title,url){
   if (window.sidebar)
      window.sidebar.addPanel(title, url, "");
   else if(window.opera && window.print){
      var elem = document.createElement("a");
      elem.setAttribute("href",url);
      elem.setAttribute("title",title);
      elem.setAttribute("rel","sidebar");
      elem.click();
   }else if(document.all)
      window.external.AddFavorite(url, title);
}

function AddToMyFav(id , a)
{
	if( a == 0 )
	{
		GetThisPage( js_url + 'AjaxReq.php?f=' + id , 'btnAdd' );
	}
	else if( a == 1 )
	{
		GetThisPage( js_url + 'AjaxReq.php?f=' + id , '' );
		document.getElementById('infav' + id).style.display = 'none';
	}
}


$(document).ready( function()
{
    $(".search-submit").click( function()
	{
		$("#search-form").submit();
	});

	$(".search-input").focus
	(
		function()
		{
			if( this.value == 'הכנס טקסט לחיפוש...' )
				this.value = '';
		}
	);

	$('.search-input').blur
	(
		function()
		{
			if( this.value == '' )
				this.value = 'הכנס טקסט לחיפוש...';
		}
	);
});

jQuery(document).ready(function() {
    jQuery('.box .text ul').jcarousel({
        vertical: true,
        scroll: 2
    });
});
