// Scrolling for the vertical menu
var scrollTimeoutVar;
var scrollStep = 2;     //pixels to scroll each interval
var scrollInterval = 15; //milliseconds between scroll steps

function activateScroll(scrollWhichLayer, scrollDirection)
{
	if (scrollDirection == "up") {
		scrollTimeoutVar = setInterval("moveLayerBy('"+scrollWhichLayer+"', 0, "+ scrollStep + ");", scrollInterval);
	}
	else if (scrollDirection == "down") {
		scrollTimeoutVar = setInterval("moveLayerBy('"+scrollWhichLayer+"', 0, "+ -scrollStep + ");", scrollInterval);
	}
}

function deactivateScroll()
{
	window.clearInterval(scrollTimeoutVar);
}

function moveLayerBy(whichLayer, deltaX, deltaY)
{
  var myObj = document.getElementById(whichLayer);
	myObj.style.overflow="scroll";
	myTop = parseInt(myObj.style.top);
	myHeight = parseInt(myObj.scrollHeight);
	myVisibleHeight = parseInt(myObj.style.height);
	myMoveY = parseInt(deltaY);
	if (myTop + myMoveY > -myMoveY && myMoveY > 0) {
		// If the next move is down but would go too far
	  myObj.style.top = "0px";
	}
	else if (myHeight + myTop + myMoveY <= 325 && myMoveY < 0) {
		// If the next move is up but would go too far
	  myObj.style.top = -(myHeight -325) + "px";
}
	else {
		// If the next move is valid
	 	myObj.style.top = myTop + myMoveY + "px";
	}
	myObj.style.overflow="hidden";
}

