﻿var carrousel = { nbSlide: 0, nbCurrent: 1, elemCurrent: null, elem: null, timer: null, init: function (elem) {
    this.nbSlide = elem.find('#InterSlideshow li').length; $('.remove').remove(); elem.find('#InterSlideshow li, .title, .link, .contentSlide').hide(); for (var i = 1; i <= this.nbSlide; i++) { elem.find('#Numbers').append('<li><a href="" onclick="return false;">' + i + '</a></li>'); }
    elem.find('#Numbers li').click(function () { carrousel.gotoSlide($(this).text()); }); this.elem = elem; elem.find('#InterSlideshow li:first, .title:first, .link:first, .contentSlide:first').show(); this.elemCurrent = elem.find('#InterSlideshow li:first'); this.elem.find('#Numbers li:first').addClass('active'); carrousel.play(); elem.mouseover(carrousel.stop); elem.mouseout(carrousel.play);
}, gotoSlide: function (num) {
    if (num == this.nbCurrent) { return false; }
    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); this.elem.find('#Numbers li').removeClass('active'); this.elem.find('#Numbers li:eq(' + (num - 1) + ')').addClass('active'); this.elem.find('.title').hide(); this.elem.find('#title' + (num - 1)).hide(); this.elem.find('#title' + num).fadeIn(); this.elem.find('.link').hide(); this.elem.find('#link' + (num - 1)).hide(); this.elem.find('#link' + num).fadeIn(); this.elem.find('.contentSlide').hide(); this.elem.find('#contentSlide' + (num - 1)).hide(); this.elem.find('#contentSlide' + num).fadeIn(); 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);
}, stop: function () { window.clearInterval(carrousel.timer); }, play: function () { window.clearInterval(carrousel.timer); carrousel.timer = window.setInterval('carrousel.next()', 7000); }
}
$(document).ready(function () { carrousel.init($('#Slideshow')); });
