/** global variables */
var single = true; //true to show only one item at a time, false the open as many as you want
var count = 0; // number of questions
/**
 * toggle FAQ Items
 *
 * @param id 		the id of the FAQ item to hide or show
 * @global single (true to show only one item at a time, false the open as many as you want)
 */
function toggleFaq(id) {	
	single = true;
	if(single) {
		//show only one Q+A at a time
		toggleAll(false);		
		showHideFaq(id, true);
	}
	else {
		//open as many Q+A as you like		
		if(document.getElementById('faq_a_'+id).style.display == 'none') {
			showHideFaq(id, true);
		}
		else {
			showHideFaq(id, false);
		}			
	}	
}

/**
 * shows or hides a FAQ item at a time depending on the given status
 *
 * @param id 		the id of the FAQ item to hide or show
 * @param status	true to show the item, false to hide it
 */
function showHideFaq(id, status) {
	var answer_id = 'faq_a_'+id; //answer
	var question_id = 'faq_f_'+id; //answer
	//var pm_id  = 'irfaq_pm_'+id+'_'+hash; // plus/minus icon
	
	if(status) {
		document.getElementById(answer_id).style.display = 'inline';
		document.getElementById(question_id).getElementsByTagName("td")[0].getElementsByTagName("span")[0].style.color = "#FFFFFF";
		document.getElementById(question_id).getElementsByTagName("td")[1].style.color = "#FFFFFF";
		document.getElementById(question_id).getElementsByTagName("td")[2].style.color = "#FFFFFF";
		document.getElementById(question_id).getElementsByTagName("td")[2].getElementsByTagName("img")[0].src= "img/arrow_faq_down.gif";

		//document.getElementById(pm_id).src = tx_irfaq_pi1_iconMinus;
	}
	else {
		document.getElementById(answer_id).style.display = 'none';	
		document.getElementById(question_id).getElementsByTagName("td")[0].getElementsByTagName("span")[0].style.color = "#004a15";
		document.getElementById(question_id).getElementsByTagName("td")[1].style.color = "#004a15";
		document.getElementById(question_id).getElementsByTagName("td")[2].style.color = "#004a15";
		document.getElementById(question_id).getElementsByTagName("td")[2].getElementsByTagName("img")[0].src= "img/arrow_faq_right.gif";
		//document.getElementById(pm_id).src = tx_irfaq_pi1_iconPlus;
	}
}

/**
 * shows or hides all FAQ items with one click
 *
 * @param mode	true to show the items, false to hide them
 * @global count (number of faqs)
 */
function toggleAll(mode) {
	for(i = 0; i < count; i++) {
		showHideFaq(i+1, mode);
	}				
}
