if (Object.isUndefined(QORT)) { var QORT = { } };

QORT.Expander = Class.create({
	
	initialize: function(element, content) {
		this.element = $(element);
		if (!this.element) return;

		this.label = this.element.innerHTML;

		this.content = $(content);
		if (!this.content) return;
		this.expanded = (this.content.style.display == 'none') ? false : true;

		this.element.observe('click', this.show.bind(this));
	},
	
	show: function(e) {
		if (this.expanded) {
			this.content.hide();
			this.expanded = false;
			this.element.update(this.label);
		} else {
			this.content.show();
			this.expanded = true;
			this.element.update('Свернуть');
		}
		Event.stop(e);
	}
});

Event.observe(document, 'dom:loaded', function() {
	$$(".expander").each(function(item) {
		new QORT.Expander(item, 'content_' + item.id);
	});
});


