﻿(function($){

    $.fn.Scroll = function(options){
		var opts = $.extend({},$.fn.Scroll.defaults, options);
		
		return this.each(function(){
		    var _this = $(this).eq(0).find("ul:first");
		    //var _this=$marquee).eq(0).find("ul:first");
		   // var _this=$marquee.get(0);
            var lineH=_this.find("li:first").height();
            var line=opts.line?parseInt(opts.line,10):parseInt(_this.height()/lineH,10);
            var speed=opts.speed?parseInt(opts.speed,10):500; 
            var timer=opts.timer?parseInt(opts.timer,10):3000; 
            if(line==0)
            { 
                line=1;
            }
            var upHeight=0-line*lineH; 
           function scrollUp(){
                _this.animate({marginTop:upHeight},speed,function(){
                    for(i=1;i<=line;i++)
                    {
                        _this.find("li:first").appendTo(_this);
                    }
                    _this.css({marginTop:0});
                 });
            };
		
			var moveId = setInterval(scrollUp,timer);
		
			_this.hover(
				function(){
					clearInterval(moveId);
				},
				function(){
					clearInterval(moveId);
					moveId = setInterval(scrollUp, timer);
				}
			);
			
		});
	};
	$.fn.Scroll.defaults = {
		timer:3000,
		speed: 500,
		line:1
		
	};
	
	$.fn.Scroll.setDefaults = function(settings) {
		$.extend( $.fn.Scroll.defaults, settings );
	};
	
  
})(jQuery);


