function getTop() {
	// get the top of the content
	var top = $('#twitter_update_list').css('top');
	return trimPx(top);
}

function getHeight(id) {
	// get the height, including padding
	var height = $(id).height();
	var paddingTop = trimPx($(id).css("padding-top"));
	var paddingBottom = trimPx($(id).css("padding-bottom"));

	return height + paddingTop + paddingBottom;
}

function trimPx(value) {
	// remove "px" from values
	var pos = value.indexOf("px");
	if (pos != 0)
		return parseInt(value.substring(0, pos));
	else
		return 0;
}

var container;
var content;
var hidden;	// # of pixels hidden by the container

function setScrollerDimensions() {
	container = getHeight("#twitter_update_container");
	content = getHeight("#twitter_update_list");
	hidden = content - container;
}

function resetScroller() {
	setScrollerDimensions();
	$('#twitter_update_list').css('top', 0);
}

$(document).ready(function() {
	
	setScrollerDimensions();
	$('#scroll-down').hover(
		function() {
			if (hidden > 0) {
				$('#twitter_update_list').animate({ top: -hidden }, 2000);
			}
		},
		function() {
			$('#twitter_update_list').stop();
		}
	);

	$('#scroll-up').hover(
		function() {
			if (hidden > 0) {
				$('#twitter_update_list').animate({ top: "0" }, 2000);
			}
		},
		function() {
			$('#twitter_update_list').stop();
		}
	);
});
