/**
 * toggle FAQ Items
 *
 * @param id 		the id of the FAQ item to hide or show
 * @param single	true to show only one item at a time, false the open as many as you want
 */
/*****************************************
 * Edit by: Eat Dimanche
 * Position: Web programming(Yejj Intern)
 * Email: eat.dimanche@yejj.com
 * Start date: 20/08/2009
 * End date: 02/09/2009
 *****************************************/
function tx_irfaq_toggleFaq(id, single, hash) {
	if (single) {
		// show only one Q+A at a time
		tx_irfaq_toggleAll(false, hash);
		tx_irfaq_showHideFaq(id, true, hash, 0);
	}
	else {
		// open as many Q+A as you like
		var hidden = (document.getElementById('irfaq_a_'+id+'_'+hash).className == 'tx-irfaq-dynans-hidden');
		tx_irfaq_showHideFaq(id, hidden, hash, 1);			
	}
}

/**
 * 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 show	true to show the item, false to hide it
 */
function tx_irfaq_showHideFaq(id, show, hash, visible_q) {	
	var faq_id = 'irfaq_a_'+id+'_'+hash; //answer
	var pm_id  = 'irfaq_pm_'+id+'_'+hash; // plus/minus icon
	var faq_q_id = 'irfaq_q_'+id+'_'+hash;

	if (show) {
		document.getElementById(faq_id).className = 'tx-irfaq-dynans-visible';
		document.getElementById(pm_id).src = tx_irfaq_pi1_iconMinus;
		if(!visible_q) document.getElementById(faq_q_id).className = 'tx-irfaq-dynheader-visible'; 
			// Visible all question in the of each category
	}
	else {
		document.getElementById(faq_id).className = 'tx-irfaq-dynans-hidden';
		document.getElementById(pm_id).src = tx_irfaq_pi1_iconPlus;
		if(!visible_q) document.getElementById(faq_q_id).className = 'tx-irfaq-dynheader-hidden'; 
			// Hidden all question in the of each category
	}
}

/**
 * shows or hides all FAQ items with one click
 *
 * @param mode	true to show the items, false to hide them
 */
function tx_irfaq_toggleAll(mode, hash, count, count_cat_img) {	
	for (i = 0; i < count; i++) {
		tx_irfaq_showHideFaq(i+1, mode, hash, 0);
		if(i < count_cat_img) tx_irfaq_showHide_cat_img(i+1, mode);
	}
}
function tx_irfaq_toggleFaq_by_category(id, hash, count_q, img_id) { 
	var hidden = (document.getElementById('irfaq_q_'+id+'_'+hash).className == 'tx-irfaq-dynheader-hidden');
	var count_condition = parseInt(id) + parseInt(count_q);
	tx_irfaq_showHide_cat_img(img_id, hidden);
	for(i = id; i < count_condition; i++){
		tx_irfaq_showHideFaq_by_category(i, hidden, hash);
	}	
}
function tx_irfaq_showHideFaq_by_category(id, show, hash) {
	var faq_q_id = 'irfaq_q_'+id+'_'+hash; //answer
	var pm_q_id  = 'irfaq_pm_'+id+'_'+hash; // plus/minus icon
	var faq_a_id = 'irfaq_a_'+id+'_'+hash; //answer

	if (show) {
		document.getElementById(faq_q_id).className = 'tx-irfaq-dynheader-visible';
	}
	else {
		document.getElementById(faq_q_id).className = 'tx-irfaq-dynheader-hidden';		
		document.getElementById(faq_a_id).className = 'tx-irfaq-dynans-hidden';
		document.getElementById(pm_q_id).src = tx_irfaq_pi1_iconPlus;
	}
}
function tx_irfaq_showHide_cat_img(img_id, show) {
	var faq_img = 'img_irfaq_'+img_id;
	if(show) {
		document.getElementById(faq_img).src = tx_irfaq_pi1_iconMinus;
	}
	else{
		document.getElementById(faq_img).src = tx_irfaq_pi1_iconPlus;
	}
}