var diapo2 = {
    nbSlide : 0,
    nbCurrent : 1,
    elemCurrent : null,
    elem : null,
    timer : null,
    
    // fonction d'initialisation
    init : function(elem){
        
        //calcul du nb de slide
        this.nbSlide = elem.find(".slide2").length;
        this.elem=elem;
        
        //initialisation du diapo
        elem.find(".slide2").hide();
        elem.find(".slide2:first").show();
        this.elemCurrent = elem.find(".slide2:first");
        
        //initialisation du timer
        this.timer = window.setInterval("diapo2.next()",5000);
    },
    
    //fonction de dˇroulement automatique du diapo
    next : function(){
        this.nbCurrent++;
        if(this.nbCurrent>this.nbSlide){this.nbCurrent=1}
        this.gotoSlide(this.nbCurrent);
    },
    
    //fonction d'affichage des slides
    gotoSlide : function(num){
        this.elemCurrent.fadeOut();
        this.elem.find("#b"+num).fadeIn();
        this.nbCurrent = num;
        this.elemCurrent = this.elem.find("#b"+num);
        
    }
    
    
}

$(function(){
    diapo2.init($("#diaporama2"));
});
