$(document).ready(function(){	
	
	/* tworzy zakladki z naglowkow o klasie "tab_container_head" */ 
	$(".describe_box").each(function() {
		var $that = $(this);
		var $navi = '<ul class="describe_tabs">';
		$that.find(".slider_container").css({"height": "168px"});
		$that.find(".slider_gallery").css({"position": "absolute"});
		var $i = 0; // licznik dla nadania klas
		$that.find(".tab_container").each(function() {
			$navi+=('<li class="item'+$i+'"><a href="#"><span>'+$(this).find(".tab_container_head").hide().html()+'</span></a></li>'); // pobiera etykiety zakladek z naglowkow
			$(this).addClass("item"+$i).hide(); //ukrywa wszytskie zakladki
			$i++;
		});
		$navi+='</ul>';
		$that.children().children().prepend($navi);
		$that.find(".tab_container:first").show(); //wy�wietla zawarto�� pierwszej zak�adki
		$that.find(".describe_tabs").children("li:first").children("a").addClass("active"); //nadaje aktywn� klas� na pierwsz� zak�adk�
		
	});
	
	/* klikni�cie w etykiet� zak�adki */
	$(".describe_tabs li a").live("click", function() {
		var $thatClass = $(this).closest("li").attr("class");
		$(this).closest(".describe_box").find(".tab_container").hide(); //ukrywa wszystkie zakladki
		$(this).closest(".describe_box").find("div."+$thatClass).fadeIn(); // pokazuje zakladke o wybranej klasie
		$(this).closest("ul").find("a").removeClass("active");
		$(this).closest("ul").find("li."+$thatClass).children("a").addClass("active");
		return false;
	});
	
});
