var structure = new Array();
var id = new Number();
var level = new Number();
var frame_left;
function getStructure(xml)
{
  id = 0;
  level = 0;
  var source=null;
  try{
    source=new ActiveXObject("Msxml2.DOMDocument");
  }
  catch(e){
    source= document.implementation.createDocument("","",null);
  }
  source.async=false;
  var exist_value=source.load(xml);
  var nodes_xml="";
  if (exist_value){
      var nodes = source.documentElement;
      nodes_xml = nodes.xml;
  }
  else {
      nodes_xml = xml;
  }
  var parser = new DOMImplementation();
  var domDoc = parser.loadXML(nodes_xml);
  var docRoot = domDoc.getDocumentElement();
  processStructure(docRoot);
  showMenu();
}
function processStructure(node)
{
  var obj = new Object();
  obj.level = '';
  var tmp_node = node;
  while (tmp_node.nodeName!="root")
  {
    obj.level+=' ';
    tmp_node = tmp_node.getParentNode();
  }
  if (node.getAttributes().getNamedItem("mid")!=null)
  {
    obj.mid = node.getAttributes().getNamedItem("mid").getNodeValue();
  }
  if (node.getAttributes().getNamedItem("mindexvar")!=null)
  {
    obj.mindexvar = node.getAttributes().getNamedItem("mindexvar").getNodeValue();
  }
  if (node.getAttributes().getNamedItem("nohidden")!=null)
  {
    obj.hiddenvar = node.getAttributes().getNamedItem("nohidden").getNodeValue();
  }
  if (node.getAttributes().getNamedItem("parentid")!=null)
  {
    obj.parentid = node.getAttributes().getNamedItem("parentid").getNodeValue();
  }
  if (node.getAttributes().getNamedItem("url")!=null)
  {
    obj.url = node.getAttributes().getNamedItem("url").getNodeValue();
  }
  if (node.getAttributes().getNamedItem("label")!=null)
  {
    obj.label = node.getAttributes().getNamedItem("label").getNodeValue();
  }
  structure[structure.length] = obj;
  if (node.getChildNodes().length>0)
  {
    var i = new Number();
    for (i=0;i<node.getChildNodes().length;i++)
    {
      processStructure(node.getChildNodes().item(i));
    }
  }
}
function showMenu()
{
  var i = new Number();
  frame_left = new treemenu('frame_left', true, true, false);
  frame_left.put(1,structure[0].label,'frame_main',structure[0].url,'0','','1','0','','');
  for (i=1;i<structure.length;i++)
  {
    frame_left.add(0,structure[i].level+structure[i].label,'frame_main',structure[i].url,structure[i].mid,structure[i].mindexvar,structure[i].hiddenvar,structure[i].parentid,'','');
  }
  document.getElementById("menu_div").innerHTML = frame_left;
}