function Scroller(elmtId)
{
	this.element = document.getElementById(elmtId);
	this.intervalFunction = null;
	this.currentPos = 0;
}

Scroller.prototype.update = function(html, startTime, endTime, offset)
{
	// stop current scrolling
	this.stopScrolling();

	// update html
	this.element.innerHTML = html + " &nbsp; &nbsp; &nbsp; &nbsp; ";
	this.scrollWidth = this.element.offsetWidth;

	// update rate
	var duration = 1000 * (endTime - startTime);
	if (duration <= 0)
		return;
	var width = this.scrollWidth + offset - 50;
	this.intervalTime = width > 0 ? 2 * (duration / width) : 50;
	this.scrollDistance = 2;
	
	// update position
	if (offset >= 0)
	{
		this.currentPos = offset;
		this.element.style.left = this.currentPos + "px";
	}

	// events
	var self = this;
	//this.element.parentNode.onmouseover = function() { self.stopScrolling() };
	//this.element.parentNode.onmouseout = function() { self.startScrolling() };

	// start scrolling
	this.startScrolling();
}

Scroller.prototype.stop = function()
{
	this.stopScrolling();
}

Scroller.prototype.startScrolling = function()
{
	// closure
	var self = this;
	this.intervalFunction = window.setInterval(function() { self.scroll() }, this.intervalTime);
}

Scroller.prototype.stopScrolling = function()
{
	if (this.intervalFunction != null)
	{
		window.clearInterval(this.intervalFunction);
		this.intervalFunction = null;
	}
}

Scroller.prototype.scroll = function()
{
	this.currentPos = this.currentPos - this.scrollDistance;
	if (this.currentPos + this.scrollWidth <= 0)
	{
		stop();
	}
	this.element.style.left = this.currentPos + "px";
}