$(function(){
    $('.vscroll').vTicker({
        speed: 2000,
        pause: 4000,
        animation: 'fade',
        mousePause: true,
        oneNews: false});
});

(function($){
$.fn.vTicker = function(options) {
    var defaults = {
        speed: 700,
        pause: 4000,
        animation: '',
        mousePause: true,
        oneNews: false
    };

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

    moveUp = function(obj){
        obj = obj.children('div');
        first = obj.children('div:first').clone(true);

        obj.animate({top: '-=' + obj.children('div:first').height() + 'px'}, options.speed, function() {
            $(this).children('div:first').remove();
            $(this).css('top', '0px');
        });

        if(options.animation == 'fade'){
            obj.children('div:first').fadeOut(options.speed);
            obj.children('div:last').hide().fadeIn(options.speed);
        }

        first.appendTo(obj);
    };

    return this.each(function() {
        $(this).html('<div>'+$(this).html()+'</div>');
        obj = $(this);
        maxHeight = 0;
        var h=obj.attr('rel')+'px';
        obj.css({overflow: 'hidden', position: 'relative',height: h})
                .children('div').css({position: 'absolute',top:0});

        /*obj.children('div').children('div').each(function(){
            if($(this).height() > maxHeight)
            {
                maxHeight = $(this).height();
            }
        });*/

        obj.children('div').children('div').each(function(){
            //$(this).height(maxHeight);
            if(options.oneNews == true) $(this).height(obj.height());
        });

        //obj.height(maxHeight * options.showItems);

        interval = setInterval('moveUp(obj)', options.pause);

        if(options.mousePause){
            obj.bind("mouseenter",function(){
                clearInterval(interval);
            }).bind("mouseleave",function(){
                interval = setInterval('moveUp(obj)', options.pause);
            });
        }
    });
};
})(jQuery);