(function ($){
  $(document).ready(function (){
	id = -1;
        hover = false;
	timeout = '';
	news = $('#latest_news');
	//setTimeout(get_next_item, 7500);
	get_next_item();
	news.hover(
		function () { 
			hover = true; 
		}, function () { 
			hover = false; }
	);
	
	function get_next_item()
	{
		if (hover)
		{
			setTimeout(get_next_item, 7500);
			return;
		}
		$.post('/hidden/get_next_news.php',{cur_id:id}, function(data){
	    	if (!data.error)
	    	{	    		
	    		//id = (++id > data.count)?1:id;
	    		id = data.id;
	    		news.fadeOut(1750, function () {	    			
	    			news.html(data.text);	    			
	    			news.fadeIn(1750, function () {
	    				setTimeout(get_next_item, 7500);
	    				});
	    		});
	    		
	    	}
	    },'json');
	}
  });
  
  $(document).ready(function (){
	  $('#search').click(function (){
		  if (this.value == 'Search Term')
		  {
			  this.value = '';
		  }
	  });
  });
  
})(jQuery);
