/*
	FAQ JavaScript
	
	Created by cpruitt on 2006-09-05.
	Copyright (c) 2006 Cliff Pruitt. All rights reserved.
*/
/*==========  Variable Initialization  ==========*/

var ajaxController = 'ajax_controller.asp';

/*===============  App Functions  ===============*/

//...	Append the appInit() function to the 'window.onload' event
nmAppendOnload(appInit);

//...	This function is called when the window finishes loading
function appInit(){
	
	if(document.getElementsByClassName) {
		questionElems = $A(document.getElementsByClassName('qaQuestion'))
		questionElems.each(function(item, index){
			item.onclick = toggleAnswerElement.bind(item);
		})
	} else {
		alert('Missing Prototype Library.');
	}
	
	if(document.getElementsByClassName) {
		questionElems = $A(document.getElementsByClassName('faqCatName'))
		questionElems.each(function(item, index){
			item.onclick = toggleCatQuestionList.bind(item);
		})
	} else {
		alert('Missing Prototype Library.');
	}
	
}

function toggleAnswerElement() {
	nodes = $A(this.parentNode.getElementsByTagName('DIV'));
	nodes.each(function(item, index){
		if(item.className == 'qaAnswer'){
			item.style.display == 'none' ? item.style.display = 'block' : item.style.display = 'none';
		}
	})
}

function toggleCatQuestionList() {
	nodes = $A(this.parentNode.getElementsByTagName('ul'));
	nodes.each(function(item, index){
		item.style.display == 'none' ? item.style.display = 'block' : item.style.display = 'none';
	})
}
