
var menuList  = new Array();
var menuIndex = 0;

function menu(menuName, menuType, indent, multiOpen, maxChildByLevel)
{
	//alert(menuName+' '+menuType);
	this.rootNode=new nodeInfo('idroot', null);					
	this.rootNode.isRoot=true;									
	this.rootNode.isOpen=false;
	this.allNode=new Array();									
//	this.allNode[0]=this.rootNode;
	this.allNode['idroot']=this.rootNode;
	this.nodeIndex=0;
	this.name=menuName;
	this.prefix=menuName+"-";
	this.type=menuType;
	this.x=0;
	this.y=0;
	this.indent=indent;
	this.xmax=0;
	this.fontSize=0;
	this.menuYSpace=0;
	this.level=0;
	this.multiOpen = multiOpen;
	this.maxChildByLevel = maxChildByLevel;
	
	//if (menuType=="Top") 
	
	menuList[menuName]=this;
	menuList[menuIndex]=this;
	menuIndex++;
}

function nodeInfo(nodeName, parentNode, level)
{
  this.nodeName			= nodeName;
  this.parentNode		= parentNode;
  this.childNode		= new Array();
  this.childNodeIndex	= 0;
  this.isOpen			= false;
  this.isRoot			= false;
  this.level			= level;
  
  if (parentNode!=null) {
		parentNode.childNode[parentNode.childNodeIndex]=this;
		parentNode.childNodeIndex++;
  }
			
  this.addNode			= addNode;
  
  if (nodeName=="root") this.isRoot=true;
}





function addNode(pMenu, parentNode, newNode, level, open)
{
  no = new nodeInfo(newNode, pMenu.allNode[parentNode], level);
  no.isOpen=open;
  pMenu.allNode[newNode]=no;
  pMenu.allNode[pMenu.nodeIndex]=no;
  pMenu.nodeIndex++;
  if (level>pMenu.level) pMenu.level = level;
}



