/*
 * jQuery UI Accordion 1.6
 * 
 * Copyright (c) 2007 Jörn Zaefferer
 *
 * http://docs.jquery.com/UI/Accordion
 *
 * Dual licensed under the MIT and GPL licenses:
 *   http://www.opensource.org/licenses/mit-license.php
 *   http://www.gnu.org/licenses/gpl.html
 *
 * Revision: $Id: jquery.accordion.js 4876 2008-03-08 11:49:04Z joern.zaefferer $
 *
 */
(function(a){function b(a,b){return function(){return a.apply(b,arguments)}}function c(b){if(!a.data(this,"ui-accordion"))return;var c=a.data(this,"ui-accordion"),d=c.options;d.running=b?0:--d.running;if(d.running)return;d.clearStyle&&d.toShow.add(d.toHide).css({height:"",overflow:""}),a(this).triggerHandler("change.ui-accordion",[d.data],d.change)}function d(d,e,f,g,h){var i=a.data(this,"ui-accordion").options;i.toShow=d,i.toHide=e,i.data=f;var j=b(c,this);i.running=e.size()==0?d.size():e.size(),i.animated?!i.alwaysOpen&&g?a.ui.accordion.animations[i.animated]({toShow:jQuery([]),toHide:e,complete:j,down:h,autoheight:i.autoheight}):a.ui.accordion.animations[i.animated]({toShow:d,toHide:e,complete:j,down:h,autoheight:i.autoheight}):(!i.alwaysOpen&&g?d.toggle():(e.hide(),d.show()),j(!0))}function e(b){var c=a.data(this,"ui-accordion").options;if(c.disabled)return!1;if(!b.target&&!c.alwaysOpen){c.active.parent().andSelf().toggleClass(c.selectedClass);var e=c.active.next(),f={instance:this,options:c,newHeader:jQuery([]),oldHeader:c.active,newContent:jQuery([]),oldContent:e},g=c.active=a([]);return d.call(this,g,e,f),!1}var h=a(b.target);if(h.parents(c.header).length)while(!h.is(c.header))h=h.parent();var i=h[0]==c.active[0];if(c.running||c.alwaysOpen&&i)return!1;if(!h.is(c.header))return;c.active.parent().andSelf().toggleClass(c.selectedClass),i||h.parent().andSelf().addClass(c.selectedClass);var g=h.next(),e=c.active.next(),f={instance:this,options:c,newHeader:h,oldHeader:c.active,newContent:g,oldContent:e},j=c.headers.index(c.active[0])>c.headers.index(h[0]);return c.active=i?a([]):h,d.call(this,g,e,f,i,j),!1}function f(b,c){return c!=undefined?typeof c=="number"?b.filter(":eq("+c+")"):b.not(b.not(c)):c===!1?a([]):b.filter(":eq(0)")}a.ui=a.ui||{},a.fn.extend({accordion:function(b,c){var d=Array.prototype.slice.call(arguments,1);return this.each(function(){if(typeof b=="string"){var c=a.data(this,"ui-accordion");c[b].apply(c,d)}else a(this).is(".ui-accordion")||a.data(this,"ui-accordion",new a.ui.accordion(this,b))})},activate:function(a){return this.accordion("activate",a)}}),a.ui.accordion=function(b,c){this.options=c=a.extend({},a.ui.accordion.defaults,c),this.element=b,a(b).addClass("ui-accordion");if(c.navigation){var d=a(b).find("a").filter(c.navigationFilter);d.length&&(d.filter(c.header).length?c.active=d:(c.active=d.parent().parent().prev(),d.addClass("current")))}c.headers=a(b).find(c.header),c.active=f(c.headers,c.active);if(c.fillSpace){var g=a(b).parent().height();c.headers.each(function(){g-=a(this).outerHeight()});var h=0;c.headers.next().each(function(){h=Math.max(h,a(this).innerHeight()-a(this).height())}).height(g-h)}else if(c.autoheight){var g=0;c.headers.next().each(function(){g=Math.max(g,a(this).outerHeight())}).height(g)}c.headers.not(c.active||"").next().hide(),c.active.parent().andSelf().addClass(c.selectedClass),c.event&&a(b).bind(c.event+".ui-accordion",e)},a.ui.accordion.prototype={activate:function(a){e.call(this.element,{target:f(this.options.headers,a)[0]})},enable:function(){this.options.disabled=!1},disable:function(){this.options.disabled=!0},destroy:function(){this.options.headers.next().css("display",""),(this.options.fillSpace||this.options.autoheight)&&this.options.headers.next().css("height",""),a.removeData(this.element,"ui-accordion"),a(this.element).removeClass("ui-accordion").unbind(".ui-accordion")}},a.extend(a.ui.accordion,{defaults:{selectedClass:"selected",alwaysOpen:!0,animated:"slide",event:"click",header:"a",autoheight:!0,running:0,navigationFilter:function(){return this.href.toLowerCase()==location.href.toLowerCase()}},animations:{slide:function(b,c){b=a.extend({easing:"swing",duration:300},b,c);if(!b.toHide.size()){b.toShow.animate({height:"show"},b);return}var d=b.toHide.height(),e=b.toShow.height(),f=e/d;b.toShow.css({height:0,overflow:"hidden"}).show(),b.toHide.filter(":hidden").each(b.complete).end().filter(":visible").animate({height:"hide"},{step:function(c){var e=(d-c)*f;if(a.browser.msie||a.browser.opera)e=Math.ceil(e);b.toShow.height(e)},duration:b.duration,easing:b.easing,complete:function(){b.autoheight||b.toShow.css("height","auto"),b.complete()}})},bounceslide:function(a){this.slide(a,{easing:a.down?"bounceout":"swing",duration:a.down?1e3:200})},easeslide:function(a){this.slide(a,{easing:"easeinout",duration:700})}}})})(jQuery)
