function xMenuAJM(sUlId, sSelLi, bSingle, iOpenLvl) {
 xMenuAJM.instances = new Array();
 xMenuAJM.instances[sUlId] = this;
 this.ulRoot = xGetElementById(sUlId);
 this.bSingle = bSingle;
 this.iOpenLvl = iOpenLvl;
 this.onClick = function(e) {
  var evt = new xEvent(e);
  var a = evt.target;
  if (!a || !a.tagName || (a.tagName.toLowerCase() != 'a') || !a.href) {
   return true;
  }
  if (('#' != a.href.charAt(a.href.length - 1)) && ('javascript:;#' != a.href)) {
   return true;
  }
  var li = a.parentNode;
  if (!li || !li.tagName || (li.tagName.toLowerCase() != 'li')
    || (li.iLvl < li.obj.iOpenLvl)) {
   return false;
  }
  var ul = xFirstChild(li, 'ul');
  if (ul) {
   if (li.obj.bSingle) {
    li.obj.fHide(li.obj);
   }
   if ((ul.style.display == 'none')) {
    ul.style.display = 'block';
   } else {
    ul.style.display = 'none';
   }
  }
  return false;
 }

 xWalkUL(sUlId, this, function(ulParent, liCurrent, ulChild, obj, iLvl) {
  liCurrent.obj = obj;
  liCurrent.iLvl = iLvl;
  xAddEventListener(liCurrent, 'click', obj.onClick, false);
  return true;
 });
 this.fHide = function(obj) {
  xWalkUL(obj.ulRoot, obj.iOpenLvl, function(ulParent, liCurrent, ulChild,
    iOpenLvl, iLvl) {
   if (iLvl >= iOpenLvl) {
    if (ulChild) {
     ulChild.style.display = 'none';
    }
   }
   return true;
  });
 }
 this.fOpen = function(sLiId) {
  if (!xDef(xGetElementById(sLiId)) || !(xGetElementById(sLiId))) {
   return;
  }
  var ul = xGetElementById(sLiId).parentNode;
  while (ul && (ul != xGetElementById(sLiId).obj.ulRoot)) {
   ul.style.display = 'block';
   ul = ul.parentNode;
  }
 }
 this.fHide(this);
 this.fOpen(sSelLi);
}
