(function($){
	$.fn.extend({
		slider: function(options) {

			var defaults = {
				items:$("li a", this), //the block type definition
				defaultItem:$("li a", this).eq(0), //the first open block
				picker:$("#picker"),
				duration:500
			};

			var options = $.extend(defaults, options);

			return this.each(function() {
				var o = options;
				var obj = $(this);
				var items = $(o.items, obj);

				//hide items
				items.each(function() {
					$(this).css("opacity", 0.0);
					$(this).css("display", "none");
				});

				//show the default item
				o.defaultItem.css("opacity", 1.0);
				o.defaultItem.css("display", "block");
				
				//keep track of the last item
				var lastItem = o.defaultItem;
				
				items.click(function() {
					//
				});

				o.picker.bind("picked", function(event) {
					slide(event.index);
				})

				function slide(index) {

					if(index == items.index(lastItem)) return;

					var target = items.eq(index);

					lastItem.hide("slide", {direction: "down"}, o.duration);
					$(target).css("opacity", 1.0);
					$(target).show("slide", {direction: "up"}, o.duration);
					
					lastItem = $(target);
				}
			});
		}
	});
})(jQuery);