jQuery.fn.newsticker = function() {
    return this.each(function(){
        var strip = $(this);
        var stripWidth = 0;
        var containerWidth = strip.parent().parent().width();
        strip.find("li").each(function(i){
            stripWidth += $(this, i).outerWidth(true);
        });
        if( stripWidth > strip.width() ) {
            $('.mask').css("width", stripWidth);
        }
        //stripWidth = strip.width();alert(stripWidth);
        var totalTravel = stripWidth+containerWidth;
        var defTiming = totalTravel/0.1;
        function scrollnews(spazio, tempo){
            strip.animate({left: '-='+ spazio}, tempo, "linear", function(){
                strip.css("left", containerWidth);
                scrollnews(totalTravel, defTiming);
            });
        }
        scrollnews(totalTravel, defTiming);
        strip.hover(function(){
            $(this).stop();
        },
        function(){
            var offset = $(this).offset();
            var residualSpace = offset.left + stripWidth;
            var residualTime = residualSpace/0.1;
            scrollnews(residualSpace, residualTime);
        });
    });
};
