// xmenu4_vertical.js
// xMenu4 Demo 2, Cascading menus from nested ULs!
// Copyright (c) 2002,2003 Michael Foster (cross-browser.com)
// This code is distributed under the terms of the LGPL (gnu.org)

////--- Loader

if (document.getElementById) {
  document.write("<"+"link rel='stylesheet' type='text/css' href='xmenu4_dhtml.css'>");
  window.onload = xOnload;
}

////--- Load Event Listener

function xOnload()
{
  var me = xGetElementById('myMenu1');
  if (!xDef(me.nodeName, me.firstChild, me.nextSibling)) {
    return;
  }
  
  var mo = new xMenu4(
    me,                       // id str or ele obj of outermost UL
    true,                     // outer UL position: true=absolute, false=static
    false,                    // main label positioning: true=horizontal, false=vertical
    0, 1,                     // box horizontal and vertical offsets
    [-3, -10, -6, -10],       // lbl focus clip array
    [-30, null, null, null],  // box focus clip array
    // css class names:
    'xmBar', 'xmBox',
    'xmBarLbl', 'xmBarLblHvr',
    'xmBarItm', 'xmBarItmHvr',
    'xmBoxLbl', 'xmBoxLblHvr',
    'xmBoxItm', 'xmBoxItmHvr'
  );

  xMnuMgr.add(mo);

  mo = new xMenu4(
    'myMenu2',                // id str or ele obj of outermost UL
    true,                     // outer UL position: true=absolute, false=static
    false,                    // main label positioning: true=horizontal, false=vertical
    0, 1,                     // box horizontal and vertical offsets
    [-3, -10, -6, -10],       // lbl focus clip array
    [-30, null, null, null],  // box focus clip array
    // css class names:
    'xmBar', 'xmBox',
    'xmBarLbl', 'xmBarLblHvr',
    'xmBarItm', 'xmBarItmHvr',
    'xmBoxLbl', 'xmBoxLblHvr',
    'xmBoxItm', 'xmBoxItmHvr'
  );

  xMnuMgr.add(mo);

  mo = new xMenu4(
    'myMenu3',                // id str or ele obj of outermost UL
    true,                     // outer UL position: true=absolute, false=static
    false,                    // main label positioning: true=horizontal, false=vertical
    0, 1,                     // box horizontal and vertical offsets
    [-3, -10, -6, -10],       // lbl focus clip array
    [-30, null, null, null],  // box focus clip array
    // css class names:
    'xmBar', 'xmBox',
    'xmBarLbl', 'xmBarLblHvr',
    'xmBarItm', 'xmBarItmHvr',
    'xmBoxLbl', 'xmBoxLblHvr',
    'xmBoxItm', 'xmBoxItmHvr'
  );

  xMnuMgr.add(mo);

  xMnuMgr.load(); // calls the load method of all menus
  xmWinOnResize(); // initial positioning
  xAddEventListener(window, 'resize', xmWinOnResize, false);
}

////--- Window Resize Event Listener

function xmWinOnResize() // reposition the 2 menus on the page
{
  var rc = xGetElementById('rightColumn');
  var mm = xGetElementById('menuMarker');
  var mmp = mm.offsetParent;
  var x = xPageX(mm)-xPageX(rc);
  var y = xPageY(mm)-xPageY(rc);
  var dx = -10, dy = 60;
  xMoveTo('myMenu1', x+dx, y+dy);
  xMoveTo('myMenu2', x+dx, y+80+dy);
  xMoveTo('myMenu3', x+dx, y+160+dy);
  xMnuMgr.paint(); // calls the paint method of all menus
}

