var carrousel2 = { nbSlide: 0, nbCurrent: 1, elemCurrent: null, elem: null, timer: null, init: function (elem) {
    this.nbSlide = elem.find(".slide").length; ; for (var i = 1; i <= this.nbSlide; i++) { $(".num").append("<span>" + i + "</span>"); }
$(".num span").click(function(){carrousel2.gotoSlide($(this).text());})
this.elem = elem; elem.find(".slide").hide(); elem.find(".slide:first").show(); this.elemCurrent = elem.find(".slide:first"); $(".num span:first").addClass("active2"); carrousel2.play(); elem.mouseover(carrousel2.stop); elem.mouseout(carrousel2.play);
},

gotoSlide: function (num) {
    if (num == this.nbCurrent) { return false; }

    /* Animation fadeIn/fadeOut
    this.elemCurrent.fadeOut();
    this.elem.find('#slide' + num).fadeIn();
    */
    /* Animation Slide */
    var sens = 1;
    if (num < this.nbCurrent) { sens = -1 }
    var cssDeb = { 'left': sens * this.elem.width() };
    var cssFin = { 'left': -sens * this.elem.width() };
    this.elem.find('#slide' + num).show().css(cssDeb);

    this.elem.find('#slide' + num).animate({
        'top': 0,
        'left': 0
    }, 500);

    this.elemCurrent.animate(cssFin, 500);

    /*****************************/
    $('.num span').removeClass('active2');
    $('.num span:eq(' + (num - 1) + ')').addClass('active2');
    this.nbCurrent = num;
    this.elemCurrent = this.elem.find('#slide' + num);

}

 /*gotoSlide: function (num) {
    if (num == this.nbCurrent) { return false; }
    this.elemCurrent.fadeOut(); this.elem.find("#slide" + num).show(); this.elem.find("#slide" + num + " .visu").hide().fadeIn(); var titleHeight = this.elemCurrent.find(".title").height(); this.elemCurrent.find(".title").animate({ "bottom": -titleHeight }, 500); this.elem.find("#slide" + num + " .title").css("bottom", -titleHeight).animate({ "bottom": 0 }, 500); this.elem.find(".num span").removeClass("active"); this.elem.find(".num span:eq(" + (num - 1) + ")").addClass("active"); this.nbCurrent = num; this.elemCurrent = this.elem.find("#slide" + num);
}*/, next: function () {
    var num = this.nbCurrent + 1; if (num > this.nbSlide) { num = 1; }
this.gotoSlide(num);},prev:function(){var num=this.nbCurrent-1;if(num<1){num=this.nbSlide;}
this.gotoSlide(num);},stop:function(){window.clearInterval(carrousel2.timer);},play:function(){window.clearInterval(carrousel2.timer);carrousel2.timer=window.setInterval("carrousel2.next()",5000);}}
$(function () { carrousel2.init($("#Carrousel")); });
