
function NewsScroller(divName, top, height, width, left, toClip, initialPause, speed)
{
  this.divName = divName.toString();
  this.top = top;
  this.height = height;
  this.width = width;
  this.left = left;
  this.toClip = toClip;
  this.timerOn = true;
  this.currentPosition = 0;
  this.timerOn = true;
  this.initialPause = initialPause;
  this.speed = speed;
}

NewsScroller.prototype.scroll = function() {

	if (this.timerOn)
	{
		div = getObject(this.divName);
	
	  if ( div == null ) { 
	    return; 
	  }
	
	  if ( document.layers ) {
	    div.clip.top = this.currentPosition;
	    div.clip.bottom = this.currentPosition + this.toClip;
	    div.top = this.top - this.currentPosition;
	  } 
	  else {
	    div = div.style;
	    div.clip = "rect(" + this.currentPosition + "px " + (this.width + this.left) + "px " + (this.currentPosition + this.toClip) + "px 0px)";
	    div.top = this.top - this.currentPosition + "px"; 
	  }
	  if ( ( this.top + this.height - this.currentPosition ) < ( this.top - this.height - 20 ) ) {
	    this.currentPosition = 0;
	    if ( document.layers ) {
	      div.clip.top = this.top;
	      div.clip.bottom = this.toClip;
	      div.top = this.top
	    }
	    else {
	      div.clip = "rect(" + this.currentPosition + "px " + (this.width + this.left) + "px " + (this.currentPosition + this.toClip) + "px 0px)";
	      div.top = this.top + "px";
	    }
	  }
		
		this.currentPosition++;
	}
	
	var self = this; 
	window.setTimeout(function() { self.scroll(); }, (this.currentPosition == 1 ? this.initialPause : this.speed));
		
	return;
}

NewsScroller.prototype.pause = function()
{
	this.timerOn = false;
}

NewsScroller.prototype.resume = function()
{
	this.timerOn = true;
}

function getObject( obj ) {
    var strObj;
    if ( document.all ) {
        strObj = document.all.item( obj );
    }
    else if ( document.getElementById ) {
        strObj = document.getElementById( obj );
    }
    return strObj;
}

