(function($){
    $.fn.shinSlide = function(){
        
        //PROPERTY
        var moving = false;
        var el = this;
        
        //PUBLIC METHODS
        this.nextSlide = function() {
            el.each(function(){
                var nextSlide = this.sudoSlider.getValue('currentSlide') +1 > this.sudoSlider.getValue('totalSlides') ? 1 : this.sudoSlider.getValue('currentSlide') +1;
                _changeSlide(nextSlide, this);
            })
        };
        
        this.prevSlide = function() {
            el.each(function(){
                var prevSlide = this.sudoSlider.getValue('currentSlide') -1 <= 0 ? this.sudoSlider.getValue('totalSlides') : this.sudoSlider.getValue('currentSlide') -1;
                _changeSlide(prevSlide, this);
            })
        }
        
        this.changeSlide = function(nbSlide) {
            el.each(function(){
                _changeSlide(nbSlide, this);
            })
        }
        
        
        //PRIVATE METHODS
        function _changeSlide(nbSlide, elC) {
            if(moving)
                return;
            $(".a-slider-active").removeClass("a-slider-active").addClass("a-slider-normal");
            $("#slide-" + nbSlide).removeClass("a-slider-normal").addClass("a-slider-active");
            elC.sudoSlider.goToSlide(nbSlide);
        }
        
        
        //INIT
        return this.each(function(){
            this.sudoSlider = $(this).sudoSlider({
                beforeAniFunc: function(t){
                    moving = true;
                },
                afterAniFunc: function(t){
                    moving = false;
                },
                prevNext : false,
                autowidth : false,
                autoheight : false
            });
        });
        
        
    };
})(jQuery)


