/********************************/
/*        图片向上间断循环滚动        */
/*        Power by Todd Lee        */
/*        lijiantao@eyou.com        */
/*        IE6 FF1.0.4                */
/*        不支持xhtml声明的文档    */
/*        2005-05-24 v1.0            */
 
 //var sample = new ScrollObj(String 内部滚动div的id, String 外面限制div的id, Int 限制显示高度,
 //Int 限制显示宽度, Int 每行的高度, Int 间隔停止的时间（毫秒）, Int 滚动速度（毫秒，越小越快）);
 //var sample = new ScrollObj('test_demo','test_demo1', 20,ppx);

/********************************/

//*********不要修改这部分***************
//scrollBodyId:    String 内部滚动div的id
//scrollBoxId:    String 外面限制div的id
//showHeight:    Int 限制显示高度
//showWidth:    Int 限制显示宽度
//lineHeight:    Int 每行的高度
//stopTime:        Int 间隔停止的时间（毫秒）
//speed:        Int 滚动速度（毫秒，越小越快）
ScrollObj = function(scrollBodyId,scrollBoxId,speed,ppx,pcycle) 
{
	
    this.ie = (navigator.appVersion.indexOf("MSIE")!=-1);
	this.ie6 = (navigator.appVersion.indexOf("MSIE 6.0")!=-1);
	this.ie7 = (navigator.appVersion.indexOf("MSIE 7.0")!=-1);
	this.ie8 = (navigator.appVersion.indexOf("MSIE 8.0")!=-1);
    this.ff = (navigator.userAgent.indexOf("Firefox")!=-1);//Firefox
    this.obj = document.getElementById(scrollBodyId);
    this.box = document.getElementById(scrollBoxId+'1'); 
	this.defaultWidth = this.box.offsetWidth;
    this.style = this.obj.style;
	this.content = this.box.innerHTML;
	this.cycle = pcycle;

    //this.box.innerHTML += this.box.innerHTML;

    document.getElementById(scrollBoxId+'2').innerHTML=document.getElementById(scrollBoxId+'1').innerHTML;

    if(!this.ie8)this.obj.style.position = "relative";
	this.scrollLeft = doScrollLeft;
    this.stopScroll = false;
    this.speed = speed;
	
    this.px = 0;//(this.ff==true)?ppx:this.obj.offsetWidth;
	//alert(this.obj.offsetWidth+'--'+this.px);
	this.left = true;
	this.style.left = 0;
    this.object = scrollBodyId + "Object";
    eval(this.object + "=this");
	setInterval(this.object+".scrollLeft()",speed);
    this.obj.onmouseover=new Function(this.object+".stopScroll=true");
    this.obj.onmouseout=new Function(this.object+".stopScroll=false");
}

function doScrollLeft() {
	  if( this.stopScroll == true ) return;
	  //alert('offsetWidth is:'+this.box.offsetWidth+',scrollLeft is:'+this.obj.scrollLeft+',this.cycle is:'+this.cycle)
	  if(this.left && this.box.offsetWidth-this.obj.scrollLeft<=this.px){   
			if(this.cycle){
				this.obj.scrollLeft-=this.box.offsetWidth;			
			}
			else this.left=false;
		  }
	  else if(this.obj.scrollLeft<=0) {   
		  if(this.cycle)
		  {
			  this.obj.scrollLeft++;	
		  }
		  else 	this.left=true;

	  } 
	  if(this.cycle)
		{
			  this.obj.scrollLeft++;
		}
	  else
		{
		  if(this.left)this.obj.scrollLeft++;
		  else this.obj.scrollLeft--;
		}
		//alert('after action   offsetWidth is:'+this.box.offsetWidth+',scrollLeft is:'+this.obj.scrollLeft+',this.cycle is:'+this.cycle)
}

