(function(E){E.ui=E.ui||{};
E.fn.extend({accordion:function(H,I){var G=Array.prototype.slice.call(arguments,1);
return this.each(function(){if(typeof H=="string"){var J=E.data(this,"ui-accordion");
J[H].apply(J,G)
}else{if(!E(this).is(".ui-accordion")){E.data(this,"ui-accordion",new E.ui.accordion(this,H))
}}})
},activate:function(G){return this.accordion("activate",G)
}});
E.ui.accordion=function(G,H){this.options=H=E.extend({},E.ui.accordion.defaults,H);
this.element=G;
E(G).addClass("ui-accordion");
if(H.navigation){var K=E(G).find("a").filter(H.navigationFilter);
if(K.length){if(K.filter(H.header).length){H.active=K
}else{H.active=K.parent().parent().prev();
K.addClass("current")
}}}H.headers=E(G).find(H.header);
H.active=C(H.headers,H.active);
if(H.fillSpace){var J=E(G).parent().height();
H.headers.each(function(){J-=E(this).outerHeight()
});
var I=0;
H.headers.next().each(function(){I=Math.max(I,E(this).innerHeight()-E(this).height())
}).height(J-I)
}else{if(H.autoheight){var J=0;
H.headers.next().each(function(){J=Math.max(J,E(this).outerHeight())
}).height(J)
}}H.headers.not(H.active||"").next().hide();
H.active.parent().andSelf().addClass(H.selectedClass);
if(H.event){E(G).bind((H.event)+".ui-accordion",F)
}};
E.ui.accordion.prototype={activate:function(G){F.call(this.element,{target:C(this.options.headers,G)[0]})
},enable:function(){this.options.disabled=false
},disable:function(){this.options.disabled=true
},destroy:function(){this.options.headers.next().css("display","");
if(this.options.fillSpace||this.options.autoheight){this.options.headers.next().css("height","")
}E.removeData(this.element,"ui-accordion");
E(this.element).removeClass("ui-accordion").unbind(".ui-accordion")
}};
function B(H,G){return function(){return H.apply(G,arguments)
}
}function D(I){if(!E.data(this,"ui-accordion")){return 
}var G=E.data(this,"ui-accordion");
var H=G.options;
H.running=I?0:--H.running;
if(H.running){return 
}if(H.clearStyle){H.toShow.add(H.toHide).css({height:"",overflow:""})
}E(this).triggerHandler("change.ui-accordion",[H.data],H.change)
}function A(G,K,L,J,M){var I=E.data(this,"ui-accordion").options;
I.toShow=G;
I.toHide=K;
I.data=L;
var H=B(D,this);
I.running=K.size()==0?G.size():K.size();
if(I.animated){if(!I.alwaysOpen&&J){E.ui.accordion.animations[I.animated]({toShow:jQuery([]),toHide:K,complete:H,down:M,autoheight:I.autoheight})
}else{E.ui.accordion.animations[I.animated]({toShow:G,toHide:K,complete:H,down:M,autoheight:I.autoheight})
}}else{if(!I.alwaysOpen&&J){G.toggle()
}else{K.hide();
G.show()
}H(true)
}}function F(L){var J=E.data(this,"ui-accordion").options;
if(J.disabled){return false
}if(!L.target&&!J.alwaysOpen){J.active.parent().andSelf().toggleClass(J.selectedClass);
var I=J.active.next(),M={instance:this,options:J,newHeader:jQuery([]),oldHeader:J.active,newContent:jQuery([]),oldContent:I},G=J.active=E([]);
A.call(this,G,I,M);
return false
}var K=E(L.target);
if(K.parents(J.header).length){while(!K.is(J.header)){K=K.parent()
}}var H=K[0]==J.active[0];
if(J.running||(J.alwaysOpen&&H)){return false
}if(!K.is(J.header)){return 
}J.active.parent().andSelf().toggleClass(J.selectedClass);
if(!H){K.parent().andSelf().addClass(J.selectedClass)
}var G=K.next(),I=J.active.next(),M={instance:this,options:J,newHeader:K,oldHeader:J.active,newContent:G,oldContent:I},N=J.headers.index(J.active[0])>J.headers.index(K[0]);
J.active=H?E([]):K;
A.call(this,G,I,M,H,N);
return false
}function C(H,G){return G!=undefined?typeof G=="number"?H.filter(":eq("+G+")"):H.not(H.not(G)):G===false?E([]):H.filter(":eq(0)")
}E.extend(E.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(G,I){G=E.extend({easing:"swing",duration:300},G,I);
if(!G.toHide.size()){G.toShow.animate({height:"show"},G);
return 
}var H=G.toHide.height(),J=G.toShow.height(),K=J/H;
G.toShow.css({height:0,overflow:"hidden"}).show();
G.toHide.filter(":hidden").each(G.complete).end().filter(":visible").animate({height:"hide"},{step:function(L){var M=(H-L)*K;
if(E.browser.msie||E.browser.opera){M=Math.ceil(M)
}G.toShow.height(M)
},duration:G.duration,easing:G.easing,complete:function(){if(!G.autoheight){G.toShow.css("height","auto")
}G.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})
}}})
})(jQuery);
