
(function(a)
{
a.ui=a.ui||{};
a.fn.extend({accordion:function(b)
{
var c=Array.prototype.slice.call(arguments,1);
return this.each(function()
{
if(typeof b=="string")
{
var d=a.data(this,"ui-accordion");
d[b].apply(d,c)
}
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(e,d)
{
this.options=d=a.extend({},a.ui.accordion.defaults,d);
this.element=e;
a(e).addClass("ui-accordion");
if(d.navigation)
{
var g=a(e).find("a").filter(d.navigationFilter);
if(g.length)
if(g.filter(d.header).length)
d.active=g;
else
{
d.active=g.parent().parent().prev();
g.addClass("current")
}
}
d.headers=a(e).find(d.header);
d.active=c(d.headers,d.active);
if(d.fillSpace)
{
var f=a(e).parent().height();
d.headers.each(function()
{
f-=a(this).outerHeight()
});
var h=0;
d.headers.next().each(function()
{
h=Math.max(h,a(this).innerHeight()-a(this).height())
}).height(f-h)
}
else
if(d.autoheight)
{
var f=0;
d.headers.next().each(function()
{
f=Math.max(f,a(this).outerHeight())
}).height(f)
}
d.headers.not(d.active||"").next().hide();
d.active.parent().andSelf().addClass(d.selectedClass);
d.event&&
a(e).bind(d.event+".ui-accordion",b)
};
a.ui.accordion.prototype={activate:function(a)
{
b.call(this.element,{target:c(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","");
(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")
}};
function e(a,b)
{
return function()
{
return a.apply(b,arguments)
}
}
function f(d)
{
if(!a.data(this,"ui-accordion"))
return;
var c=a.data(this,"ui-accordion"),
b=c.options;
b.running=d?0:--b.running;
if(b.running)
return;
b.clearStyle&&
b.toShow.add(b.toHide).css({height:"",overflow:""});
a(this).triggerHandler("change.ui-accordion",[b.data],b.change)
}
function d(d,c,j,h,i)
{
var b=a.data(this,"ui-accordion").options;
b.toShow=d;
b.toHide=c;
b.data=j;
var g=e(f,this);
b.running=c.size()==0?d.size():c.size();
if(b.animated)
if(!b.alwaysOpen&&h)
a.ui.accordion.animations[b.animated]({toShow:jQuery([]),toHide:c,complete:g,down:i,autoheight:b.autoheight});
else
a.ui.accordion.animations[b.animated]({toShow:d,toHide:c,complete:g,down:i,autoheight:b.autoheight});
else
{
if(!b.alwaysOpen&&h)
d.toggle();
else
{
c.hide();
d.show()
}
g(true)
}
}
function b(h)
{
var b=a.data(this,"ui-accordion").options;
if(b.disabled)
return false;
if(!h.target&&!b.alwaysOpen)
{
b.active.parent().andSelf().toggleClass(b.selectedClass);
var f=b.active.next(),
i={instance:this,options:b,newHeader:jQuery([]),oldHeader:b.active,newContent:jQuery([]),oldContent:f},
g=b.active=a([]);
d.call(this,g,f,i);
return false
}
var c=a(h.target);
if(c.parents(b.header).length)
while(!c.is(b.header))
c=c.parent();
var e=c[0]==b.active[0];
if(b.running||b.alwaysOpen&&e)
return false;
if(!c.is(b.header))
return;
b.active.parent().andSelf().toggleClass(b.selectedClass);
!e&&
c.parent().andSelf().addClass(b.selectedClass);
var g=c.next(),
f=b.active.next(),
i={instance:this,options:b,newHeader:c,oldHeader:b.active,newContent:g,oldContent:f},
j=b.headers.index(b.active[0])>b.headers.index(c[0]);
b.active=e?a([]):c;
d.call(this,g,f,i,e,j);
return false
}
function c(c,b)
{
return b!=undefined?typeof b=="number"?c.filter(":eq("+b+")"):c.not(c.not(b)):b===false?a([]):c.filter(":eq(0)")
}
a.extend(a.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(b,f)
{
b=a.extend({easing:"swing",duration:300},b,f);
if(!b.toHide.size())
{
b.toShow.animate({height:"show"},b);
return
}
var c=b.toHide.height(),
e=b.toShow.height(),
d=e/c;
b.toShow.css({height:0,overflow:"hidden"}).show();
b.toHide.filter(":hidden").each(b.complete).end().filter(":visible").animate({height:"hide"},{step:function(f)
{
var e=(c-f)*d;
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)
