Accordian = Class.create();
Accordian.prototype = {
	initialize: function(elem, clickableEntity) {
		this.container = $(elem);
		var headers = $$('.right_content_alertbox2 .bg .accordion .accordionheader');
		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('accordionelement',section);
                // contents[0].show();
                Effect.SlideDown(contents[0]);
                contents[0].style.height='auto';
                contents[0].style.overflow = 'visible';
            } else {
                this.closeExistingSection();
            }
        },
        closeExistingSection: function() {
            if(this.currentSection) {
            var contents = document.getElementsByClassName('accordionelement',this.currentSection);
            //contents[0].style.height="0px";
           contents[0].style.overflow = "auto"; 
            Effect.SlideUp(contents[0]);
            this.currentSection = null
            // contents[0].hide(); // no need to hide anymore
            }
        }
}


		Event.observe(window,'load',init,false);
		function init() {

                        accordian = new Accordian('right_content_alert_box2','accordionelement')
		}
