
function GetElementByID(obj)
{
	if(document.getElementById)
	{
	 return document.getElementById(obj);
	 }
	else 
	{
	 return document.all[obj];
	 }
}
function ExpandCollapseNode(PlusSignNode, DescriptionBox)
{
	
	this.TriggerHolder=PlusSignNode;
	this.Pane=DescriptionBox;
	this.ChangeIcon=function(Degree)
	{
		if(Degree<0)
		 GetElementByID(this.TriggerHolder).src=getCollapseIconPath();
		else 
		 GetElementByID(this.TriggerHolder).src=getExpandIconPath();		
		return true; 
	}
	this.HidePane=function()
	{
	    GetElementByID(this.Pane).style.display="none";
		return true;		
	}
	this.ShowPane=function()
	{
		GetElementByID(this.Pane).style.display="block";		
		return true;		
	}
	return this;
}

function ExpandCollapseStructure(InstanceName)
{
	
	this.Nodes=new Array();
	this.Instance=InstanceName;
	this.Init=function()
	{
/*		var thisElem;
		for(thisElem=0;thisElem<this.Nodes.length;thisElem++)
		 GetElementByID(this.Nodes[thisElem].TriggerHolder).onclick=this.Instance+".ShowPane('"+this.Nodes[thisElem].Pane+"');";
*/	
 	    this.HideAll();	 
	}
	this.AddNode=function(PlusSignNode,DescriptionBox)
	{
		var temp=new ExpandCollapseNode(PlusSignNode,DescriptionBox);
		this.Nodes.push(temp);
		return true;
	}
	this.HideAll=function()
	{
		var thisElem;
		for(thisElem=0;thisElem<this.Nodes.length;thisElem++)
		//for (thisElem in this.Nodes) 
		{
			this.Nodes[thisElem].HidePane();
			this.Nodes[thisElem].ChangeIcon(1);
		}
		return true;
	}
	this.ShowPane=function(paneName)
	{
		
		var thisElem;
		var hideMe=false;
		if(GetElementByID(paneName).style.display=="block")
			hideMe=true;
		//for(thisElem in this.Nodes)
		for(thisElem=0;thisElem<this.Nodes.length;thisElem++){
		 if (this.Nodes[thisElem].Pane == paneName && hideMe==false) 
		 {
   				this.Nodes[thisElem].ChangeIcon(-1);
				this.Nodes[thisElem].ShowPane();
		 }
		 else
		 {
				this.Nodes[thisElem].ChangeIcon(1);
				this.Nodes[thisElem].HidePane();
				
		 }
	  }
		
	}
}
