//<!-作者：风飘无影 -->
//参数说明: 要滚动的容器ID,方向r,l,t,b(t,b要注意内容必须是多行),延时速度,宽度，高度
function $2(id){return document.getElementById(id);} 
function myMarquee(_id,_mode,_speed,_w,_h,_step,_stopTime)
{	
	this.ID=_id;
	this.mode=_mode; 
	this.speed=_speed;
	this.txt=$2(_id).innerHTML;
	this.width=_w;
	this.height=_h;
	
	if(_step!=null)
	    this.step=_step;
	if(_stopTime!=null)
	    this.stopTime=_stopTime
	
	
	
	var s='<div id="'+_id+'content" style="overflow: hidden;height:'+_h+'px;width:'+_w+'px;white-space: nowrap;"><div id="'+_id+'_show" style="display: inline">'+this.txt+'</div><div id="'+_id+'_hide" style="display: inline"></div></div>'
	$2(_id).innerHTML=s;	
}

myMarquee.prototype.run=function()
	{
		
		$2(this.ID+'_hide').innerHTML=$2(this.ID+'_show').innerHTML;
		var temp='mymarquee'+this.ID+'=setInterval(\'doing("'+this.mode+'","'+this.ID+'")\','+this.speed+')'	
		eval(temp)

		var _id=this.ID;
		var _mode=this.mode;
		var _speed=this.speed;
		$2(this.ID+'content').onmouseover=function() 
			{
				eval('clearInterval(mymarquee'+_id+')')
			}		
		$2(this.ID+'content').onmouseout=function() 
			{
				eval('mymarquee'+_id+'=setInterval(\'doing("'+_mode+'","'+_id+'")\',_speed)');
			}
	}

function doing(mode,ID)
	{
	    //  alert(ID)
		  switch(mode) {
		   case 'l':
			if($2(ID+'_show').offsetWidth-$2(ID+'content').scrollLeft<=0)
			 $2(ID+'content').scrollLeft-=$2(ID+'_show').offsetWidth
			else{
			 $2(ID+'content').scrollLeft++
			}
			break;
		   case 'r':
			if($2(ID+'content').scrollLeft<=0)
			 $2(ID+'content').scrollLeft+=$2(ID+'_show').offsetWidth
			else{
			 $2(ID+'content').scrollLeft--
			}
			break;
		   case 't':
			    if($2(ID+'_hide').offsetTop-$2(ID+'content').scrollTop<=0)
			     $2(ID+'content').scrollTop-=$2(ID+'_show').offsetHeight
			    else{
			     $2(ID+'content').scrollTop++
			    }
			    			  
	          //  window.setTimeout("doing('"+mode+"','"+ID+"')", 2000 ); 
			    
			break;
		   case 'b':
			if($2(ID+'_show').offsetTop-$2(ID+'content').scrollTop>=0)
			 $2(ID+'content').scrollTop+=$2(ID+'_hide').offsetHeight
			else{
			 $2(ID+'content').scrollTop--
			}
			break;
		  }
	 }
	 
