$(function() {
	$("a.m_news_link").each(function() { 
		
		$(this).click(function(){$("a.first_news_group").removeClass("first_news_group"); $(this).addClass("first_news_group"); LoadNews($(this).text()); });

		//$(this).css({'font-size':$(this).attr("rel")+"%" }).removeAttr("rel").attr({"href":public_root_path+"/search.html?tags="+$(this).attr("title")}).attr({"title":$(this).text()})   
		});
	
	LoadNews("1");	
	
	  $("#menu_top").lavaLamp({
                fx: "backout", 
                speed: 700,
                click: function(event, menuItem) {
                  
                  return menuItem;
                }
            });
            
  $("#scroll_panel div.item").show();
      $("#rozrywka_turystyka").scrollable({
		items:'#scroll_panel',
		size:1, 
		navi:'#menu_top',
		 naviItem:'div',
		 speed:1000
	});
         
    $("#kina_scroll_content div.item").show();
      $("#kina_scroll").scrollable({
		items:'#kina_scroll_content',
		size:1, 
		navi:'#kina_navi',
		 naviItem:'div'
	});      
	
	$("#href_rozrywka").click(function(){$("#scroll_panel").removeClass("scroll_turystyka");$("#scroll_panel").addClass("scroll_rozrywka");$("#puby_kino").show(); $("#oferty_biur_podrozy").hide();}) ;
	$("#href_turystyka").click(function(){$("#scroll_panel").removeClass("scroll_rozrywka");$("#scroll_panel").addClass("scroll_turystyka"); $("#puby_kino").hide(); $("#oferty_biur_podrozy").show();}) ;
		
	$("#pub_select").jdrop();
});

function LoadNews(id)
{
$.ajax({
  url: "ajax.php?mod=news&id="+id,
  success: function(html){
  
 	if($("#m_news_content").html()!="")
 	{
  		$("#m_news_content").fadeOut(function(){$(this).html(html).fadeIn(1000);
  		//$("#m_news_img").css({ height:$("#m_news_img_id").height() });
  		
  			if (!$("#m_news_img_content").is(":visible")) {  
  				$("#m_news_img_content").css({"opacity":"0.5"}).show();
  				$("#m_news_right li:first").addClass("selected");
				RefreshNews()
  				}
				
  	
  		
  		});
 	}
 	else
 	{
  		$("#m_news_content").html(html).fadeIn(1000);
  		//$("#m_news_img").css({ height:$("#m_news_img_id").height() });
  		setTimeout("",1000);
  		if (!$("#m_news_img_content").is(":visible")) {
  			$("#m_news_img_content").css({"opacity":"0.6"}).show();
  			$("#m_news_right li:first").addClass("selected"); 
  			RefreshNews();
  		}
 	}
 	
 	
 	
	

   
  }
  
  
});

	
}

function RefreshNews()
{
	$("#m_news_right a").each(function() { 
		$(this).click(function(){
			$("#m_news_right li.selected").removeClass("selected"); 
			$(this).parent().addClass("selected");
			$("#m_news_img_content div").html($("#"+$(this).attr("name")+"_html").html());
			if($("#"+$(this).attr("name")+"_img").html()!="")
				$("#m_news_img_id").attr("src",$("#"+$(this).attr("name")+"_img").html());
			else $("#m_news_img_id").attr("src",public_root_path+"/images/m_news_bg.gif");
			
			
								});
			});
}
