/**
 * toggle Heading Items
 *
 * @param id 		the id of the Course 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 toggleHeading(id, single, hash, typeheading) {	
		
	if(single) {
		//show only one Q+A at a time
		toggleAll(false, hash);		
		showHideHeading(id, true, hash);
	}
	else {
		//open as many Q+A as you like		
		if(document.getElementById('igsideheading_a_'+id+'_'+hash).style.display == 'none') {
			changeStyleHeading(id, true, hash, typeheading);
			showHideHeading(id, true, hash);
		}
		else {
			changeStyleHeading(id, false, hash, typeheading);
			showHideHeading(id, false, hash);
		}			
	}	
}

function changeStyleHeading(id, status, hash, typeheading) {
	if(typeheading == 'menu')
	{
		if(status)
		{
			filepath = 'url("fileadmin/templates/images/arrow_menu_hover.gif") no-repeat 0px 2px;';
		}
		else
		{
			filepath = 'url("fileadmin/templates/images/arrow_menu_no.gif") no-repeat 0px 2px;';
		}
	}
	else
	{
		if(status)
		{
			filepath = 'url("fileadmin/templates/images/arrow_content_hover.gif") no-repeat 0px 2px;';
		}
		else
		{
			filepath = 'url("fileadmin/templates/images/arrow_content_no.gif") no-repeat 0px 2px;';
		}
	}
	
	document.getElementById('igsideheading_'+id+'_'+hash).style.background = filepath;
	
	
	
}

/**
 * shows or hides a Heading item at a time depending on the given status
 *
 * @param id 		the id of the Heading item to hide or show
 * @param status	true to show the item, false to hide it
 */
function showHideHeading(id, status, hash) {
	var heading_id = 'igsideheading_a_'+id+'_'+hash; //answer
	var pm_id  = 'igsideheading_pm_'+id+'_'+hash; // plus/minus icon
	
	if(status) {
		document.getElementById(heading_id).style.display = 'block';
	}
	else {
		document.getElementById(heading_id).style.display = 'none';	
	}
}

/**
 * shows or hides all Course Management 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++) {
		showHideHeading(i+1, mode, hash);
	}				
}