

var speed = 15; // Set scrolling speed - larger number = slower.

var top = 0;
var scrollAmount = 0;
var moveupvar;
var movedownvar;
var contentHeight = 0;
var containerHeight = 0;
function initializeScroll() {
	top = 0;
	scrollAmount = 0;

	contentHeight = $("#content").height();
	containerHeight = $("#container").height();
	scrollAmount = contentHeight - containerHeight;
	
	if (scrollAmount > 0) {
		$("#down").css("visibility", "visible");
		$("#content").css("width", ($("#container").width() - 30) + "px");
		contentHeight = $("#content").height();
		scrollAmount = contentHeight - containerHeight;
	}
	
	$("#up").hover(
		function () { moveUp(); },
		function () { clearTimeout(moveupvar); }
	);
	$("#down").hover(
		function () { moveDown(); },
		function () { clearTimeout(movedownvar); }
	);
}

function moveDown() {
	if ("-" + scrollAmount <= top) {
		top--;
		$("#up").css("visibility", "visible");
		$("#content").css("top", top + "px");
		movedownvar = setTimeout("moveDown()", speed);
	} else {
		$("#down").css("visibility", "hidden");
	}
}

function moveUp() {
	if (top <= 0) {
		top++;
		$("#down").css("visibility", "visible");
		$("#content").css("top", top + "px");
		moveupvar = setTimeout("moveUp()", speed);
	} else {
		$("#up").css("visibility", "hidden");
	}
}

$(document).ready(function(){
	initializeScroll();
});

