$(function(){
	
	var speed = 30;
	
	function movebox(direction,object)
	{
		var parent = $(object).parent().parent().attr('id');
		var ul = $('#' + parent + ' .links ul');
		var current = parseInt(ul.css('top'));
		
		if (direction == 1)  // up
		{
			if (current < 0)
			{
				var move = current + speed;
			}
		}
		else // down
		{
			var total = 0 - parseInt(ul.children().size()) * 30;
			if ( current > ( total) )
			{
				var move = current - speed;
			}
		}
		
		ul.css('top', move);
	}
	
	// begin arrows
	$('.up').click(function() {
		movebox(1,this);
	});
	
	$('.down').click(function() {
		movebox(0,this);
	});
	
});
