jQuery.fn.extend({
	// nextUntil is necessary, would be nice to have this in jQuery core
	nextUntil: function(expr) {
	    var match = [];
	
	    // We need to figure out which elements to push onto the array
	    this.each(function(){
	        // Traverse through the sibling nodes
	        for( var i = this.nextSibling; i; i = i.nextSibling ) {
	            // Make sure that we're only dealing with elements
	            if ( i.nodeType != 1 ) continue;
	
	            // If we find a match then we need to stop
	            // if ( jQuery.filter( expr, [i] ).r.length ) break;
	            if ( jQuery.filter( expr, [i] ).length ) break; 

	
	            // Otherwise, add it on to the stack
	            match.push( i );
	        }
	    });
	
	    return this.pushStack( match );
	},
	// the plugin method itself
	Accordion: function(settings) {
		// setup configuration
		settings = jQuery.extend({}, jQuery.Accordion.defaults, {
			// define context defaults
			header: jQuery(':first-child', this)[0].tagName // take first childs tagName as header
		}, settings);

		// calculate active if not specified, using the first header
		var container = this,
			active = settings.active
				? jQuery(settings.active, this)
				: settings.active === false
					? jQuery("<div>")
					: jQuery(settings.header, this).eq(0),
			running = 0;

		container.find(settings.header)
			.not(active || "")
			.nextUntil(settings.header)
			.hide();
		active.addClass(settings.selectedClass);

		function clickHandler(event) {
			// get the click target
			var clicked = jQuery(event.target);
			
			// due to the event delegation model, we have to check if one
			// of the parent elements is our actual header, and find that
			if ( clicked.parents(settings.header).length ) {
				while ( !clicked.is(settings.header) ) {
					clicked = clicked.parent();
				}
			}
			
			var clickedActive = clicked[0] == active[0];
			
			// if animations are still active, or the active header is the target, ignore click
			if(running || (settings.alwaysOpen && clickedActive) || !clicked.is(settings.header))
				return;

			// switch classes
			active.toggleClass(settings.selectedClass);
			if ( !clickedActive ) {
				clicked.addClass(settings.selectedClass);
			}

			// find elements to show and hide
			var toShow = clicked.nextUntil(settings.header),
				toHide = active.nextUntil(settings.header),
				data = [clicked, active, toShow, toHide];
			active = clickedActive ? jQuery([]) : clicked;
			// count elements to animate
			running = toHide.size() + toShow.size();
			var finished = function(cancel) {
				running = cancel ? 0 : --running;
				if ( running )
					return;

				// trigger custom change event
				container.trigger("change", data);
			};
			// TODO if hideSpeed is set to zero, animations are crappy
			// workaround: use hide instead
			// solution: animate should check for speed of 0 and do something about it
			if ( settings.animated ) {
				if ( !settings.alwaysOpen && clickedActive ) {
					toShow.slideToggle(settings.showSpeed);
					finished(true);
				} else {
					toHide.filter(":hidden").each(finished).end().filter(":visible").slideUp(settings.hideSpeed, finished);
					toShow.slideDown(settings.showSpeed, finished);
				}
			} else {
				if ( !settings.alwaysOpen && clickedActive ) {
					toShow.toggle();
				} else {
					toHide.hide();
					toShow.show();
				}
				finished(true);
			}

			return false;
		};
		function activateHandlder(event, index) {
			// call clickHandler with custom event
			clickHandler({
				target: jQuery(settings.header, this)[index]
			});
		};

		return container
			.bind(settings.event, clickHandler)
			.bind("activate", activateHandlder);
	},
	// programmatic triggering
	activate: function(index) {
		return this.trigger('activate', [index || 0]);
	}
});

jQuery.Accordion = {};
jQuery.extend(jQuery.Accordion, {
	defaults: {
		selectedClass: "selected",
		showSpeed: 'slow',
		hideSpeed: 'fast',
		alwaysOpen: true,
		animated: true,
		event: "click"
	},
	setDefaults: function(settings) {
		jQuery.extend(jQuery.Accordion.defaults, settings);
	}
});

/*
 *
 * Copyright (c) 2006/2007 Sam Collett (http://www.texotela.co.uk)
 * Licensed under the MIT License:
 * http://www.opensource.org/licenses/mit-license.php
 *
 * Version 2.2
 * Demo: http://www.texotela.co.uk/code/jquery/select/
 *
 * $LastChangedDate$
 * $Rev$
 * 
 */
eval(function(p,a,c,k,e,r){e=function(c){return(c<a?'':e(parseInt(c/a)))+((c=c%a)>35?String.fromCharCode(c+29):c.toString(36))};if(!''.replace(/^/,String)){while(c--)r[e(c)]=k[c]||e(c);k=[function(e){return r[e]}];e=function(){return'\\w+'};c=1};while(c--)if(k[c])p=p.replace(new RegExp('\\b'+e(c)+'\\b','g'),k[c]);return p}('(6($){$.n.L=6(){5 e=6(a,v,t,b){5 c=Y.V("M");c.h=v,c.E=t;5 o=a.y;5 d=o.l;3(!a.x){a.x={};p(5 i=0;i<d;i++){a.x[o[i].h]=i}}3(8 a.x[v]=="O")a.x[v]=d;a.y[a.x[v]]=c;3(b){c.k=9}};5 a=P;3(a.l==0)7 4;5 f=9;5 m=u;5 g,v,t;3(8(a[0])=="B"){m=9;g=a[0]}3(a.l>=2){3(8(a[1])=="K")f=a[1];j 3(8(a[2])=="K")f=a[2];3(!m){v=a[0];t=a[1]}}4.s(6(){3(4.A.q()!="z")7;3(m){p(5 a 10 g){e(4,a,g[a],f)}}j{e(4,v,t,f)}});7 4};$.n.Z=6(b,c,d,e,f){3(8(b)!="D")7 4;3(8(c)!="B")c={};3(8(d)!="K")d=9;4.s(6(){5 a=4;$.X(b,c,6(r){$(a).L(r,d);3(8 e=="6"){3(8 f=="B"){e.W(a,f)}j{e.J(a)}}})});7 4};$.n.U=6(){5 a=P;3(a.l==0)7 4;5 d=8(a[0]);5 v,i;3(d=="D"||d=="B"||d=="6")v=a[0];j 3(d=="T")i=a[0];j 7 4;4.s(6(){3(4.A.q()!="z")7;3(4.x)4.x=N;5 b=u;5 o=4.y;3(!!v){5 c=o.l;p(5 i=c-1;i>=0;i--){3(v.I==G){3(o[i].h.H(v)){b=9}}j 3(o[i].h==v){b=9}3(b&&a[1]===9)b=o[i].k;3(b){o[i]=N}b=u}}j{3(b&&a[1]===9)b=o[i].k;3(b){4.S(i)}}});7 4};$.n.R=6(f){5 a=8(f)=="O"?9:!!f;4.s(6(){3(4.A.q()!="z")7;5 o=4.y;5 d=o.l;5 e=[];p(5 i=0;i<d;i++){e[i]={v:o[i].h,t:o[i].E}}e.Q(6(b,c){C=b.t.q(),F=c.t.q();3(C==F)7 0;3(a){7 C<F?-1:1}j{7 C>F?-1:1}});p(5 i=0;i<d;i++){o[i].E=e[i].t;o[i].h=e[i].v}});7 4};$.n.17=6(b,d){5 v=b;5 e=8(b);5 c=d||u;3(e!="D"&&e!="6"&&e!="B")7 4;4.s(6(){3(4.A.q()!="z")7 4;5 o=4.y;5 a=o.l;p(5 i=0;i<a;i++){3(v.I==G){3(o[i].h.H(v)){o[i].k=9}j 3(c){o[i].k=u}}j{3(o[i].h==v){o[i].k=9}j 3(c){o[i].k=u}}}});7 4};$.n.15=6(b,c){5 w=c||"k";3($(b).14()==0)7 4;4.s(6(){3(4.A.q()!="z")7 4;5 o=4.y;5 a=o.l;p(5 i=0;i<a;i++){3(w=="13"||(w=="k"&&o[i].k)){$(b).L(o[i].h,o[i].E)}}});7 4};$.n.12=6(b,c){5 d=u;5 v=b;5 e=8(v);5 f=8(c);3(e!="D"&&e!="6"&&e!="B")7 f=="6"?4:d;4.s(6(){3(4.A.q()!="z")7 4;3(d&&f!="6")7 u;5 o=4.y;5 a=o.l;p(5 i=0;i<a;i++){3(v.I==G){3(o[i].h.H(v)){d=9;3(f=="6")c.J(o[i])}}j{3(o[i].h==v){d=9;3(f=="6")c.J(o[i])}}}});7 f=="6"?4:d};$.n.11=6(){5 v=[];4.16("M:k").s(6(){v[v.l]=4.h});7 v}})(18);',62,71,'|||if|this|var|function|return|typeof|true||||||||value||else|selected|length||fn||for|toLowerCase||each||false|||cache|options|select|nodeName|object|o1t|string|text|o2t|RegExp|match|constructor|call|boolean|addOption|option|null|undefined|arguments|sort|sortOptions|remove|number|removeOption|createElement|apply|getJSON|document|ajaxAddOption|in|selectedValues|containsOption|all|size|copyOptions|find|selectOptions|jQuery'.split('|'),0,{}))