Accordian = Class.create();
Accordian.prototype = {
	initialize: function(elem, clickableEntity) {
		this.container = $(elem);
		var headers = $$('#' + elem + ' .section ' + clickableEntity);
		headers.each(function(header) {
			Event.observe(header,'click',this.sectionClicked.bindAsEventListener(this));
		}.bind(this));
	},

	sectionClicked: function(event) {
			this.openSection(Event.element(event).parentNode);
		},
		openSection: function(section) {
			var section = $(section);
			if(section.id != this.currentSection) {
                this.closeExistingSection();
                this.currentSection = section.id;
                var contents = document.getElementsByClassName('contents',section);
				Effect.BlindDown(contents[0], { queue: 'end', duration:0.25});
				  //                  contents[0].show();
              }
		},
		closeExistingSection: function() {
			if(this.currentSection) {
				var contents = document.getElementsByClassName('contents',this.currentSection);
				Effect.BlindUp(contents[0], { queue: 'front', duration:0.25});
				//contents[0].hide();
			}
		}
}

