$=function(obj){return document.getElementById(obj);}


// 滚动函数
function Marquee(){
	this.ID=document.getElementById(arguments[0]);//id
	this.Direction=arguments[1]; //0上 1下 2左 3右
	this.ClientWH=arguments[2];//如果方向上下这里是高度，左右宽度
	this.WaitTime=arguments[3];  //等待时间
	this.ID.innerHTML+=this.ID.innerHTML;
	this.i=1;
	
	this.start(this);
	
}
Marquee.prototype.start=function(obj){
	obj.startID=function(){obj.Scroll();}
	obj.Continue=function(){	
		clearInterval(obj.Timer);
		obj.Timer=setInterval(obj.startID,1);}
	obj.pause=function(){
		clearInterval(obj.Timer);	
		clearTimeout(obj.t);
		obj.t=setTimeout(obj.Continue,obj.WaitTime);}
	obj.ID.onmouseover=function(){clearInterval(obj.Timer);}
	obj.ID.onmouseout=function(){obj.Continue();}	
	
	obj.Continue();	
}
Marquee.prototype.Scroll=function(){
	switch(this.Direction)
	{
		//向上
		case 0:
			this.ID.scrollTop+=1;
			if(this.ID.scrollTop==this.ID.scrollHeight/2) this.ID.scrollTop=0;
			//本来用的for 火狐不管用，郁闷,只能用if了
			if(this.i==this.ClientWH){this.i=1;this.pause();}
			else{this.i++;}
			break;
		//向下
		case 1:
			this.ID.scrollTop-=1;
			if(this.ID.scrollTop==0) this.ID.scrollTop=this.ID.scrollHeight/2;
			//本来用的for 火狐不管用，郁闷,只能用if了
			if(this.i==this.ClientWH){this.i=1;this.pause();}
			else{this.i++;}
			break;			
	}
}