////////////////////////////////////////////////////////////////
// the following 2 variables can be changed
//
// NOTE: if an individual page would like to override
// the DEFAULT_MENU setting here, then create a variable
// on that page called CUSTOM_DEFAULT_MENU and assign
// a default menu span id value to it there.
////////////////////////////////////////////////////////////////

////////////////////////////////////////////
// an array of names of css id values for
// the child menus - do not include the
// filler menu from above
////////////////////////////////////////////

var ALL_MENUS = Array("ddmOne", "ddmTwo");

////////////////////////////////////////////
// which menu to show if no other menu is
// being used - if no menu needs to be
// shown by default, then an empty span can
// be built
//
// NOTE: if an empty span is used (as
// opposed to one of the existing menus),
// do NOT include this span in the 
// ALL_MENUS array above.
////////////////////////////////////////////

var DEFAULT_MENU = "ddmZero";

////////////////////////////////////////////////////////////////
// do not edit code below this point
////////////////////////////////////////////////////////////////

// ok to use menu?
var BROWSER_OK = (document.getElementById) ? true : false;

// probably overkill
var MENU_ON = "block";
var MENU_OFF = "none";

// for the timer that clears if no menu is being used
var tID = null;
var overChild = false;

// show/hide a menu
function toggleMenu (menu, status, fromParent) {
    if (! BROWSER_OK) return;
    if (fromParent) {
        // clear any currently showing menu
        this.clearAllMenus(false);
        this.trackState();
    }
    // do the deed
    document.getElementById(menu).style.display = status;
}

// used to enable/disable menu toggling
function trackState () {
    tID = (overChild) ? setTimeout("clearAllMenus(true)", 50) : clearTimeout(tID);
    overChild = (overChild) ? false : true;
}

// clear all menus
function clearAllMenus (restoreHolder) {
    var rhett = (restoreHolder) ? MENU_ON : MENU_OFF;
    // turn off the default manually (if it's there)
    if (document.getElementById("ddmZero") != null) {
        toggleMenu("ddmZero", MENU_OFF, false);
    }
    // clear all the menus
    for (var i=0; i < ALL_MENUS.length; i++) {
        toggleMenu(ALL_MENUS[i], MENU_OFF, false);
    }
    // the default menu
    toggleMenu(DEFAULT_MENU, rhett, false);
}

// get things started
function init () {
    // is there a custom value?
    DEFAULT_MENU = (CUSTOM_DEFAULT_MENU != "") ? CUSTOM_DEFAULT_MENU : DEFAULT_MENU;
    // now set up the page
    clearAllMenus(true);
}

// window.onload = init;
