
$.fn.tinyscroller = function(options){
	var stop = false;
	var step = 1;
	var railz = $('.rails', this)
		.css({
			position: 'relative',
			overflow: 'hidden',
			height: options.railsHeight
		})

	var wheelz = $('.wheels', this)
		.css('position', 'relative')

	if (railz.height() > wheelz.height()) {
		return false;
	}		

	
	var controlz = $('.control', this)
			.css({
				cursor: 'pointer'
			})
			.mousedown(check)
			.click(stopNow);
		$(controlz[0]).data('dir', 1);
		$(controlz[1]).data('dir', -1);
		

	
	var limitz = [];
		limitz[0] = 0;
		limitz[1] = railz.height() - wheelz.height();

		
	function check(){
		$(this).addClass('active');

		var dir =  $(this).data('dir');
		var limit = limitz[(1-dir)/2] 
				
		wheee(dir, limit);
	}
	
	function wheee(dir, limit) {
		
		if (limit != parseInt(wheelz.css('top'))) {
			stop = false;
			wheelz.animate({
				'top': '+=' + (step*dir).toString()
			}, 1, function(){
				if (!stop) {
					wheee(dir, limit)
				}
			});
		}
		return false;
	}
	
	function stopNow() {
		stop = true;
		$(this).removeClass('active');
		return false;
	}
		
}
