/**
 * 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
 */
function toggleFaq(id, single, hash, row) {	
		
	if(single) {
		//show only one Q+A at a time
		toggleAll(false, hash);		
		showHideFaq(id, true, hash, row);
	}
	else {
		//open as many Q+A as you like		
		if(document.getElementById('irfaq_a_'+id+'_'+hash).style.display == 'none') {
			showHideFaq(id, true, hash, row);
		}
		else {
			showHideFaq(id, false, hash, row);
		}			
	}	
}

/**
 * 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, hash, row) {
	var faq_id = 'irfaq_a_'+id+'_'+hash; //answer
	var faqdiv_id =  'irfaq_div_'+id+'_'+hash; //divid
	
	if(status) {
		document.getElementById(faq_id).style.display = 'inline';
		document.getElementById(faqdiv_id).className = 'faq-item '+row+' active';
	}
	else {
		document.getElementById(faq_id).style.display = 'none';	
		document.getElementById(faqdiv_id).className = 'faq-item '+row;
	}
}

/**
 * shows or hides all FAQ items with one click
 *
 * @param mode	true to show the items, false to hide them
 */
function toggleAll(mode, hash, count) {
	for(i = 0; i < count; i++) {
		//modulo
		var row = 'row'+ i % 2;
		showHideFaq(i+1, mode, hash, row);
	}				
}

