$(document).ready(function() {
	$("#topnav li").each(function() { //For each list item...
		var linkText = $(this).find("a").html(); //Find the text inside of the a tag
		$(this).find("span").show().html(linkText); //Add the text in the span tag
	}); 
	
	$("#topnav li").hover(function() {	//On hover...
		$(this).find("span").stop().animate({ 
			marginTop: "-18" //Find the span tag and move it up 50 pixels
		}, 150);
	} , function() { //On hover out...
		$(this).find("span").stop().animate({
			marginTop: "0" //Move the span back to its original state (0px)
		}, 300);
	});

});

$(function(){  
    $("a1").click(function(){  
            $("dd").slideToggle('slow');  
        });  
    $("a#link_pliki1").click(function(){  
            $("#pliki").slideToggle('normal');  
        });  
    $("a#link_zapytanie").click(function(){  
            $("#zapytanie").slideToggle('normal');   
        });  
    $("a#link_komentarze").click(function(){  
            $("#komentarze").slideToggle('normal');     
        });  
    $("a#link_oceny").click(function(){  
            $("#oceny").slideToggle('normal');  
        });  
});  

$(document).ready(function(){
		var Idx = 1;
		var IntervalKey;
		var ChangeImage = function(){
			//If the image still animating, stop it and start the new one
			$("#MainImage").ImageStop(true,true);
			$("#MainImage").ImageSwitch({NewImage: $(".TnImage").eq(Idx).attr("src").replace("tn-","med-")});		
	        $("#DisplayDiv").slideDown('slow');  			
			//Mark which thumbnail is displaying
			$(".TnImage").css("opacity","0.7");
			$(".TnImage").eq(Idx).css("opacity","1");
			
			//Set the next image will be display
			Idx++;
			if(Idx>7){
				Idx = 0;
			}
			//Start preload the next image
			$.ImagePreload($(".TnImage").eq(Idx).attr("src").replace("tn-","med-"));			
		};
		
		//When a thumbnail's clicked
		$(".TnImage").click(function(){
			Idx = $(".TnImage").index(this);
			ChangeImage();
		});		
		
		var StartSlideShow = function(){
			IntervalKey = setInterval(ChangeImage,2500);
			$("#SlideShow").text("Zatrzymaj pokaz");
			$("#SlideShow").unbind("click");
			$("#SlideShow").bind("click",StopSlideShow);					
		};
		
		var StopSlideShow = function(){
			clearInterval(IntervalKey);
			$("#SlideShow").text("Uruchom Pokaz");
			$("#SlideShow").unbind("click");
			$("#SlideShow").bind("click",StartSlideShow);	
			
		};

		$("#SlideShow").bind("click",StartSlideShow);
});
