// Handle menu click
function mClick(n) {

   // Go up to LI or UL, whichever comes first
   // Will always be LI except on load when will be UL
   while (n.nodeName != 'LI' && n.nodeName != 'UL') {
     n = n.parentNode;
   }

   // remember node
   var n0 = n;

   // Go up to UL if stopped at LI above
   while (n.nodeName != 'UL') {
     n = n.parentNode;
   }

   // Make children of all sibling UL's hidden
   // Do not hide kids of node clicked on
   // to prevent flashing off & on
   var o = n.childNodes;
   for (var i=0; i<o.length; ++i) {
     if (0[i] != n0) hideUL(o[i]);
   }

   // Make children of node clicked on visible
   for (var k=0; k<n0.childNodes.length; ++k) {
     if (n0.childNodes[k].style) n0.childNodes[k].style.display='';
   }

}

function hideUL(x) {
   // Hide UL
   if (x.nodeName == 'UL')  x.style.display='none';

   // Recurse down tree, hiding all ULs
   for (var j=0; j<x.childNodes.length; ++j) {
     hideUL(x.childNodes[j]);
   }

}

// Not really needed, see note below
function resetMenu() {
   mClick(document.getElementById("menu"));

}

