$.fn.tape_slider = function(options) {
	var tape = $('.roll_tape', this), slots = $('.tape_slot', this),
	tape_length = options.slot_width * slots.length;
	
	tape.css('width', tape_length).show();

	var offset = 0, max_offset = (slots.length - options.visible_count) * options.slot_width;
	var prev = $('.prev', this), next = $('.next', this);
	
	//Hide arrows if not needed
	if(slots.length <= options.visible_count) $('.prev, .next', this).hide();
	
	//Add slider functions
	else {
		var timer = null;
	
		var bound_offset = function(value) {
			if(value < 0) value = 0;
			if(value > max_offset) value = max_offset;
			return value;
		}
		
		var change_arrows = function(offset) {
			prev.toggleClass('none', offset == 0);
			next.toggleClass('none', offset == max_offset);
		}
	
		var move = function(dir) {
			tape.stop();
		
			var new_offset = Math.floor(offset/options.slot_width + (dir > 0 ? 1 : 0)) * options.slot_width;
			if(dir < 0 && new_offset == offset) new_offset = offset - options.slot_width;
			
			new_offset = bound_offset(new_offset);
			
			if(new_offset != offset) {		
				change_arrows(new_offset);
			
				tape.animate({left: -new_offset}, 400, 'swing', function(){
					offset = new_offset;
				});
				return false;
			}
		}
		
		//Bind events
		prev.click(function(){ return move(-1); });
		next.click(function(){ return move(1); });
		
		tape.mousewheel(function(event, delta) {
			tape.stop();
			
			offset = bound_offset(offset + delta * -15);
			this.style.left = -offset + 'px';
			
			change_arrows(offset);
			return false;
		});
		
		if(options.start > 1) {
			offset = bound_offset((options.start - 1) * options.slot_width);
			tape.css('left', -offset);
		}
		
		change_arrows(offset);
	} 
}