var slowNess = 3;

function getUpDuration() {
	return $('scroll').getScroll().y * slowNess;
}

function getDownDuration() {
	return ($('scroll').getScrollSize().y - $('scroll').getScroll().y) * slowNess;
}

function setup(){
	
	$('scroll').setStyle('overflow', 'hidden');
	
	if ($('scroll').getScrollSize().y <= $('scroll').getSize().y) {
		$('scrollcontrols').setStyle('display', 'none');
	};
	
	$('scroll').fx = new Fx.Scroll('scroll', {duration:getDownDuration()});

	$('up').addEvent('mouseover', function() {
		$('scroll').fx.options.duration = getUpDuration();
		$('scroll').fx.toTop();
	});
	
	$('up').addEvent('mouseout', function(){
		$('scroll').fx.cancel();
	});

	$('down').addEvent('mouseover', function() {
		$('scroll').fx.options.duration = getDownDuration();
		$('scroll').fx.toBottom();
	});
	
	$('down').addEvent('mouseout', function(){
		$('scroll').fx.cancel();
	});		
}

window.addEvent('domready', setup);

