  var moveMenu = 0;
  var selMenu = 0;
  var activeMenu = 0;
  var selTimerID = 0;
  var moveSteps = 0;
  var totalMoveSteps = 30;
  var openAmount = 1;
  var initDone = 0;
  var accuHeight = 0;
  var realTopPos = 125;
  var topPos = realTopPos;

  function menuMove() {
    if (moveSteps > 0) {

      sublist = document.getElementById('x_sublist_1_' + moveMenu);

      firstMove = false;
      if (moveSteps == totalMoveSteps) {
        sublist.firstChild.style.overflowY = "hidden";
        firstMove = true;
      }

      moveSteps = Math.floor(moveSteps * 0.88);
      sxh = Math.floor(openAmount * (totalMoveSteps-moveSteps) / totalMoveSteps);

      if (moveSteps <= 0) {
        sublist.firstChild.style.overflowY = "auto";
      }
      if (sublist.style.overflow != 'hidden') { sublist.style.overflow = 'hidden'; }
      sublist.style.display = 'block';
      sublist.style.height = sxh + "px";
      sublist.firstChild.style.height = (sxh - 1) + 'px';

      if (firstMove) {
        sublist = document.getElementById('x_group_1_' + moveMenu);
        sublist.style.borderBottomWidth = "0px";
      }

      if (activeMenu != 0) {
        sublist = document.getElementById('x_sublist_1_' + activeMenu);
        if (sublist.style.overflow != 'hidden') { sublist.style.overflow = 'hidden'; }
        uxh = Math.floor(openAmount * (moveSteps) / totalMoveSteps);
        sublist.firstChild.style.height = uxh + "px";
        if (firstMove) {
          sublist.firstChild.style.overflowY = 'hidden';
        }
        sublist.style.height = uxh + "px";
        sublist.style.overflowY = 'hidden';
        if (moveSteps == 0) {
          sublist.style.display = 'none';
          sublist = document.getElementById('x_group_1_' + activeMenu);
          sublist.style.borderTopWidth = "1px";
        }
      }
      if (moveSteps <= 0) {
        activeMenu = moveMenu;
        moveMenu = 0;
        moveSteps = 0;
      }
      setTimeout("menuMove();", 15);
    } else {
      moveMenu = 0;
      moveSteps = 0;
    }
  }

  function menuShow(x) {
    if (initDone != 0) {

    if (selTimerID != 0) {
      clearTimeout(selTimerID);
    }
    s = x.id.substr(10);
    if (moveSteps <= 0) {
      selMenu = s;
      if (activeMenu != selMenu) {
        moveSteps = totalMoveSteps;
        moveMenu = s;
        setTimeout("menuMove();", 15);
      }
    } else {
      if (selMenu > 0) {
        setTimeout("menuOver(document.getElementById('x_group_1_" + selMenu + "'))", 15);
        selMenu = 0;
      }
    }

    }
  }
  function menuOver(x) {
    if (initDone != 0) {

    s = x.id.substr(10);
    if (selMenu != s) {
      selMenu = s;
      if (selTimerID != 0) {
        clearTimeout(selTimerID);
      }
      selTimerID = setTimeout("menuShow(document.getElementById('" + x.id + "'))", 250);
    }

    }
  }
  function menuOut(x) {
    if (selTimerID != 0) {
      clearTimeout(selTimerID);
    }
    selMenu = 0;
  }
  function sizeMenus() {
    var myWidth = 0, myHeight = 0;

    var ieDiv = document.getElementById('iewarning');
    if (ieDiv) {
      topPos = realTopPos + ieDiv.offsetHeight;
    }

    if( typeof( window.innerWidth ) == 'number' ) {
      //Non-IE
      myWidth = window.innerWidth;
      myHeight = window.innerHeight;
    } else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
      //IE 6+ in 'standards compliant mode'
      myWidth = document.documentElement.clientWidth;
      myHeight = document.documentElement.clientHeight;
    } else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
      //IE 4 compatible
      myWidth = document.body.clientWidth;
      myHeight = document.body.clientHeight;
    }
    var scrOfX = 0, scrOfY = 0;
    if( typeof( window.pageYOffset ) == 'number' ) {
      //Netscape compliant
      scrOfY = window.pageYOffset;
      scrOfX = window.pageXOffset;
    } else if( document.body && ( document.body.scrollLeft || document.body.scrollTop ) ) {
      //DOM compliant
      scrOfY = document.body.scrollTop;
      scrOfX = document.body.scrollLeft;
    } else if( document.documentElement && ( document.documentElement.scrollLeft || document.documentElement.scrollTop ) ) {
      //IE6 standards compliant mode
      scrOfY = document.documentElement.scrollTop;
      scrOfX = document.documentElement.scrollLeft;
    }

    adj = 0;
    adjh = 0;
    adjhflag = 0;

    if (scrOfY < topPos-1) {
      adj = scrOfY;
      document.getElementById('navbar').style.position = 'absolute';
    } else {
      adjh = topPos;
      if( window.XMLHttpRequest ) { // IE 6 doesn't implement position fixed nicely...
        document.getElementById('navbar').style.position = 'fixed';
        adjhflag = 1;
      }

    }

    if (adjhflag != 0) {
      adjt = topPos;
    } else {
      adjt = scrOfY - adj;
      if (adjt < topPos) {
        adjt = topPos;
      }
    }
    openAmount = myHeight - (topPos + 6) - accuHeight + adj + adjh;
    if ((activeMenu != 0) & (moveSteps == 0)) {
      sublist = document.getElementById('x_sublist_1_' + activeMenu);
      sublist.style.height = openAmount + "px";
      sublist.style.overflowY = "hidden";
      sublist.firstChild.style.height = (openAmount - 1) + "px";
      sublist.firstChild.style.overflowY = "auto";
    }
    if (adjhflag == 0) {
      document.getElementById('navbar').style.top = adjt + "px";
    } else {
      document.getElementById('navbar').style.top = "1px";
    }
  }

  function initMenus() {
    document.getElementById('navbar_content').className = "navbar_javascript";
    var oDiv = document.getElementById('x_topcat_1');

    if (document.images) {
      picDetectJS = new Image(16, 16);
      picDetectJS.src = '/jsdetect.php';
    }
    accuHeight = 0;
    if (document.getElementById('x_group_9999')) {
      accuHeight = document.getElementById('x_group_9999').offsetHeight;
    } 
    if(oDiv.firstChild) { // check for children
      oDiv = oDiv.firstChild;
      if (oDiv.firstChild) {
        var oChild = oDiv.firstChild;
        while(oChild) { // run over them
          if(oChild.nodeType==1) { // element
            // oChild is a first level child of oDiv
            // Do what you want with it here
            if (oChild.id.substr(0,10) == 'x_group_1_') {
              oChild.style.display = 'block';
              accuHeight += oChild.offsetHeight;
            }

            if (oChild.id.substr(0,12) == 'x_sublist_1_') {
              if (oChild.className.length !== 7) {
                oChild.style.height = openAmount + "px";
                oChild.style.display = "block";
                activeMenu = oChild.id.substr(12);
              } else {
                oChild.style.height = "0px";
                oChild.style.display = "none";
              }
            }
          }
          oChild = oChild.nextSibling;
        }
      }
    }
    sizeMenus();
    initDone = 1;
  }
  window.onscroll = function() {
    sizeMenus();
  }
