//document.onmouseup = stop_scroll;
   
var scrollTimer;  
var scrollData = new Array();	 
var scrollMaxSpeed = 2;

var scrollCurrentSpeed = 0;
var scrollDestinationSpeed = scrollMaxSpeed;
		 
function scroll_init(text,up,down,scrollHeight)
{	 
	scrollData[text] = new Object(); 
	scrollData[text].elem = document.getElementById(text);
	scrollData[text].up = document.getElementById(up);
	scrollData[text].down = document.getElementById(down);	
	scrollData[text].height = scrollHeight;  

	scrollData[text].elem.style.top = "0px";
	heightInt = parseInt(scrollData[text].elem.offsetHeight);

	if (heightInt > (scrollHeight+10)) {
		scrollData[text].up.style.visibility = "hidden";
		scrollData[text].down.style.visibility = "visible";
	}		
	else
	{
		scrollData[text].elem.style.height = scrollHeight+"px";
		scrollData[text].up.style.visibility = "hidden";
		scrollData[text].down.style.visibility = "hidden";
	}		  
}

function scrolldown(id) 
{
	elem = document.getElementById(id);	   
	heightInt = parseInt(elem.offsetHeight);
	topInt = parseInt(elem.style.top);
	if (scrollCurrentSpeed < scrollDestinationSpeed) scrollCurrentSpeed += 0.3;
	if (scrollCurrentSpeed > scrollDestinationSpeed) scrollCurrentSpeed -= 0.3;
	if (scrollCurrentSpeed <= 0) scroll_end();
	topInt -= scrollCurrentSpeed;
	if (topInt < scrollData[id].height-heightInt) 
	{
		topInt = scrollData[id].height-heightInt;
		scrollData[id].down.style.visibility = "hidden";
	}
	elem.style.top = topInt+"px";
	if (topInt < 0) scrollData[id].up.style.visibility = "visible";
}

function scrollup(id) 
{
	elem = document.getElementById(id);
	topInt = parseInt(elem.style.top);
	if (scrollCurrentSpeed < scrollDestinationSpeed) scrollCurrentSpeed += 0.3;
	if (scrollCurrentSpeed > scrollDestinationSpeed) scrollCurrentSpeed -= 0.3;
	if (scrollCurrentSpeed <= 0) scroll_end();
	topInt += scrollCurrentSpeed;
	if (topInt > 0) 
	{
		topInt = 0;
		scrollData[id].up.style.visibility = "hidden";
	}
	elem.style.top = topInt+"px";
	if (topInt > scrollData[id].height-heightInt) scrollData[id].down.style.visibility = "visible";
}

function start_scrolldown(id)
{							   
	scroll_end();  
	scrollTimer = setInterval("scrolldown('"+id+"')",10);	
}

function start_scrollup(id)
{		
	scroll_end();  
	scrollTimer = setInterval("scrollup('"+id+"')",10);
}						
					   
function scroll_end()
{
	scrollCurrentSpeed = 0;
	scrollDestinationSpeed = scrollMaxSpeed;
	clearInterval(scrollTimer);
}

function stop_scroll()
{	   							
	scrollDestinationSpeed = 0;
}