/* .js file to expand/contract divs */

// need to hide everything that's not a top-level element 
// get all the document elements of name like node999.. and close all the child ones

/*var menu_status = new Array();
function ShowDiv(theid,iid)	// if rollback take out these parameters
{
	alert('ok');

}*/

var menu_status = new Array();

function showHide(theid,iid)	// if rollback take out these parameters
{
	if (document.getElementById) 
	{
		var switch_id = document.getElementById(theid);
		var img_ID = document.getElementById(iid);
		if(menu_status[theid] != 'show')
		{
			switch_id.className = 'show';
			img_ID.src='cssimages/collapse.gif'; // - sign
			menu_status[theid] = 'show';
		}
		else
		{
			switch_id.className = 'hide';
			img_ID.src='cssimages/expand.gif'; // + sign
			menu_status[theid] = 'hide';
		}
		
	}

} 


	/*
	// first parameter is always the current node's id.  all other parameters are the list of child nodes to expand/contract
	if (arguments.length > 1)	// there are some nodes
	{
		for (var i = 1; i < arguments.length; i++)	
		// loop through all the nodes passed in as arguments, i.e. all the child nodes of the one that was clicked on
		{
			// the element to expand: 
			var change = document.getElementById('node'+arguments[i]);
			
			// toggle it open/shut
			if (change.style.display == "none")
				change.style.display = "block";	// show it
			else
				change.style.display = "none";	// hide it
		}
		
		// need to change the text (and the title attribute if possible) of the node that was clicked on
		// if we were doing this with images, change the img.src instead of the innerHTML would probably be better
		// using indexOf, because IE has a bug with innerHTML; it trims leading spaces.  the value is actually ' + ' or ' - ', so doesn't work!  so indexOf just tells us if the string contains a + sign, which will have to do
		if (document.getElementById('expand'+arguments[0]).innerHTML.indexOf("+") != -1) 
			document.getElementById('expand'+arguments[0]).innerHTML = " - ";	// contract icon
		else
			document.getElementById('expand'+arguments[0]).innerHTML = " + ";	// expand icon
	}
	*/
	
function closeAll()
{
	// close all the nodes apart from the ones at the top level, and all the nodes upwards of the current page
	if (arguments.length)	// there are some nodes
	{
		for (var i = 0; i < arguments.length; i++)	
		// loop through all the nodes passed in as arguments
		{
			if (document.getElementById('node'+arguments[i]))
			{
				
				//document.getElementById('node'+arguments[i]).style.display = "none";
				document.getElementById('node'+arguments[i]).className = 'hide';
				
			//if (document.getElementById('expand'+arguments[i]))
			//	document.getElementById('expand'+arguments[i]).innerHTML = " + ";
			}
			if (document.getElementById('expand'+arguments[i]))
			{
				document.getElementById('expand'+arguments[i]).src='cssimages/expand.gif'; // + sign
			}
		}
	}
}

function openAll()
{
	// open all the nodes apart from the ones at the top level, and all the nodes upwards of the current page
	if (arguments.length)	// there are some nodes
	{
		for (var i = 0; i < arguments.length; i++)	
		// loop through all the nodes passed in as arguments
		{
			if (document.getElementById('node'+arguments[i]))
			{
				//alert('node'+arguments[i]);
				//document.getElementById('node'+arguments[i]).style.display = "block";
				document.getElementById('node'+arguments[i]).className = 'show';
			
			//if (document.getElementById('expand'+arguments[i]))
			//	document.getElementById('expand'+arguments[i]).innerHTML = " - ";
			}
			if (document.getElementById('expand'+arguments[i]))
			{
				document.getElementById('expand'+arguments[i]).src='cssimages/collapse.gif'; // - sign
			}
		}
	}
}
/*
function showPluses()
{
	// toggle all the passed nodes to + signs
	if (arguments.length)	// there are some nodes
	{
		for (var i = 0; i < arguments.length; i++)	
		// loop through all the nodes passed in as arguments
		{
			if (document.getElementById('expand'+arguments[i]))
				document.getElementById('expand'+arguments[i]).innerHTML = " + ";
			//else
			//	document.getElementById('noexpand'+arguments[i]).innerHTML = " * ";
				
		}
	}
}

function showMinuses()
{
	// toggle all the passed nodes to - signs
	if (arguments.length)	// there are some nodes
	{
		for (var i = 0; i < arguments.length; i++)	
		// loop through all the nodes passed in as arguments
		{
			if (document.getElementById('expand'+arguments[i]))
				document.getElementById('expand'+arguments[i]).innerHTML = " - ";
		}
	}
}*/
