/**
 * @author Sébastien Riguet <sebastien.riguet@zebnet.fr>
 */


(function($) { //create closure
    $.fn.zflash = function(options) {
        
        var flashNum = jQuery(jQuery(this).children()[0]).children().length;
        
        if (flashNum > 0) {
            var flash = jQuery(jQuery(this).children()[0]);
            
            var isAnimating = false;
            var currentI = -1
            var timerLength = 8000;
            slideShowTimer = setInterval("slideTo()", timerLength);
            
            slideTo = function () {
                flash.animate({"left": "-=550px"}, timerLength / 4);
                //alert(flash.position().left)
                if (flash.position().left <= (-1 * 550 * flashNum) ) {
                    flash.stop(true)
                    flash.css("left", "550px");
                    flash.animate({"left": "-=550px"}, timerLength / 4);
                }
            }
        }
    }
})(jQuery);
