function createDivByClassName(name) {
   //create a new Div
   var divTag = this.document.createElement("div"); 
   divTag.id = name; 
   divTag.className = name; 
   this.document.body.appendChild(divTag);
   
   return divTag;
}

function createFrameByClassName(name) {
   //create a new Frame
   var divTag = this.document.createElement("iframe"); 
   divTag.id = name; 
   divTag.className = name; 
   divTag.name = name;
   divTag.scrolling = "no";
   this.document.body.appendChild(divTag);
   
   return divTag;
}

function ToggleExpansion()
{             
   for(j=0; j<this.childNodes.length; j++)
   {
      if(this.childNodes[j].mouseIsOver)
         return;
   }
   this.className = (this.className == "expandMenu") ? "collapseMenu" : "expandMenu";
}

function startList() 
{
   if (getById)
   {
      navRoot = getById("nav");
      for (i=0; i<navRoot.childNodes.length; i++)
      {
         node = navRoot.childNodes[i];
         if (node.nodeName=="LI")
         {
            //add a mouse over check on each child node
            //this is a temp fix so that when a user clicks on a child link, the
            //list does not collapse, check to see if the child link is clicked,
            //if so, then do not collapse the link, if the parent link is clicked
            //then collapse the list
            //Note: should try to pursue a smarter solution in the future
            for(j=0; j<node.childNodes.length; j++)
            {
               childNode = node.childNodes[j];
               if(childNode.nodeName == "UL")
               {
                  childNode.mouseIsOver = false;
                  childNode.onmouseover = function(){ this.mouseIsOver = true; };
                  childNode.onmouseout = function(){ this.mouseIsOver = false; };
                  //add on click event to set the proper CSS class for collapsing
                  //only if the node has a nested list
                  node.onclick=ToggleExpansion;
                  //set the default className
                  node.className = "collapseMenu";
               }
            }
         }
      }
   }
}
//ensure that this function runs to initialize the list
window.onload=startList;

