$(document).ready(function(){
	tabs("zakladki", 0); 
	tabs("zakladki_gora", "random"); 
	$("tr:nth-child(odd)").addClass("odd");
	
	
	var state = $.cookie('state');
		if (state == 0) {
			$("div.woj").after("<a href=\"#\" class=\"show\">Ukryj mapę</a>");
			$("a.show").click(function() {
				$(this).prev("div.woj").slideToggle("slow");
				$.cookie('state', '1');
				return false;
				}).toggle(
				function () {
					$(this).html("<a href=\"#\" class=\"show\">Pokaż mapę</a>");
				},
				function () {
					$(this).html("<a href=\"#\" class=\"show\">Ukryj mapę</a>");
			}
		);
		} else {
			$("div.woj").after("<a href=\"#\" class=\"show\">Pokaż mapę</a>").hide();
				$("a.show").click(function() {
					$(this).prev("div.woj").slideToggle("slow");
					$.cookie('state', '0');
					return false;
					}).toggle(
					function () {
						$(this).html("<a href=\"#\" class=\"show\">Ukryj mapę</a>");
					},
					function () {
						$(this).html("<a href=\"#\" class=\"show\">Pokaż mapę</a>");
					}
			);
	}
	
	
});

function tabs(id, number) {

		if (number == "random") {
			var max_number = $("#"+id+" h2").length;
			number = Math.floor(max_number*Math.random())
		}

		$("#"+id+" h2 a").removeClass("active");
		$("#"+id+" h2:eq("+number+") a").addClass("active");                            
		$("#"+id+" div").not(":eq("+number+")").hide();
		
		$("#"+id+" h2 a").click(function() {
		$("#"+id+" h2 a").removeClass("active");
		var licznik = $("#"+id+" h2 *").index(this);                                              
		
		$(this).addClass("active");
		
		$("#"+id+" div").hide();
		$("#"+id+" div").eq(licznik).show();
		
		return false;
	});
 }