jQuery.fn.scroller = function(options) {
    var settings = jQuery.extend({
        panel: null,
		items : null,
        up: null,
        down: null,
        speed: 500,
		show : 4,
		active : 0
    }, options);
	
	if (!settings.panel || !settings.up || !settings.down)
		alert('Element Missing');
	
	var obj = this;
	
	var totalDisplayHeight = 0;
	var currentIndex = settings.show - 1;
	var items = settings.items;
	var totalItems = items.size();
	var container = $('<div/>').css({marginTop : 0});
	
	items.each(function(index) {
		if (index < settings.show) {
			totalDisplayHeight += $(this).outerHeight(true);
		}
		container.append(this);
	});
	settings.panel.append(container);
	settings.panel.css({height: totalDisplayHeight, overflow: 'hidden'});
	
	if (items.size() > settings.show) {
		settings.up.css({opacity : 0.2});
		
		settings.up.click(function() {
			if (currentIndex + 1 > settings.show) {
				settings.down.css({opacity : 1});
				var itemHeight = $(items[currentIndex]).outerHeight(true);
				var marginTop = (parseInt(container.css('marginTop')) + itemHeight);
				container.animate({marginTop: marginTop}, settings.speed);
				currentIndex--;
			} 
			if (currentIndex - 1 < settings.show) {
				settings.up.css({opacity : 0.2});
			}
		});
		
		settings.down.click(function() {
			if (currentIndex + 1 < totalItems) {
				settings.up.css({opacity : 1});
				currentIndex++;
				var itemHeight = $(items[currentIndex]).outerHeight(true);
				var marginTop = (parseInt(container.css('marginTop')) - itemHeight);
				container.animate({marginTop: marginTop}, settings.speed);
			}
			
			if (currentIndex + 1 == totalItems) {
				settings.down.css({opacity : 0.2});
			}
		});
		
		if (settings.active > 0) {
			currentIndex = settings.active;
			var itemHeight = $(items[currentIndex]).outerHeight(true);
			var marginTop = (parseInt(container.css('marginTop')) - itemHeight);
			container.animate({marginTop: marginTop}, settings.speed);
		}
	} else {
		settings.up.css({display: 'none'});
		settings.down.css({display: 'none'});
	}
}
