//滚动插件
(function($){
$.fn.extend({
        Scroll:function(opt,callback){
                //参数初始化
                if(!opt) var opt={};
				var _this=this;
				_this.timer = null;  
                _this.child=this.eq(0).find("ul:first");
                _this.lineH=_this.child.find("li:first").height(); //获取行高
				//每次滚动的行数，默认为一屏，即父容器高度
                _this.line=opt.line?parseInt(opt.line,10):parseInt(_this.height()/_this.lineH,10); 
                _this.speed=opt.speed?parseInt(opt.speed,10):500; //卷动速度，数值越大，速度越慢（毫秒）
                _this.timespan=opt.timespan?parseInt(opt.timespan,10):3000; //滚动的时间间隔（毫秒）
                if(_this.line==0) _this.line=1;
                _this.upHeight=0-_this.line*_this.lineH;
                //滚动函数
                _this.scrollUp=function(){
                        _this.child.animate({
                                marginTop:_this.upHeight
                        },_this.speed,function(){
                                for(i=1;i<=_this.line;i++){
                                        _this.child.find("li:first").appendTo(_this.child);
                                }
                                _this.child.css({marginTop:0});
                        });
                }
                //鼠标事件绑定
                _this.child.hover(function(){
                        clearInterval(_this.timer);
                },function(){
                        _this.timer=setInterval(function(){_this.scrollUp();},_this.timespan);
                }).mouseout();
        }        
})
})(jQuery);
/*
$(document).ready(function(){
        $("#scrollDiv").Scroll({line:1,speed:1000,timespan:2000});
});

$(document).ready(function(){
        $("#scrollDiv2").Scroll({line:1,speed:1000,timespan:3000});
});*/





