var bottomBarHeight=-1;(function(a){a.tabpane={build:function(b){if(typeof(b)=="undefined"){b={}}var c=a.extend({},a.tabpane.defaults,b);return this.each(function(){var h=a(this);var g=a.extend({},c,h.metadata());if(a.browser.msie){g.animate=false}if(!h.is(".jqTabPaneInitialized")){h.addClass("jqTabPaneInitialized");var d=h;a('<span class="foswikiClear"></span>').prependTo(h);var f=a('<ul class="jqTabGroup"></ul>').prependTo(h);var e=1;h.find("> .jqTab").each(function(){var i=a(this);var j=i.find("h2:first").remove().html();f.append('<li><a href="#" data="'+this.id+'">'+j+"</a></li>");if(e==g.select||i.hasClass(g.select)){g.currentTabId=this.id}e++});if(g.currentTabId){a.tabpane.switchTab(h,g,g.currentTabId)}if(g.autoMaxExpand){a.tabpane.autoMaxExpand(h,g)}h.find(".jqTabGroup > li > a").click(function(){a(this).blur();var i=a(this).attr("data");if(i!=g.currentTabId){a.tabpane.switchTab(h,g,i)}return false})}})},switchTab:function(n,b,j){var g=b.currentTabId;a.log("TABPANE: switching from "+g+" to "+j);var l=jQuery("#"+j);var h=jQuery("#"+g);var d=l.find(".jqTabContents:first");var e=h.find(".jqTabContents:first");var m=e.height();h.removeClass("current");l.addClass("current");n.find("li a[data="+g+"]").parent().removeClass("current");n.find("li a[data="+j+"]").parent().addClass("current");if(!b[j]){b[j]=l.metadata()}var i=b[j];if(typeof(i.beforeHandler)=="function"){i.beforeHandler.call(this,g,j)}if((b.animate||b.autoMaxExpand)&&m>0){a.log("TABPANE: setting height to "+m);d.height(m)}var f=d;var k=false;if(typeof(i.container)!="undefined"){f=d.find(i.container);if(f.length){k=true}else{f=d}}function c(){var p="none";if(m>0){p="easeInOutQuad"}if(b.autoMaxExpand){if(b.animate&&p!="none"){f.css({opacity:0}).animate({opacity:1},300)}a(window).trigger("resize")}else{if(b.animate){d.height("auto");if(p!="none"){var o=d.height();if(k){d.height(m).animate({height:o},300,p,function(){d.height("auto")});f.css({opacity:0}).animate({opacity:1},300,p)}else{d.height(m).css({opacity:0}).animate({opacity:1,height:o},300,p,function(){d.height("auto")})}}}}if(typeof(i.afterHandler)=="function"){i.afterHandler.call(this,g,j)}b.currentTabId=j}if(typeof(i.url)!="undefined"){f.load(i.url,undefined,function(p,o,q){if(typeof(i.afterLoadHandler)=="function"){i.afterLoadHandler.call(this,g,j)}c()});delete b[j].url}else{c()}},autoMaxExpand:function(c,b){window.setTimeout(function(){jQuery.tabpane.fixHeight(c,b);jQuery(window).one("resize",function(){a.tabpane.autoMaxExpand(c,b)})},100)},fixHeight:function(e,d){jQuery.log("TABPANE: called fixHeight()");var f=e.find("> .jqTab.current .jqTabContents:first");var c=f.offset();if(typeof(c)=="undefined"){return}var i=c.top;if(bottomBarHeight<=0){bottomBarHeight=jQuery(".natEditBottomBar").outerHeight(true)}var h=jQuery(window).height();if(!h){h=window.innerHeight}var b=h-i-2*bottomBarHeight+0.5;var g=a("#DEBUG");if(g){b-=g.outerHeight(true)}if(d&&d.minHeight&&b<d.minHeight){b=d.minHeight}if(b<0){return}f.height(b)},defaults:{select:1,animate:false,autoMaxExpand:false,minHeight:230}};a.fn.tabpane=a.tabpane.build})(jQuery);