
/**
 * uses prototype.js
 *
 * -> more information on http://www.prototypejs.org/api/
 */

// add the event for switching from open to closed to all sectionFrame6 elements
function faqInit(event) {
	faqElements = $$('div.sectionFrame6 h4');
	for(var i=0; i < faqElements.length; i++) {
		Event.observe(faqElements[i], 'click', faqSwitch);
	}
}

// switch the clicked element and close all others
function faqSwitch(event) {
	
	// if the user clicked on a closed element, close all and open this
	if(Element.hasClassName(this.parentNode, 'sectionFrame6')) {
		faqElements = $$('div.sectionFrame6Open h4');
		
		for(var i=0; i < faqElements.length; i++) {
			Element.removeClassName(faqElements[i].parentNode, 'sectionFrame6Open');
			Element.addClassName(faqElements[i].parentNode, 'sectionFrame6');
		}
		
		Element.removeClassName(this.parentNode, 'sectionFrame6');
		Element.addClassName(this.parentNode, 'sectionFrame6Open');
		
	// if the user clicked on a open element, close this
	} else {
		Element.removeClassName(this.parentNode, 'sectionFrame6Open');
		Element.addClassName(this.parentNode, 'sectionFrame6');
	}
}

// run faqInit as soon as the page is ready
Event.observe(window, 'load', faqInit);
