/**
 * Gestion du diaporama des actus
 */
var Slideactu = new Class({

	Implements: Options,
	
	// init
    initialize: function(container, options) {
		 
        this.slides = [];
          
        // maj options
        this.setOptions({
            wrapper: ".wrapper",
            slides: ".actus",
            duration: 250,
            transition: "scroll",
            start: 0,         
            auto: "on",
            autoInterval: 5000
            }, options);
        
        this.element = $(container);
	    this.slides = $(container).getElements(this.options.slides);
		
	    // init diapo
	    this.showSlide(this.options.start);	    
	   
	    this.auto();    
        
    },
       
    
    // affichage de la diapo no
    showSlide: function(no) {
	    
		this.currentSlide = no;
		
		this.fxScroll();
        
    },
    
    // scroll entre 2 diapo
    fxScroll: function() {
		
		new Fx.Scroll(this.element, {
				
				duration: this.options.duration
				
			}).toElement(this.slides[this.currentSlide]);
		
		

    },
   
    
    // diaporama auto
    auto: function() {
        this.intervalID = this.rotate.periodical(this.options.autoInterval, this);       
    },
    
    // changement de diapo pour le mode auto
    rotate: function() {
	
        if (this.currentSlide + 1 >= this.slides.length)
            next = 0;
        else
            next = this.currentSlide + 1;
        
        if (this.options.auto == "once" && next == 0)
            this.stop();            
                
        this.showSlide(next);       
    }
    
});

