// JavaScript Document
// Script per slideshow casuale di immagini con jQuery

//HO DOVUTO MODIFICARE TUTTE LE FUNZIONI $() di jquery perchè fanno conflitto con prototype.js ed ho aggiunto una riga a jquery.js



function slideShow() {
    var $active = $('#slideshow div.active'); //$('#slideshow img.active');
	
    if ( $active.length == 0 ) $active = $('#slideshow div:last');
	
	var $next =  $active.next().length ? $active.next()
        : $('#slideshow div:first');
	
	
	// 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() {
    setInterval( "slideShow()", 4000 );
});
*/
/*
function mycarousel_initCallback(carousel)
{
    // Disable autoscrolling if the user clicks the prev or next button.
    carousel.buttonNext.bind('click', function() {
        carousel.startAuto(0);
    });
 
    carousel.buttonPrev.bind('click', function() {
        carousel.startAuto(0);
    });
 
    // Pause autoscrolling if the user moves with the cursor over the clip.
    carousel.clip.hover(function() {
        carousel.stopAuto();
    }, function() {
        carousel.startAuto();
    });
};
 */
jQuery(document).ready(function() {
   /* jQuery('#mycarousel').jcarousel({
        auto: 1,
        wrap: 'circular',
        scroll: 1,
        initCallback: mycarousel_initCallback
    });
	*/
	setInterval( "slideShow()", 3000 );
	
});
