(function(c){c.widget("ui.accordion",{init:function(){var j=this.options;if(j.navigation){var g=this.element.find("a").filter(j.navigationFilter);if(g.length){if(g.filter(j.header).length){j.active=g;}else{j.active=g.parent().parent().prev();g.addClass("current");}}}j.headers=this.element.find(j.header);
j.active=e(j.headers,j.active);if(c.browser.msie){this.element.find("a").css("zoom","1");}if(!this.element.hasClass("ui-accordion")){this.element.addClass("ui-accordion");c("<span class='ui-accordion-left'/>").insertBefore(j.headers);c("<span class='ui-accordion-right'/>").appendTo(j.headers);j.headers.addClass("ui-accordion-header").attr("tabindex","0");
}var h;if(j.fillSpace){h=this.element.parent().height();j.headers.each(function(){h-=c(this).outerHeight();});var i=0;j.headers.next().each(function(){i=Math.max(i,c(this).innerHeight()-c(this).height());}).height(h-i);}else{if(j.autoHeight){h=0;j.headers.next().each(function(){h=Math.max(h,c(this).outerHeight());
}).height(h);}}j.headers.not(j.active||"").next().hide();j.active.parent().andSelf().addClass(j.selectedClass);if(j.event){this.element.bind((j.event)+".accordion",b);}},activate:function(g){b.call(this.element[0],{target:e(this.options.headers,g)[0]});},destroy:function(){this.options.headers.next().css("display","");
if(this.options.fillSpace||this.options.autoHeight){this.options.headers.next().css("height","");}c.removeData(this.element[0],"accordion");this.element.removeClass("ui-accordion").unbind(".accordion");}});function f(g,h){return function(){return g.apply(h,arguments);};}function d(g){if(!c.data(this,"accordion")){return;
}var i=c.data(this,"accordion");var h=i.options;h.running=g?0:--h.running;if(h.running){return;}if(h.clearStyle){h.toShow.add(h.toHide).css({height:"",overflow:""});}c(this).triggerHandler("accordionchange",[c.event.fix({type:"accordionchange",target:i.element[0]}),h.data],h.change);}function a(l,h,g,i,m){var j=c.data(this,"accordion").options;
j.toShow=l;j.toHide=h;j.data=g;var k=f(d,this);j.running=h.size()===0?l.size():h.size();if(j.animated){if(!j.alwaysOpen&&i){c.ui.accordion.animations[j.animated]({toShow:jQuery([]),toHide:h,complete:k,down:m,autoHeight:j.autoHeight});}else{c.ui.accordion.animations[j.animated]({toShow:l,toHide:h,complete:k,down:m,autoHeight:j.autoHeight});
}}else{if(!j.alwaysOpen&&i){l.toggle();}else{h.hide();l.show();}k(true);}}function b(g){var i=c.data(this,"accordion").options;if(i.disabled){return false;}if(!g.target&&!i.alwaysOpen){i.active.parent().andSelf().toggleClass(i.selectedClass);var j=i.active.next(),n={options:i,newHeader:jQuery([]),oldHeader:i.active,newContent:jQuery([]),oldContent:j},l=(i.active=c([]));
a.call(this,l,j,n);return false;}var h=c(g.target);h=c(h.parents(i.header)[0]||h);var k=h[0]==i.active[0];if(i.running||(i.alwaysOpen&&k)){return false;}if(!h.is(i.header)){return;}i.active.parent().andSelf().toggleClass(i.selectedClass);if(!k){h.parent().andSelf().addClass(i.selectedClass);}var l=h.next(),j=i.active.next(),n={options:i,newHeader:h,oldHeader:i.active,newContent:l,oldContent:j},m=i.headers.index(i.active[0])>i.headers.index(h[0]);
i.active=k?c([]):h;a.call(this,l,j,n,k,m);return false;}function e(g,h){return h!=undefined?typeof h=="number"?g.filter(":eq("+h+")"):g.not(g.not(h)):h===false?c([]):g.filter(":eq(0)");}c.extend(c.ui.accordion,{defaults:{selectedClass:"selected",alwaysOpen:true,animated:"slide",event:"click",header:"a",autoHeight:true,running:0,navigationFilter:function(){return this.href.toLowerCase()==location.href.toLowerCase();
}},animations:{slide:function(k,i){k=c.extend({easing:"swing",duration:300},k,i);if(!k.toHide.size()){k.toShow.animate({height:"show"},k);return;}var j=k.toHide.height(),h=k.toShow.height(),g=h/j;k.toShow.css({height:0,overflow:"hidden"}).show();k.toHide.filter(":hidden").each(k.complete).end().filter(":visible").animate({height:"hide"},{step:function(l){var m=(j-l)*g;
if(c.browser.msie||c.browser.opera){m=Math.ceil(m);}k.toShow.height(m);},duration:k.duration,easing:k.easing,complete:function(){if(!k.autoHeight){k.toShow.css("height","auto");}k.complete();}});},bounceslide:function(g){this.slide(g,{easing:g.down?"bounceout":"swing",duration:g.down?1000:200});},easeslide:function(g){this.slide(g,{easing:"easeinout",duration:700});
}}});c.fn.activate=function(g){return this.accordion("activate",g);};})(jQuery);
