var whichOpen, fixedHeight;
Event.observe(window, 'load', function()
{
	var togglers = $$('.accordion_toggle');
	var contents = $$('.accordion_content');

	Fx.Accordion.addMethods({
		__hide_all: function()
		{
			this.__prev_index = null;
			if(this.previousClick != 'nan') {
				this.__prev_index = this.previousClick;
			}
			this.elements.each(function(el, key){
				if(this.__prev_index != key) {
					el.hide();
				}
			}.bind(this));
		},
		__click: function(ind) {
			this.__prev_index = ind;
		}
	});

	var acc = new Fx.Accordion(togglers, contents, {
		start: !Object.isUndefined(whichOpen) ? whichOpen : null,
		fixedHeight: !Object.isUndefined(fixedHeight) ? fixedHeight : false,
		onComplete: function() {
			if( this.__prev_index != null
				&& this.__prev_index != this.previousClick) {
				this.elements[this.__prev_index].hide();
			}
			this.__click(this.previousClick);
		},

		onActive: function(el) {
			this.togglers.each(function(elNew) {
				elNew.removeClassName('active');
			});
			el.addClassName('active');
		}
	});
	acc.__hide_all();
});
