// functions for opening and closing a tree and maintaining a list of what nodes are opened and closed


var openArray = new Array();

function Hide(oItems) {


	oItems.style.display = "none";

}

function Show(oItems) {

	
	oItems.style.display = "";

     
}

function addToOpenList(id)
{

	openArray.push(id);
}

function removeFromOpenList(id)
{
	// find the index of the element to remove.
	
	for (i=0; i < openArray.length; i++)
	{
		if (openArray[i] == id) 
		{ openArray = cutFromArray(openArray,i);
			break;
		}
	}

}

function buildOpenList()
{
	
	var returnString = "";

	for (i = 0; i  <openArray.length; i++)
	{

		returnString = returnString + openArray[i] + ",";	
	}

	return returnString.substring(0,returnString.length-1);

}


function cutFromArray(arr, i)
   {
   var pre = arr.slice(0,i);
   var post = arr.slice(i+1, arr.length);
   return pre.concat(post);
   }


function Toggle(event,oButton, oItems, id) 
{	
	if ((oItems.style.display == "none")) 
	{
		
		addToOpenList(id);
		oItems.style.display = "";
		oButton.src = "/images/downarrow.gif";
	}	
	else 
	{
		removeFromOpenList(id);
		oItems.style.display = "none";
		oButton.src = "/images/arrow.gif";
	}
	event.cancelBubble=true;
	
	return false;

}
