;(function($) {
	$.fn.extend({
        imUpSideDownTabber: function(options) { 
        	opts = $.extend({}, $.tabberDisplay.defaults, options);
			return this.each(function() {
				new $.tabberDisplay(this, opts);
			});
        }
    });	

$.tabberDisplay = function(obj, opts) {
	var $this = $(obj);
	var selected = null;
	//var once = false;
	$this.append($('<div></div>').attr("id", opts.tab_container));
	$.each(opts.tabs, function(i, itm) {
		$("#"+opts.tab_container).append($('<a></a>')						
		//a = document.createElement(a);
		//$(a)
			.append(itm.caption)
			.attr("href", "#") 
			.click(function() {
				$("."+opts.active_tab_class).removeClass(opts.active_tab_class);
				$(this).addClass(opts.active_tab_class);
				showHide(itm.content_id);
				return false;
			}));
	});
	
	function showHide(id) {
		if (selected) {
			$("#"+selected).slideUp("slow");
			$("#login_box_fader").slideUp("slow");
			
			//$("#"+opts.tab_container).slideUp("slow");
		}
		if (selected == id) {
			selected = '';	
			$("."+opts.active_tab_class).removeClass(opts.active_tab_class);
		} else {
			$("#"+id).slideDown("slow");
			
			$("#login_box_fader").slideDown("slow");
			
			selected = id;
		}
	};
};

$.tabberDisplay.defaults = {
	//element: 'a';//this value can be blank. It will be automatically set to "a"
	//active_tab_class: 'selected';//this value can be blank. It will be automatically set to "a.selected"
	//content_class: 'tab_content' //this value can be blank. It will be automatically set to "tab_content. This div must be set display:none in the css file"
	content_class: '',
	tab_container: '',
	active_tab_class: '',
	tabs: '',
	direction: ''// (up, down);
};

})(jQuery);	
