(function($) {

    $.fn.extend({
        verticalScroll: function(o) {
            var defaults = {
                start: 0,
                scroll: 1,
                interval: 5000,
                duration: 600,
                easing: 'swing',
                axis: 'y',
                cycle: true
            };
            var options = $.extend(defaults, o);

            return this.each(function() {

                var scrollTimed = function() {
                    if (options.cycle) {
                        $('ul:first', obj).append($('li:first', obj).clone());
                        currentLi = options.start;
                    }
                    obj.scrollTo(
                        $('li:eq('+currentLi+')', obj),
                        {
                            duration: options.duration,
                            easing: options.easing,
                            axis: options.axis,
                            onAfter: function() {
                                if (options.cycle) {
                                   $('li:first', obj).remove();
                                }
                            }
                        }
                    );

                    if (!options.cycle) {
                        currentLi++;
                        if ((currentLi+options.scroll) > $('li', obj).length) {
                            currentLi = 0;
                        }
                    }

                };

                var obj = $(this);

                var currentLi = options.start;

                //Add css rules
                if (!options.cycle)
                {
                    $('ul', obj).css('margin-bottom', $(this).outerHeight(true)+'px');
                }


                //init the timer
                var news_timer = null;

                if ($('li', obj).length > 0) {
                    obj.mouseover(function() {
                        clearInterval(news_timer);
                    }).mouseout(function() {
                        news_timer = setInterval(scrollTimed, options.interval);
                    });

                    news_timer = setInterval(scrollTimed, options.interval);
                }


            });
        }
    });

})(jQuery)