var ourInterval;
var origColor = "#F3F9F1";
var overColor = "#36FF00";
var scrollSpeed = 50;
var scrollHeight = 5;

var scrollstarted	= false;

function increaseSpeed(direction, divID, elementID){
	scrollSpeed	= 25;
	clearInterval(ourInterval);
	ourInterval = setInterval("scroll"+direction+"('"+divID+"')", scrollSpeed);
}

function decreaseSpeed(direction, divID, elementID){
	scrollSpeed	= 50;
	clearInterval(ourInterval);
	ourInterval = setInterval("scroll"+direction+"('"+divID+"')", scrollSpeed);
}

function scrollStart(direction, divID, elementID){
//CHANGE THE BACKGROUND COLOR OF THE TD THE MOUSE IS OVER
//document.getElementById(elementID).style.backgroundColor = overColor;
// REPEATED CALL EITHER scrollUp OR scrollDown

//scrollstarted	= true;
//setTimeout("scroll"+direction+"('"+divID+"')", scrollSpeed);
ourInterval = setInterval("scroll"+direction+"('"+divID+"')", scrollSpeed);
}
function scrollEnd(which){
// OUR MOUSE IS OUT, SO RETURN TD TO ORIGINAL COLOR
//document.getElementById(which).style.backgroundColor = origColor;
// STOP CALLING THE SCROLL FUNCTION
clearInterval(ourInterval);
//scrollstarted	= false;
}

function scrollUp(which){
// SET THE SCROLL TOP
document.getElementById(which).scrollTop = document.getElementById(which).scrollTop - scrollHeight;
getProgress(which);
//if(scrollstarted==true)
//{
//	setTimeout("scrollUp("+which+")",scrollSpeed);
//}

}
function scrollDown(which){
// SET THE SCROLL TOP
document.getElementById(which).scrollTop = document.getElementById(which).scrollTop + scrollHeight;
getProgress(which);

//if(scrollstarted==true)
//{
//	setTimeout("scrollDown("+which+")",scrollSpeed);
//}
}

function getProgress(which)
{
	var height	= document.getElementById(which).scrollHeight-document.getElementById(which).offsetHeight;
	var top		= document.getElementById(which).scrollTop;
	
	var percent	= Math.ceil((top/height)*100);
	if(!isNaN(percent))
	{
		var elem	= document.getElementById(which+"progress");
		if(typeof(elem)!="undefined" && elem)
		{
			elem.innerHTML	= percent+"%";
		}    
		elem    = document.getElementById(which+"progressbar");
		if(typeof(elem)!="undefined" && elem)
		{
			elem.style.width    = percent+"%";
		}
		elem    = document.getElementById(which+"progressbartext");
		if(typeof(elem)!="undefined" && elem)
		{
			elem.innerHTML  = percent+"%";
		}
	}
}

