(function($) {

	$.fn.extend({
		scrollable: function(params)
		{
			init(this);
		}
	});
	
	function init(el){
		el.each(
			assign_events
		);
	}
	
	function assign_events(){
		var start = 0;
		var stop = 0;
		var el = $(this)
		if(el.find('.scrollable').height() <= el.find('.scroll').height())
			el.find('.scroll').hide();
		el.find('.scroll a').click(function(){
			return false;
		});
		el.find('.scroll .up').mousedown(function(){
			el.find('.scrollable').animate({'top' : start});
			return false;
		});
		el.find('.scroll .up').mouseup(function(){
			el.find('.scrollable').stop();
			return false;
		});
		el.find('.scroll .down').mousedown(function(){
			var content_length = el.find('.scrollable').height();
			var stop = el.height() - content_length;
			el.find('.scrollable').animate({'top' : stop});
			return false;
		});
		el.find('.scroll .down').mouseup(function(){
			el.find('.scrollable').stop();
			return false;
		});
	}
	
})(jQuery);
