//Plugin Slider
//Version 2.01
//Date : 13/09/2011

//Revision 2.00
//Version initiale

//Revision 2.01
//Ajout loading dynamique

//Pré-requis : jquery-*.js (min : 1.6)
//            : jquery-ui-*.js (min : 1.8)

/*
<div class="container">
	<div class="wrapper">
		<div class="item">
		</div>
		<div class="item">
		</div>
		<div class="item">
		</div>
	</div>
	<div class="next">
	</div>
	<div class="prev">
	</div>
</div>
$('.container').alpSlider();

Ou en dynamique pour les images

<div class="container">
	<div class="wrapper">
		<div class="item"><a href="images/diaporama/02.jpg"></a></div>
		<div class="item"><a href="images/diaporama/03.jpg"></a></div>
		<div class="item"><a href="images/diaporama/04.jpg"></a></div>
		<div class="item"><a href="images/diaporama/01.jpg"></a></div>
	</div>
</div>
$('.container').alpSlider();

Avec la taille dans le CSS
#Centre_Container.Diapo .wrapper .item
{
	display:none;
	width:950px;
	height:300px;
}

*/

(function ($) {
    $.fn.alpSlider = function (options) {
        var defaults = {
            speed: 1200,
            direction: 'horizontal',
            animation: 'barSlideOut',
            animationItemDelay: 100,
            wrapperClass: 'wrapper',
            itemClass: 'item',
            mainTitleClass: 'mainTitre',
            itemTitleClass: 'itemTitre',
            prevNextIs: false,
            prevClass: "prev",
            nextClass: "next",
            autoplay: true,
            autoplayTime: 1000,
            navigationBarIs: false,
            navigationBarClass: 'navigationBar',
            navigationBarWrapperClass: 'navigationWrapper',
            navigationBarItemClass: 'navigationbarItem',
            navigationBarItemActifClass: 'Actif',
            navigationBarItemHoverClass: 'Hover'
        };

        //Rédefinie les options du plugins
        var opts = $.extend(defaults, options);

        //Initialise les différents élèments
        var oContainer = $(this);
        var oPrev = null;
        var oNext = null;
        var oWrapper = oContainer.find('.' + opts.wrapperClass);
        var oItems = oWrapper.find('.' + opts.itemClass);
        var oNavigationBar = null;
        var oNavigationWrapper = null;
        var oNavigationBarItem = null;
        var oAnimationWrapper = null;

        //Variable liées au animations
        var animationWrapperClass = "animationWrapper";
        var animationItemClass = "animationItem";
        var animationItemNb = 15;
        var animationImgSrc = null;
        var animationList = ['simple', 'random', 'slide', 'slideIn', 'slideOut', 'fadeIn', 'fadeOut', 'barFadeIn', 'barFadeOut', 'barSlideOut', 'barSlideIn', 'squareSlide'];
        var animationTimeout = null;
        var animationTimer_Hover_Is = false;
        var animationIs = false;

        //Variable lié à la navigation
        var curPosition = 0;
        var targetPosition = 0;

        //Initialise le style du container
        oContainer.css({
            position: 'relative'
        });

        //Initialise le style du wrapper
        oWrapper.css({
            width: $(oItems.get(0)).outerWidth(),
            height: $(oItems.get(0)).outerHeight(),
            position: 'absolute',
            top: '0px',
            left: '0px',
            overflow: 'hidden'
        });


        //Initialise les items
        oItems.each(function (index) {
            $(this).css({
                position: 'absolute',
                top: '0px',
                left: '0px',
                zIndex: oItems.length - index
            });
            if ($(this).find('.' + opts.itemTitleClass).length > 0) {
                $(this).find('.' + opts.itemTitleClass).hide();
            }
        });

        //Initialise les boutons suivant et précédents
        if (opts.prevNextIs == true) {
            oPrev = oContainer.find('.' + opts.prevClass);
            oNext = oContainer.find('.' + opts.nextClass);

            //Initialise le style des boutons de navigation		
            oPrev.hide();
            oNext.hide();
            setPrevNext();

            //Lors d'un clic sur le bouton suivant
            oNext.click(function () {
                animationTimer_Hover_Is = true;
                targetPosition = curPosition + 1;
                animate();
                return false;
            });

            //Lors d'un clic sur le bouton précédent
            oPrev.click(function () {
                animationTimer_Hover_Is = true;
                targetPosition = curPosition - 1;
                animate();
                return false;
            });
        }

        //Initialise la barre de navigation
        if (opts.navigationBarIs == true) {
            oNavigationBar = oContainer.append('<div class="' + opts.navigationBarClass + '"></div>').parent().find('.' + opts.navigationBarClass);
            oNavigationBar.css({
                maxWidth: oContainer.outerWidth() + 'px'
            });
            oContainer.height(parseInt(oContainer.outerHeight()) + parseInt(oNavigationBar.outerHeight()));

            //Ajoute le wrapper
            oNavigationWrapper = oNavigationBar.append('<div class="' + opts.navigationWrapperClass + '"></div>').parent().find('.' + opts.navigationWrapperClass);

            //Ajoute les boutons de navigation
            var i = 0;
            for (i = 0; i < oItems.length; i++) {
                oNavigationWrapper.append('<a href="#" class="' + opts.navigationBarItemClass + '"></a>');
            }
            oNavigationBarItem = oNavigationWrapper.find('.' + opts.navigationBarItemClass);
            oNavigationBarItem.css({
                textDecoration: 'none'
            });
            setNavigationBarItem();

            //Lors d'un clic sur un des boutons de navigation
            oNavigationBarItem.click(function () {
                animationTimer_Hover_Is = true;
                targetPosition = $(this).index();
                animate();
                return false;
            });
        }

        //Initialise la première image
        if (oItems.size() > 0) {
            if (($(oItems.get(curPosition)).find(":first").get(0).nodeName.toUpperCase() == 'A') && ($(oItems.get(curPosition)).find(":first > *").size() == 0)) {
                var Img2 = $("<img>");
                Img2.bind("load", function () {
                    $(this).fadeIn(500, function () {
                        autoPlayStart();
                        setTitle();
                    });
                });
                Img2.hide();
                $(oItems.get(curPosition)).find(":first").replaceWith(Img2.attr('src', $(oItems.get(curPosition)).find(":first").attr('href')));
            } else {
                autoPlayStart();
                setTitle();
            }
        }

        /////////////////////////////////////////
        function autoPlayStart() {
            if (opts.autoplay) {
                autoPlayStop();
                animationTimeout = setTimeout(autoplay, opts.autoplayTime);
                if (opts.prevNextIs) {

                    oContainer.hover(
					    function () {
					        animationTimer_Hover_Is = true;
					        autoPlayStop();

					    },
						function () {
						    animationTimer_Hover_Is = false;
						    if (!animationIs) {
						        autoPlayStop();
						        animationTimeout = setTimeout(autoplay, opts.autoplayTime);
						    }
						}
					);
                }
            }
        }

        function autoPlayStop() {
            clearTimeout(animationTimeout);
        }

        function setTitle() {
            if (oContainer.find('.' + opts.mainTitleClass).length > 0) {
                if ($(oItems.get(targetPosition)).find('.' + opts.itemTitleClass).length > 0) {
                    oContainer.find('.' + opts.mainTitleClass).html($(oItems.get(targetPosition)).find('.' + opts.itemTitleClass).html());
                }
            }
        }

        function animate() {
            autoPlayStop();
            if (!animationIs) {
                if (($(oItems.get(targetPosition)).find(":first").get(0).nodeName.toUpperCase() == 'A') && ($(oItems.get(targetPosition)).find(":first > *").size() == 0)) {
                    var Img = $("<img>");
                    Img.bind("load", function () { animateBegin(); });
                    $(oItems.get(targetPosition)).find(":first").replaceWith(Img.attr('src', $(oItems.get(targetPosition)).find(":first").attr('href')));
                } else {
                    animateBegin();
                }
            }
        }

        //Permet d'animer les items suivant la position courante et une position voulue
        function animateBegin() {
            if (!animationIs) {
                if (curPosition != targetPosition) {
                    setTitle();
                    animationIs = true;
                    oContainer.css({ cursor: 'wait' });
                    if (opts.navigationBarIs) {
                        oNavigationBarItem.css({ cursor: 'wait' });
                    }

                    //Ajoute le bloc permettant les animations complexe
                    $('.' + animationWrapperClass).remove();
                    oAnimationWrapper = $('<div/>').addClass(animationWrapperClass).css({
                        width: oContainer.outerWidth(),
                        height: oWrapper.outerHeight(),
                        position: 'absolute',
                        top: '0px',
                        left: '0px',
                        zIndex: '799'
                    });
                    oWrapper.append(oAnimationWrapper);

                    if (isInArray(opts.animation, animationList) == false) {
                        opts.animation = animationList[0];
                    }

                    if (opts.animation == 'random') {
                        var Random_Index = 0;

                        while (parseInt(Random_Index) < 2) {
                            Random_Index = Math.floor(Math.random() * animationList.length);
                        }

                        eval(animationList[parseInt(Random_Index)] + '()');
                    } else {
                        eval(opts.animation + '()');
                    }


                    curPosition = targetPosition;
                    if (opts.prevNextIs == true) {
                        setPrevNext();
                    }
                    if (opts.navigationBarIs == true) {
                        setNavigationBarItem();
                    }
                }
            }
        }

        //Lorsqu'une animation est terminé
        function animateEnd() {
            animationIs = false;
            $('.' + animationWrapperClass).remove();
            oContainer.css({ cursor: 'default' });
            if (opts.navigationBarIs) {
                oNavigationBarItem.css({ cursor: 'pointer' });
            }
            if (animationTimer_Hover_Is == false) {
                autoPlayStart();
            }

        }

        //Permet de jouer en boucle le slider
        function autoplay() {
            if (oItems.length > 0) {
                if (curPosition < oItems.length - 1) {
                    targetPosition = curPosition + 1;
                }
                else {
                    targetPosition = 0;
                }
                animate();
            }

        }

        //Permet d'afficher ou non les bouton suivant et précédent
        function setPrevNext() {
            if (curPosition == oItems.length - 1) {
                oNext.hide();
                if (oItems.length - 1 > 0) {
                    oPrev.show();
                }
            }
            else if (curPosition == 0) {
                oPrev.hide();
                if (oItems.length - 1 >= 0) {
                    oNext.show();
                }
            }
            else if (curPosition > 0 && curPosition < oItems.length - 1) {
                oPrev.show();
                oNext.show();
            }
        }

        //Permet d'affecter le style du bouton de navigation actif
        function setNavigationBarItem() {
            oNavigationBarItem.removeClass(opts.navigationBarItemActifClass);
            $(oNavigationBarItem.get(curPosition)).addClass(opts.navigationBarItemActifClass);
        }

        //Permet de savoir si une valeur est dans un tableau
        function isInArray(value, tab) {
            for (x = 0; x < tab.length; x++) {
                if (tab[x] == value) { return true; }
            }
            return false;
        }

        //Fonctions permettant d'animer les items

        //Fonction simple : le premiere item laisse la place au suivant sans animations
        function simple() {
            oItems.css({ zIndex: '797' });
            $(oItems.get(targetPosition)).css({ zIndex: '798' });
            animateEnd();
        }

        //Fonction slide : décale les items les un a coté des autres
        function slide() {
            oItems.css({ zIndex: '796' });
            $(oItems.get(curPosition)).css({ zIndex: '797' });
            //Si deplacement croissant
            if (curPosition < targetPosition) {
                //Si déplacement horizontal
                if (opts.direction == "horizontal") {
                    $(oItems.get(targetPosition)).css({ left: parseInt(oWrapper.outerWidth()) + 'px', zIndex: '798' });
                    $(oItems.get(targetPosition)).animate({
                        left: "-=" + parseInt(oWrapper.outerWidth()) + "px"
                    }, opts.speed);
                    $(oItems.get(curPosition)).animate({
                        left: "-=" + parseInt(oWrapper.outerWidth()) + "px"
                    }, opts.speed, function () { animateEnd(); $(oItems.get(curPosition)).css({ left: '0px' }); });
                }
                //Si deplacement vertical
                else {
                    $(oItems.get(targetPosition)).css({ top: parseInt(oWrapper.outerHeight()) + 'px', zIndex: '798' });
                    $(oItems.get(targetPosition)).animate({
                        top: "-=" + parseInt(oWrapper.outerHeight()) + "px"
                    }, opts.speed);
                    $(oItems.get(curPosition)).animate({
                        top: "-=" + parseInt(oWrapper.outerHeight()) + "px"
                    }, opts.speed, function () { animateEnd(); $(oItems.get(curPosition)).css({ top: '0px' }); });
                }
            }
            //Si déplacement décroissant
            else {
                //Si déplacement horizontal
                if (opts.direction == "horizontal") {
                    $(oItems.get(targetPosition)).css({ left: '-' + parseInt(oWrapper.outerWidth()) + 'px', zIndex: '798' });
                    $(oItems.get(targetPosition)).animate({
                        left: "+=" + parseInt(oWrapper.outerWidth()) + "px"
                    }, opts.speed);
                    $(oItems.get(curPosition)).animate({
                        left: "+=" + parseInt(oWrapper.outerWidth()) + "px"
                    }, opts.speed, function () { animateEnd(); $(oItems.get(curPosition)).css({ left: '0px' }); });
                }
                //Si deplacement vertical
                else {
                    $(oItems.get(targetPosition)).css({ top: '-' + parseInt(oWrapper.outerHeight()) + 'px', zIndex: '798' });
                    $(oItems.get(targetPosition)).animate({
                        top: "+=" + parseInt(oWrapper.outerHeight()) + "px"
                    }, opts.speed);
                    $(oItems.get(curPosition)).animate({
                        top: "+=" + parseInt(oWrapper.outerHeight()) + "px"
                    }, opts.speed, function () { animateEnd(); $(oItems.get(curPosition)).css({ top: '0px' }); });
                }
            }
        }

        //Fonction slideIn : Le nouvel item passe devant l'ancien
        function slideIn() {
            oItems.css({ zIndex: '796' });
            $(oItems.get(curPosition)).css({ zIndex: '797' });
            //Si deplacement croissant
            if (curPosition < targetPosition) {
                //Si déplacement horizontal
                if (opts.direction == "horizontal") {
                    $(oItems.get(targetPosition)).css({ left: parseInt(oWrapper.outerWidth()) + 'px', zIndex: '798' });
                    $(oItems.get(targetPosition)).animate({
                        left: "-=" + parseInt(oWrapper.outerWidth()) + "px"
                    }, opts.speed, function () { animateEnd(); });
                }
                //Si deplacement vertical
                else {
                    $(oItems.get(targetPosition)).css({ top: parseInt(oWrapper.outerHeight()) + 'px', zIndex: '798' });
                    $(oItems.get(targetPosition)).animate({
                        top: "-=" + parseInt(oWrapper.outerHeight()) + "px"
                    }, opts.speed, function () { animateEnd(); });
                }
            }
            //Si déplacement décroissant
            else {
                //Si déplacement horizontal
                if (opts.direction == "horizontal") {
                    $(oItems.get(targetPosition)).css({ left: '-' + parseInt(oWrapper.outerWidth()) + 'px', zIndex: '798' });
                    $(oItems.get(targetPosition)).animate({
                        left: "+=" + parseInt(oWrapper.outerWidth()) + "px"
                    }, opts.speed, function () { animateEnd(); });
                }
                //Si deplacement vertical
                else {
                    $(oItems.get(targetPosition)).css({ top: '-' + parseInt(oWrapper.outerHeight()) + 'px', zIndex: '798' });
                    $(oItems.get(targetPosition)).animate({
                        top: "+=" + parseInt(oWrapper.outerHeight()) + "px"
                    }, opts.speed, function () { animateEnd(); });
                }
            }
        }

        //Fonction slideOut : L'item actuel se decale par dessus le nouveau
        function slideOut() {
            oItems.css({ zIndex: '796' });
            $(oItems.get(targetPosition)).css({ zIndex: '797' });
            $(oItems.get(curPosition)).css({ zIndex: '798' });
            //Si deplacement croissant
            if (curPosition < targetPosition) {
                //Si déplacement horizontal
                if (opts.direction == "horizontal") {
                    $(oItems.get(targetPosition)).css({ left: '0px' });
                    $(oItems.get(curPosition)).animate({
                        left: "+=" + parseInt(oWrapper.outerWidth()) + "px"
                    }, opts.speed, function () { animateEnd(); });
                }
                //Si deplacement vertical
                else {
                    $(oItems.get(targetPosition)).css({ top: '0px' });
                    $(oItems.get(curPosition)).animate({
                        top: "+=" + parseInt(oWrapper.outerHeight()) + "px"
                    }, opts.speed, function () { animateEnd(); });
                }

            }
            //Si déplacement décroissant
            else {
                //Si déplacement horizontal
                if (opts.direction == "horizontal") {
                    $(oItems.get(targetPosition)).css({ left: '0px' });
                    $(oItems.get(curPosition)).animate({
                        left: "-=" + parseInt(oWrapper.outerWidth()) + "px"
                    }, opts.speed, function () { animateEnd(); });
                }
                //Si deplacement vertical
                else {
                    $(oItems.get(targetPosition)).css({ top: '0px' });
                    $(oItems.get(curPosition)).animate({
                        top: "-=" + parseInt(oWrapper.outerHeight()) + "px"
                    }, opts.speed, function () { animateEnd(); });
                }
            }
        }

        //Fonction fadeOut : le premier item s'efface pour laisser apparaitre le nouveau
        function fadeOut() {
            oItems.css({ zIndex: '796' });
            $(oItems.get(targetPosition)).css({ zIndex: '797' }).show();
            $(oItems.get(curPosition)).css({ zIndex: '798' }).fadeOut(opts.speed, function () { animateEnd(); });
        }

        //Fonction fadeOut : le nouvel item apparait par dessus l'ancien
        function fadeIn() {
            oItems.css({ zIndex: '796' });
            $(oItems.get(curPosition)).css({ zIndex: '797' });
            $(oItems.get(targetPosition)).hide().css({ zIndex: '798' }).fadeIn(opts.speed, function () { animateEnd(); });
        }

        //L'item actuel (si c'est une image) se découpe en plusieurs barre qui apparaissent les unes après les autres
        function barFadeIn() {
            if ($(oItems.get(curPosition)).find('img').length > 0) {

                animationImgSrc = $(oItems.get(targetPosition)).find('img').first().attr('src');
                setAnimationBar();

                $('.' + animationItemClass).hide();

                oItems.css({ zIndex: '796' });
                $(oItems.get(targetPosition)).css({ zIndex: '798' }).hide();
                $(oItems.get(curPosition)).css({ zIndex: '797' }).show();

                $('.' + animationItemClass).each(function (index) {
                    if (index != animationItemNb - 1) {
                        $(this).delay(opts.animationItemDelay * (index + 1)).fadeIn(opts.speed);
                    }
                    else {
                        $(this).delay(opts.animationItemDelay * (index + 1)).fadeIn(opts.speed, function () { animateEnd(); });
                    }
                });

            }
            else {
                eval(animationList[0] + '()');
            }
        }

        //L'item actuel (si c'est une image) se découpe en plusieurs barre qui disparaissent les une après les autres
        function barFadeOut() {
            if ($(oItems.get(targetPosition)).find('img').length > 0) {

                animationImgSrc = $(oItems.get(curPosition)).find('img').first().attr('src');
                setAnimationBar();

                oItems.css({ zIndex: '796' });
                $(oItems.get(curPosition)).css({ zIndex: '797' });
                $(oItems.get(targetPosition)).css({ zIndex: '798' });
                animateEnd();

                $('.' + animationItemClass).each(function (index) {

                    if (index != animationItemNb - 1) {
                        $(this).delay(opts.animationItemDelay * (index + 1)).fadeOut(opts.speed);
                    }
                    else {
                        $(this).delay(opts.animationItemDelay * (index + 1)).fadeOut(opts.speed, function () { animateEnd(); });
                    }
                });
                animateEnd();

            }
            else {
                eval(animationList[0] + '()');
            }
        }

        //L'item actuel (si c'est une image) se découpe en plusieurs barres qui glissent vers haut et le bas les unes apres les autres
        function barSlideIn() {
            if ($(oItems.get(curPosition)).find('img').length > 0) {

                animationImgSrc = $(oItems.get(curPosition)).find('img').first().attr('src');
                setAnimationBar();

                oItems.css({ zIndex: '796' });
                $(oItems.get(targetPosition)).css({ zIndex: '798' }).show();
                $(oItems.get(curPosition)).css({ zIndex: '797' });
                $('.' + animationItemClass).each(function (index) {
                    if (index != animationItemNb - 1) {
                        if (index % 2 == 0) {
                            $(this).delay(opts.animationItemDelay * (index)).animate({
                                top: "+=" + parseInt(oAnimationWrapper.height()) + "px",
                                opacity: '0'
                            }, opts.speed, 'easeOutQuint');
                        }
                        else {
                            $(this).delay(opts.animationItemDelay * (index)).animate({
                                top: "-=" + parseInt(oAnimationWrapper.height()) + "px",
                                opacity: '0'
                            }, opts.speed, 'easeOutQuint');
                        }
                    }
                    else {
                        if (index % 2 == 0) {
                            $(this).delay(opts.animationItemDelay * (index)).animate({
                                top: "+=" + parseInt(oAnimationWrapper.height()) + "px",
                                opacity: '0'
                            }, opts.speed, 'easeOutQuint', function () { animateEnd(); });
                        }
                        else {
                            $(this).delay(opts.animationItemDelay * (index)).animate({
                                top: "-=" + parseInt(oAnimationWrapper.height()) + "px",
                                opacity: '0'
                            }, opts.speed, 'easeOutQuint', function () { animateEnd(); });
                        }
                    }
                });

            }
            else {
                eval(animationList[0] + '()');
            }
        }

        //L'item actuel (si c'est une image) se découpe en plusieurs barres qui glissent vers haut et le bas les unes apres les autres
        function barSlideOut() {
            if ($(oItems.get(targetPosition)).find('img').length > 0) {

                animationImgSrc = $(oItems.get(curPosition)).find('img').first().attr('src');
                setAnimationBar();

                oItems.css({ zIndex: '796' });
                $(oItems.get(curPosition)).css({ zIndex: '797' });
                $(oItems.get(targetPosition)).css({ zIndex: '798' });

                $('.' + animationItemClass).each(function (index) {
                    if (index != animationItemNb - 1) {
                        if (index % 2 == 0) {
                            $(this).delay(opts.animationItemDelay * (index)).animate({
                                top: "+=" + parseInt(oAnimationWrapper.height()) + "px",
                                opacity: '1'
                            }, opts.speed, 'easeOutQuint');
                        }
                        else {
                            $(this).delay(opts.animationItemDelay * (index)).animate({
                                top: "-=" + parseInt(oAnimationWrapper.height()) + "px",
                                opacity: '1'
                            }, opts.speed, 'easeOutQuint');
                        }
                    }
                    else {
                        if (index % 2 == 0) {
                            $(this).delay(opts.animationItemDelay * (index)).animate({
                                top: "+=" + parseInt(oAnimationWrapper.height()) + "px",
                                opacity: '1'
                            }, opts.speed, 'easeOutQuint', function () { animateEnd(); });
                        }
                        else {
                            $(this).delay(opts.animationItemDelay * (index)).animate({
                                top: "-=" + parseInt(oAnimationWrapper.height()) + "px",
                                opacity: '1'
                            }, opts.speed, 'easeOutQuint', function () { animateEnd(); });
                        }
                    }
                });

            }
            else {
                eval(animationList[0] + '()');
            }
        }


        //L'item actuel (si c'est une image) se découpe en plusieurs barres qui glissent vers haut et le bas les unes apres les autres
        function squareSlide() {
            if ($(oItems.get(targetPosition)).find('img').length > 0) {

                animationImgSrc = $(oItems.get(curPosition)).find('img').first().attr('src');
                setAnimationSquare();

                oItems.css({ zIndex: '796' });
                $(oItems.get(targetPosition)).css({ zIndex: '798' }).show();
                $(oItems.get(curPosition)).css({ zIndex: '797' });

                var delay = opts.animationItemDelay;
                i = 0;
                j = 0;

                $('.' + animationItemClass).each(function (index) {

                    if (index != parseInt(animationItemNb / 2) - 1) {
                        $(this).delay(delay * (j + i)).animate({
                            height: "0px",
                            width: "0px",
                            opacity: '0.2'
                        }, opts.speed, 'easeOutQuint');
                    }
                    else {
                        $(this).delay(delay * (j + i)).animate({
                            height: "0px",
                            width: "0px",
                            opacity: '0.2'
                        }, opts.speed, 'easeOutQuint', function () { animateEnd(); });
                    }

                    i++;
                    if (i == parseInt(animationItemNb / 2)) {
                        i = 0;
                        j++;
                    }

                });
            }
            else {
                eval(animationList[0] + '()');
            }
        }

        function setAnimationBar() {
            var i = 0;
            var Dimension = 0;
            var Position = 0;
            var Background = 0;

            //Si déplacement horizontal
            if (opts.direction == "horizontal") {
                for (i = 0; i < animationItemNb; i++) {
                    Position = i * parseInt(oAnimationWrapper.width() / animationItemNb);
                    Background = -(i * parseInt(oAnimationWrapper.width() / animationItemNb));
                    if (i < animationItemNb - 1) {
                        Dimension = parseInt(oAnimationWrapper.width() / animationItemNb);
                    }
                    else {
                        Dimension = oAnimationWrapper.width() - (i * (parseInt(oAnimationWrapper.width() / animationItemNb)));
                    }

                    $('<div/>').css({
                        width: Dimension,
                        height: oAnimationWrapper.height(),
                        top: '0px',
                        left: Position,
                        position: 'absolute',
                        backgroundImage: 'url(' + animationImgSrc + ')',
                        backgroundPosition: '' + Background + 'px 0px'
                    }).addClass(animationItemClass).appendTo(oAnimationWrapper);

                }
            }
            //Si deplacement vertical
            else {
                for (i = 0; i < animationItemNb; i++) {
                    Position = i * parseInt(oAnimationWrapper.height() / animationItemNb);
                    Background = -(i * parseInt(oAnimationWrapper.height() / animationItemNb));
                    if (i < animationItemNb - 1) {
                        Dimension = parseInt(oAnimationWrapper.height() / animationItemNb);
                    }
                    else {
                        Dimension = oAnimationWrapper.height() - (i * (parseInt(oAnimationWrapper.height() / animationItemNb)));
                    }
                    $('<div/>').css({ width: oAnimationWrapper.width(),
                        height: Dimension,
                        top: Position,
                        left: '0px',
                        position: 'absolute',
                        backgroundImage: 'url(' + animationImgSrc + ')',
                        backgroundPosition: '0px ' + Background + 'px'
                    }).addClass(animationItemClass).appendTo(oAnimationWrapper);
                }
            }
        }

        function setAnimationSquare() {

            var animationItemRowNb = parseInt(animationItemNb / 2);
            var animationItemColNb = parseInt(animationItemNb / 2);
            var itemHeight = parseInt(oAnimationWrapper.height() / animationItemRowNb);
            var itemWidth = parseInt(oAnimationWrapper.width() / animationItemColNb);
            var i = 0;
            var j = 0;
            var lastHeight = parseInt(oAnimationWrapper.height()) - (itemHeight * (animationItemRowNb - 1));
            var lastWidth = parseInt(oAnimationWrapper.width()) - (itemWidth * (animationItemColNb - 1));
            var curHeight = 0;
            var curWidth = 0;

            for (i = 0; i < animationItemRowNb; i++) {
                for (j = 0; j < animationItemColNb; j++) {
                    if (i < animationItemRowNb - 1) {
                        curHeight = itemHeight;
                    }
                    else {
                        curHeight = lastHeight;
                    }

                    if (j < animationItemColNb - 1) {
                        curWidth = itemWidth;
                    }
                    else {
                        curWidth = lastWidth;
                    }

                    $('<div/>').css({
                        width: curWidth,
                        height: curHeight,
                        top: parseInt((i * parseInt(oAnimationWrapper.height() / animationItemRowNb))),
                        left: parseInt((j * parseInt(oAnimationWrapper.width() / animationItemColNb))),
                        position: 'absolute',
                        backgroundImage: 'url(' + animationImgSrc + ')',
                        backgroundPosition: '' + (-(j * parseInt(oAnimationWrapper.width() / animationItemColNb))) + 'px ' + (-(i * parseInt(oAnimationWrapper.height() / animationItemRowNb))) + 'px'
                    }).addClass(animationItemClass).appendTo(oAnimationWrapper);
                }
            }

        }


    };
})(jQuery); 
