$(document).ready(function(){
s = new sliders(".sliders");
});

var sliders = function(id){
    var self = this;
    this.div = $(id);
    this.sliders = this.div.find(".bandeMove");
    this.largeurCache = this.div.width();
    this.largeur=0;
    this.div.find('a').each(function(){
        self.largeur+=$(this).width();
        self.largeur+=parseInt($(this).css("padding-left"));
        self.largeur+=parseInt($(this).css("padding-right"));
        self.largeur+=parseInt($(this).css("margin-left"));
        self.largeur+=parseInt($(this).css("margin-right"));
    });    
    this.prec = this.div.find(".up");
    this.suiv = this.div.find(".down");
    this.saut = this.largeurCache/2;
    this.nbEtapes = Math.ceil(this.largeur/this.saut - this.largeurCache/this.saut);
    this.courant=0;
    
    var mouseovered = false;
    var mouseoveredd = false;
    
    this.suiv.mouseover(function(){
        mouseovered = true;
        });
    this.suiv.mouseleave(function(){
        mouseovered = false;
        clearInterval(suiv);
        });
    
    this.prec.mouseover(function(){
        mouseoveredd = true;
        });
    this.prec.mouseleave(function(){
        mouseoveredd = false;
        clearInterval(prec);
        });
    
    this.suiv.mouseover(function(){
        suiv = setInterval(function(){
        if(self.courant<=1 && mouseovered == true){
        self.courant++;
        self.sliders.animate({
            "top":-165*self.courant
            },800);
        }
        }, 800);
        
    });
    
    this.prec.mouseover(function(){
        
        prec = setInterval(function() {
        if(self.courant>0 && mouseoveredd == true){
        self.courant--;
        self.sliders.animate({
            "top":-165*self.courant
            }, 800);
        }
        }, 800);
    });
}

