/******************************************
 * The CMS Collapsible List Class
 *
 * For showing/hiding FAQ answers & other lists.
 ******************************************/

if (typeof crumbs == "undefined" || !crumbs) {
    var crumbs = {};
}

crumbs.CollapsibleList = Class.create({
	/**
	 * Constructor
	 *
	 * @param string containerId: the ID of the container element
	 */
	initialize: function (containerId) {
		this.container = $(containerId);
		this.items = $$("#" + containerId + " p > a");
		for (var i = 0; i < this.items.length; i++) {
			this.items[i].addClassName("collapser");
			Event.observe(this.items[i], "click", this.showHideItem);
		}
	},

	/**
	 * Shows or hides the item span.
	 *
	 * @param Event e
	 */
	showHideItem: function (e) {
		var parent = $(this.parentNode);
		if (parent.hasClassName("open"))
			parent.removeClassName("open");
		else
			parent.addClassName("open");
	}
});