var ScrollContent = Class.create (
{
	initialize: function(wrap, scroller, up, down, speed)
	{
		var self = this;
		this.wrap = $(scroll-wrap);
		this.scroller = $(scroller);
		this.up = $(up);
		this.down = $(down);
		this.speed = speed;
		this.iid = 0;
		
		if(this.scroller.offsetHeight > 360)
		{
			self.showControls();
		}
		
		
		Event.observe(this.up, 'mouseover', function(){
			self.iid = setInterval(function()
			{
				self.scrollUp();
			}, self.speed);
		});
		
		Event.observe(this.down, 'mouseover', function(){
			self.iid = setInterval(function()
			{
				self.scrollDown();
			}, self.speed);
		});
		
		Event.observe(this.up, 'mouseout', function(){
			clearInterval(self.iid);
		});
		
		Event.observe(this.down, 'mouseout', function(){
			clearInterval(self.iid);
		});
	},
		
	scrollUp: function()
	{
		var pos = eval($(this.scroller).getStyle('top').replace('px', ''));
		if( pos < 0 )
		{
			$(this.scroller).setStyle({
				'top': ( pos + 1 ) + 'px'
			});
		}
	},
	
	scrollDown: function()
	{
		var pos = eval($(this.scroller).getStyle('top').replace('px', ''));
		if( -(pos) < ($(this.scroller).offsetHeight - 360))
		{
			$(this.scroller).setStyle({
				'top': ( pos - 1 ) + 'px'
			});
		}
	},
	
	showControls: function()
	{
		$$('ul.scroll-controls').each(function(controls){
			$(controls).setStyle({
				'display': 'block'
			});
		});
	}
});

Event.observe(window, 'load', function()
{
	if ($('scroll-wrap')) {
		// Wrap, scrollable content, up, down, speed
		new ScrollContent('scroll-wrap', 'scroller', 'scroll-up', 'scroll-down', 2);
	}
});