function ScrollingPanel(viewPortId, contentPanelId)
{
	this.width = "200px";
	this.height = "200px";
	this.viewPort = document.getElementById(viewPortId);
	this.viewPort.style.overflow = "hidden";
	this.contentPanel = document.getElementById(contentPanelId);
	this.contentPanel.style.top = "0px";
	this.contentPanel.style.MozUserSelect = "none";
	this.contentPanel.style.position = "relative";
	this.contentPanel.style.width = this.width;
	this.scrollUpLimit = 0;
	this.scrollStep = 5;
	this.scrollInterval = 500;// milliseconds
	this.intervalId = null;
}
														
ScrollingPanel.prototype.setHeight = function(pixelHeight)
{
	this.viewPort.style.height = pixelHeight + "px";
}

ScrollingPanel.prototype.setWidth = function(pixelWidth)
{
	this.viewPort.style.width = pixelWidth + "px";
	this.contentPanel.style.width = this.viewPort.style.width;
}

ScrollingPanel.prototype.setTop = function(pixelTop)
{
	this.viewPort.style.top = pixelTop + "px";
}

ScrollingPanel.prototype.setLeft = function(pixelLeft)
{
	this.viewPort.style.left = pixelLeft + "px";
}

ScrollingPanel.prototype.setPosition = function(position)
{
	this.viewPort.style.position = position;
}
							
ScrollingPanel.prototype.setScrollStep = function(pixelStep)
{
	this.scrollStep = pixelStep;
}
							
ScrollingPanel.prototype.setScrollInterval = function(milliseconds)
{
	this.scrollInterval = milliseconds;
}

ScrollingPanel.prototype.startScroll = function(direction)
{
	this.scrollDownLimit = this.viewPort.offsetHeight - this.contentPanel.offsetHeight;
	var step = (direction == "up") ? this.scrollStep : -this.scrollStep;
	this.scroll(step); 
}

ScrollingPanel.prototype.stopScroll = function()
{
	if(this.intervalId)
	{
		clearInterval(this.intervalId);	
		this.intervalId = null;
	}					
}

ScrollingPanel.prototype.scroll = function(step)
{
	var instance = this;
	this.intervalId = setInterval(function(){ScrollingPanel.moveContentPanel(instance, step)}, this.scrollInterval);
}

ScrollingPanel.moveContentPanel = function(instance, step)
{
	var topInt = parseInt(instance.contentPanel.style.top);
	if(step > 0 && topInt == 0) instance.stopScroll();
	else if(step < 0 && topInt <= instance.scrollDownLimit) instance.stopScroll();
	else instance.contentPanel.style.top = (topInt + step) + "px";
}

