$(document).ready(function(){
$('a[rel="lytebox"]').colorbox({rel:'nofollow'});
$(".fadeover,.TnImage").fadeTo(0, 0.3);
$(".fadeover,.TnImage").hover(function(){
$(this).fadeTo("slow", 1.0);
},function(){
$(this).fadeTo("slow", 0.3);
});

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

$(".forbicina").fadeTo("slow", 0.7);
$(".forbicina").hover(function(){
$(this).fadeTo("normal", 1.0);
},function(){
$(this).fadeTo("slow", 0.7);
});

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();
});		

$(".forbice").hover(function () {
$(".forbicetta").hide("puff", {}, 1000);
});

// transition effect
style = 'easeOutQuart';
// if the mouse hover the image
$('.menu').hover(
function() {
//display heading and caption
$(this).children('.caption').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});
}
);
});

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