// Script per slideshow casuale di immagini con jQuery

function slideShow() {
    var $active = $('#SlideContainer img.active');

    if ( $active.length == 0 ) $active = $('#SlideContainer img:last-active');

	// 3 linee che servono per far comparire le immagini in ordine casuale
	var $sibs  = $active.siblings();
    var rndNum = Math.floor(Math.random() * $sibs.length );
    var $next  = $( $sibs[ rndNum ] );

    $active.addClass('last-active');

    $next.css({opacity: 0.0})
        .addClass('active')
        .animate({opacity: 1.0}, 1000, function() {
            $active.removeClass('active last-active');
        });
}


$(function() {
    var navButtons = '#block1, #block2, #block3, #block4, #block5';
    $(navButtons).hover(function() {
        $(this).stop().animate({'top':'-110px'});
        }, function () {
        $(this).stop().animate({'top':'0px'})
        });
});

$(function() {
    setInterval( "slideShow()", 4000 );
});

