(function($) {
    $.fn.extend({
        autoScroll: function(options) {
            var defaults = {
                scrollTime: 1000,
                stillTime: 1000
            };

            var opts = $.extend(defaults, options);

            opts.stillTime = opts.stillTime + opts.scrollTime;


            this.each(function() {
                var obj = $(this);

                obj.data("liScrolling", false);

				if (obj.children("li").length <= 1) return this;

                obj.everyTime(opts.stillTime, "still",
                function() {
                    $.liScroll.scroll(obj, opts.scrollTime)
                });

                return this;

            });
        }
    });

    $.extend({
        liScroll: {
            scroll: function(obj, scrollTime) {
                var time = scrollTime ? scrollTime: 1000;
                var liCurrent = obj.children("li:visible");
                var liNext = liCurrent.next();

                obj.data("liScrolling", true);

                if (! (liNext.html())) {
                    liNext = obj.children("li:first");
                }

                liCurrent.animate({
                    "top": -liCurrent.height()
                },
                time,
                function() {
                    $(this).hide();
                    obj.data("liScrolling", false);
                });


                liNext.css("top", liCurrent.height()).show().animate({
                    "top": 0
                },
                time);
            }
        }
    });
})(jQuery);