(function($) {
    var debugMode = false;
    $.fn.extend({
        tabs: function(config) {
            this.options
				= $.extend({
					tabhead: "h3", // Tag or valid Query Selector of the Elements to Transform the Tabs-Navigation from (originals are removed)
					selected : 0,
					fx: "show", // can be "fadeIn", "slideDown", "show"
					fxspeed: "normal" // speed (String|Number): "slow", "normal", or "fast") or the number of milliseconds to run the animation
				}, config);

			var o = this;
			return this.each(function() {
				var el = $(this);
				var tabs = el.children(o.options.tabhead);
				tabs
					.each(function() {
						$(this)
							.children("a")
							.click(function(event) {
								event.preventDefault();
								// remove previous active tab
								el.children(o.options.tabhead + ".active")
									.removeClass("active")
									.next()
									.hide();
								// add active tab
								var aux = $(this)
									.parent()
									.addClass("active")
									.next();
								// try to adjust the height
								aux
									.parent()
									.height(aux.height()+$(this).height()+25);
								aux
									.toggle();
							});
						$(this)
							.next()
							.hide();
					});
				tabs
					.eq(o.options.selected)
					.addClass("active")
					.children("a")
					.click();
			});
        }
    });
    // private Methods
    function debug(msg){
        if(debugMode && window.console && window.console.log){
            window.console.log(msg);
        }
    }
})(jQuery);

$(document).ready(function() {
	$(".tabs").tabs();
});
