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