function genMenu(nestObj, rootPath, menuItems)
{
  var ul = window.document.createElement("ul");
  var re;
  
  for (var i = 0; i < menuItems.length; i++)
    {
      if ((re = new RegExp("^" + rootPath + "/" + menuItems[i].itemURI + "/?$")) 
          && re.test(window.location.pathname))
        {
          var li = window.document.createElement("li");
          if (i == (menuItems.length - 1))
            {
              li.style.marginBottom = "0px";
            }
          var span = window.document.createElement("span");
          var textNode = window.document.createTextNode(menuItems[i].itemName);
          span.appendChild(textNode);
          li.appendChild(span);
          ul.appendChild(li);
        }
      else if ((re = new RegExp("^" + rootPath + "/" + menuItems[i].itemURI + "/")) 
          && re.test(window.location.pathname))
        {
          var li = window.document.createElement("li");
          if (i == (menuItems.length - 1))
            {
              li.style.marginBottom = "0px";
            }
          var anchor = window.document.createElement("a");
          anchor.href = rootPath + "/" + menuItems[i].itemURI + "/";
          anchor.className="act";
          var textNode = window.document.createTextNode(menuItems[i].itemName);
          anchor.appendChild(textNode);
          li.appendChild(anchor);
          ul.appendChild(li);
        }
      else
        {
          var li = window.document.createElement("li");
          if (i == (menuItems.length - 1))
            {
              li.style.marginBottom = "0px";
            }
          var anchor = window.document.createElement("a");
          anchor.href = rootPath + "/" + menuItems[i].itemURI + "/";
          var textNode = window.document.createTextNode(menuItems[i].itemName);
          anchor.appendChild(textNode);
          li.appendChild(anchor);
          ul.appendChild(li);
       }
    }
  nestObj.appendChild(ul);
}
