(function($){
	jQuery.fn.simpletab = function(settings) {
		var s = jQuery.extend({startIndex:0}, settings);
		
		var activeTab = null;
		var activeContent = null;
		
		return $(this).each(function(){
			
			// set tab click handler
			$(this).children().click(function(){
				$this = $(this);

				// hide active if it isn't active tab
				if (!activeTab || $this.find('a').attr('href') != activeTab.find('a').attr('href')){
					if (activeTab) activeTab.removeClass('active');
					if (activeContent) activeContent.hide();

					// highlight the active tab
					$this.addClass('active');

					// show the contents
					var id = $(this).find('a').attr('href').substr(1); // remove the #
					activeContent = $('#' + id);
					activeContent.show();

					activeTab = $this;
				}
				
				return false;
			});
			
			$(this).children().eq(s.startIndex).click();
			
			return this;
		});
	};
})(jQuery);
