// banner immagini home page
$(document).ready(function() { 
    // start slideshow 
    $('#fotobanner').cycle({ 
        fx:      'fade', 
        timeout:  4000, 
		speed: 4000,
        before:   onBefore 
    }); 
    function onBefore(curr, next, opts) { 
        // on the first pass, addSlide is undefined (plugin hasn't yet created the fn); 
        // when we're finshed adding slides we'll null it out again 
        if (!opts.addSlide) 
            return; 

        // on Before arguments: 
        //  curr == DOM element for the slide that is currently being displayed 
        //  next == DOM element for the slide that is about to be displayed 
        //  opts == slideshow options 

        var currentImageNum = contatore; 

        if (currentImageNum == (totalSlideCount-2)) { 
            // final slide in our slide slideshow is about to be displayed 
            // so there are no more to fetch 
            opts.addSlide = null; 
            return; 
        } 

        // add our next slide 
        opts.addSlide('<img src="images/fotobanner/'+listafiles[contatore]+'" width="740" height="270" />'); 
		++contatore;
    }; 
}); 

