(function($){
    $.fn.jbanner=function(options){
        var settings={
            duration:2000
        };
        return this.each(function(){
            var $this=$(this);
            var slides=$this.children();
            var current=0;
            var started=true;
            var td;
            if(options){
                $.extend(settings,options);
            }
            var scrollIt=function(){
                if(slides!=undefined && slides.length>0){                    
                        $(slides[current]).slideUp(1000,function(){
                            $(this).remove();
                            $this.append($(this));
                            $(this).show(10);
                            $(this).fadeTo(10,1.0);
                            current++;
                            if(current>=slides.length){
                                current=0;
                            }
                            start();
                        });                   
                }
            };
            $this.hover(function(){
                if(td){
                    started=false;
                    clearTimeout(td);
                    $(slides[current]).stop();
                }
            }, function(){
                started=true;
                start();
            });
            var start=function(){
                if(started){
                    td=setTimeout(scrollIt,settings.duration);
                }
            }
            start();
        });
    };
})(jQuery);
