$(document).ready(function(){
	
	/* Cambiare l'effetto da utilizzare */
	$.easing.def = "easeOutQuad";

	/*
	if ($('#menuContainer')) {
		$('ul.mainMenu li.title a').click(function(e){
		
			// Finding the drop down list that corresponds to the current section: 
			var subMenu = $(this).parent().next();
			
			$('.sub-menu').not(subMenu).slideUp('slow');
			subMenu.stop(false,true).slideToggle('slow');
			
			// Prevenire l'evento predefinito (che sarebbe di seguire il collegamento) 
			e.preventDefault();
		})
	}*/
	
	if ($('#tabs')) {
		$.featureList(
			$("#tabs li a"),
			$("#output li"), {
				start_item	:	0,
				transition_interval : 3000
			}
		);
	}
	
	$(".swfPopup").fancybox({
		'padding'	: 10,
		'autoScale'	: false,
		'transitionIn'	: 'fade',
		'speedIn' 	: 500,
		'transitionOut'	: 'none',
		'width':'540',
		'height':'440'
	});
	
	$(".popup").fancybox({
		'padding'	: 10,
		'autoScale'	: false,
		'transitionIn'	: 'fade',
		'speedIn' 	: 500,
		'transitionOut'	: 'none'
	});
	
	if ($(".bannerContainer").length)  {
		$(function() { /*banner con fade*/
	    		slideSwitch();
	    		setInterval( "slideSwitch()", 3000 );
		});
	}
	
});


function slideSwitch() {

	    var $active = $('.bannerContainer img.active');
	
	    if ( $active.length == 0 ) $active = $('.bannerContainer img:last');
	
	    // use this to pull the images in the order they appear in the markup
	    var $next =  $active.next().length ? $active.next()
	        : $('.bannerContainer 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}, 500, function() {
	            $active.removeClass('active last-active');
	        });
}

