/**
 *
 * @param id 		the id of the Program item to hide or show
 */
function toggleProgram(id, single) {	
		
	if(single) {
		//show only one program at a time
		toggleAll(false);		
		showHideProgram(id, true);
	}
	else {
		//open as many Program as you like		
		if(document.getElementById('program_'+id).style.display == 'none') {
			showHideProgram(id, true);
		}
		else {
			showHideProgram(id, false);
		}			
	}	
}

/**
 * shows or hides a Program item at a time depending on the given status
 *
 * @param id 		the id of the Program item to hide or show
 * @param status	true to show the item, false to hide it
 */
function showHideProgram(id, status) {
	var program_id = 'program_'+id; //answer
	var icon_id  = 'icon_'+id; // plus/minus icon
	
	if(status) {
		document.getElementById(program_id).style.display = 'inline';
		document.getElementById(icon_id).src = iconMinus;
	}
	else {
		document.getElementById(program_id).style.display = 'none';	
		document.getElementById(icon_id).src = iconPlus;
	}
}

/**
 * shows or hides all Program items with one click
 *
 * @param mode	true to show the items, false to hide them
 */
function toggleAll(mode) {
	
	
	var x = document.getElementsByTagName("dd");
	var htmlStr = "";
	var iconId = "";
	
	for (var i=0;i<x.length;i++)
	{
		iconId = x[i].id
		iconId = iconId.replace("program_", "icon_");
		if(mode) {
			x[i].style.display = 'inline';
			document.getElementById(iconId).src = iconMinus;
		}
		else {
			x[i].style.display = 'none';
			document.getElementById(iconId).src = iconPlus;	
		}
	}			
}

function toggleOld() {

var y = document.getElementById('icon_' + parseInt(x[i].id));
		for (var i=0;i<y.length;i++)
		{
			if(mode) {
				y[i].src = iconMinus;
			}
			else {
				y[i].src = iconPlus;	
			}
		}

	var x = document.getElementsByTagName("gg");
	for (var i=0;i<x.length;i++)
	{
		if(mode) {
			x[i].src = iconMinus;
		}
		else {
			x[i].src = iconPlus;
		}
	}
}
