	var fftools=window.fftools={
		extend:function(destination, source){//扩展对象
			for(var property in source){
				destination[property] = source[property]
			}
			return destination;
		}
	};
	
	var $=window.$=function(e){
		var elem=typeof(e)=='string'?document.getElementById(e):e;
		if(elem){ fftools.extend(elem,Scroll);}
		return elem;
	};
	
	var Scroll={
		//滚动类的一些属性
		interval:10,//滚动速率
		speed:2,//滚动速度,必须能被滚动高度（h）整除
		time:5,//滚动时间间隔
		stopScroll:false,//是否停止滚动
		init:function(w,h){//参数分别代表滚动文本的宽度，高度
			Scroll.content=this;
			if(this){//如果对象存在，继续执行
				//给滚动元素设定基本样式
				with(this){
					style.width=w+"px";
					style.height=h+"px";
					style.overflow='hidden';
					style.whiteSpace='nowrap';
				}
				//定义程序辅助变量
				scrollHeight=h;//每次滚动一个高度
				stopTime=0;
				currentTop=0;
				this.appendChild(this.cloneNode(true));//复制滚动内容，防止内容过短，不利于滚动循环
				this.scrollTop=0;
				setInterval("Scroll.operate()",Scroll.interval);
			}
		},
		operate:function(){
			Scroll.content.onmouseover=function(){ Scroll.stopScroll=true;}
			Scroll.content.onmouseout=function(){ Scroll.stopScroll=false;}
			if(Scroll.stopScroll==true) return false;
			currentTop+=Scroll.speed;
			if(currentTop > scrollHeight){
				stopTime+=Scroll.speed;
				currentTop-=Scroll.speed;
				if(stopTime==Scroll.time*scrollHeight){
					currentTop=0;
					stopTime=0;
				}
			}
			else{
				preTop=Scroll.content.scrollTop;
				Scroll.content.scrollTop+=Scroll.speed;
				if(preTop==Scroll.content.scrollTop){//如果执行完一次完整的循环后
					Scroll.content.scrollTop=0;
					Scroll.content.scrollTop+=Scroll.speed;
				}
			}
		}
	};


