// Ottimizzazione caricamento immagini con fadein

     jQuery(function () {
	 jQuery('#Animazione IMG, #Immagine_Sez IMG, #Persone IMG, #MediaImg IMG, #Elenco img').hide();
});
	 var i = 0;
	 var int=0;
     jQuery(window).bind("load", function() {
     var int = setInterval("imgLoader(i)",150);
});
			
     function imgLoader() {
	 var images = jQuery('#Animazione IMG, #Immagine_Sez IMG, #Persone IMG, #MediaImg IMG, #Elenco img').length;
	 if (i >= images) {
	 clearInterval(int);
// jQuery('.loader  img').css('background', 'none');
	 }
	 jQuery('#Animazione IMG:hidden, #Immagine_Sez IMG:hidden, #Persone IMG:hidden, #MediaImg IMG:hidden, #Elenco img:hidden').eq(0).fadeIn(500)
	 i++;
	 
}
 
 
function slideSwitch() {
    var $active = $('#Animazione IMG.active');
 
    if ( $active.length == 0 ) $active = $('#Animazione IMG:last');
 
    // use this to pull the images in the order they appear in the markup
    var $next =  $active.next().length ? $active.next()
        : $('#Animazione IMG:first');
 
   // uncomment the 3 lines below to pull the images in random order
    
  //  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}, 1500, function() {
            $active.removeClass('active last-active');
        });
}
 
$(function() {
    setInterval( "slideSwitch()", 6500 );
});


// Menu a tendina
//$(function(){

	//$(".btn-slide").mouseover(function(){
		//$("#Tendina").slideToggle("slow");
		//$(this).toggleClass("active"); return false;
	//});
	
	 
//});

