$(document).ready(function(){
$(".fadeover,.TnImage").fadeTo(0, 0.3);
$(".fadeover,.TnImage").hover(function(){
$(this).fadeTo("slow", 1.0);
},function(){
$(this).fadeTo("slow", 0.3);
});

$(".mini").click(function(){
$("#contenutisotto,#contenutisopra,#quadroweb,#contenutihome").hide();
});

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-")});		
//Set the next image will be display
Idx++;
if(Idx>3){
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();
});

$(".scala").hover(function () {
$(".scaletta").hide("puff", {}, 1000);
});

// transition effect
		style = 'easeOutQuart';

		// if the mouse hover the image
		$('.menu,.web-menu').hover(
			function() {
				//display heading and caption
				$(this).children('.caption').stop(false,true).animate({bottom:0},{duration:200, easing: style});
				$(this).children('.sovra').stop(false,true).animate({bottom:0},{duration:200, easing: style});
			},

			function() {
				//hide heading and caption
				$(this).children('.caption').stop(false,true).animate({bottom:-25},{duration:200, easing: style});
				$(this).children('.sovra').stop(false,true).animate({bottom:-140},{duration:200, easing: style});
			}
		);

});

$(window).load(function () {
$("#contenutisotto,#quadroweb").fadeIn(1500);
$("#contenutisopra").fadeIn(7000);
});