/**
 * toggle div items
 *
 * @param prefix	the prefix of the div item to hide or show
 * @param id 		the id of the div 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 toggleDiv(prefix, id, single) {
	if(single) {
		//show only one div at a time
		toggleDivAll(prefix, false);		
		showHideDiv(prefix, id, true);
	}
	else {
		//open as many as you like
		if(document.getElementById(prefix+id).style.display == 'none') {
			showHideDiv(prefix, id, true);
		}
		else {
			showHideDiv(prefix, id, false);
		}			
	}	
}

/**
 * shows or hides all divs items with one click
 *
 * @param prefix	the prefix of the div item to hide or show
 * @param mode		true to show the items, false to hide them
 */
function toggleDivAll(prefix, mode) {
	
	var i = 1;
	while(showHideDiv(prefix, i, mode)) {
		i++
	}				
}

/**
 * shows or hides a div item at a time depending on the given status
 *
 * @param prefix	the prefix of the div item to hide or show
 * @param id 		the id of the div item to hide or show
 * @param status	true to show the item, false to hide it
 */
function showHideDiv(prefix, id, mode) {
	var div_id = prefix+id; //answer
	//var icon_id  = prefix+id; // plus/minus icon
	
	if(document.getElementById(div_id)==null)
		return false;
	
	if(mode==null)
		mode = !(document.getElementById(div_id).style.display == 'none');
	
	if(mode) {
		document.getElementById(div_id).style.display = 'block';
		//document.getElementById(icon_id).src = prefix+"_iconMinus";
	}
	else {
		document.getElementById(div_id).style.display = 'none';	
		//document.getElementById(icon_id).src = prefix+"_iconPlus";
	}
	
	return true;
}


