/****************************************************************************
// set array for menu color
var arMenuColor = Array();
    arMenuColor["normal"] = "#ffffff";
    arMenuColor["hilight"] = "#0066cc";
    arMenuColor["airMenu"] = "#66ccff";
    arMenuColor["marineMenu"] = "#33ffcc";
    arMenuColor["railMenu"] = "#ccff33";
    arMenuColor["roadMenu"] = "#6666CC";
    arMenuColor["logisticsMenu"] = "#ff9900";
    arMenuColor["morecooljobsMenu"] = "#ff6666";

// load this function with other onload handlers
window.onload = function()
{
    initDropDown();
}

last update: 2005/04/23 - economized onmouseover handler for menu headings
****************************************************************************/


// set array for menu color
var arMenuColor = Array();
    arMenuColor["normal"] = "#ffffff";
    arMenuColor["hilight"] = "#0066cc";
    arMenuColor["airMenu"] = "#66ccff";
    arMenuColor["marineMenu"] = "#33ffcc";
    arMenuColor["railMenu"] = "#ccff33";
    arMenuColor["roadMenu"] = "#6666CC";
    arMenuColor["logisticsMenu"] = "#ff9900";
    arMenuColor["morecooljobsMenu"] = "#ff6666";



/* global variables */
// set array for current menu
var currentMenu = Array();
    currentMenu["head"] = null;
    currentMenu["dd"] = null;
    currentMenu["init"] = null;
    currentMenu["selected"] = null;

// timer variable
var menuTimer;

/* end global variables */


// function to show menu
function showMenu()
{
    if( currentMenu["init"] )
    {
        clearTimeout( menuTimer );
        // show requested menu & set fore color to arMenuColor hover color
        if( currentMenu["head"] != currentMenu["selected"] )
        {
            var headColor = arMenuColor[currentMenu["head"]] ? arMenuColor[currentMenu["head"]] : arMenuColor["hilight"];
            xColor( currentMenu["head"], headColor );
        }
        xShow( currentMenu["dd"] );
    }
    else
    {
        return null;
    }
}

// function to close current menu
function hideMenu()
{
    if( currentMenu["init"] )
    {
    // stay:
    //    clearTimeout( menuTimer );
    // hide:
        menuTimer = window.setTimeout( "resetAll();", 277 );
    }
    else
    {
        return null;
    }
}

function resetAll()
{
    if( currentMenu["init"] )
    {
        if( currentMenu["head"] != currentMenu["selected"] )
        {
            // set "menunameMenu" foreground color to normal color from arMenuColor
            xColor( currentMenu["head"], arMenuColor["normal"] );
        }
        // hide previous menu
        xHide( currentMenu["dd"] );
    }
    else
    {
        return null;
    }
}

// initialize dynamic functions for all links
function initDropDown()
{
    // set dropdown menu placement and triggers
    // get all the elements of class tcMenuHead (id in format "menunameMenu")
    var tcObj = document.getElementsByTagName( "a" );

    for( var i = 0; i < tcObj.length; i++ )
    {
        if( tcObj[i].className.indexOf( "tcMenuHead" ) != -1 )
        {
            // run through all objects in array to set position of drop down
            // if drop down menu object doesn't exist, skip.
            // local variables for setup, dynamic variables for current
            var mHead = tcObj[i].id;
            var mDD = tcObj[i].id + "DD";

            if ( xGetElementById( mDD ) )
            {
                // calculate left position to right flush drop down menu
                // if left flush is all that's required, use the style sheet definition
                var headLeftPos = xOffsetLeft( mHead );
                var headWidth = xWidth( mHead );
                var DDWidth = xWidth( mDD );

                var ieMacOffset = ( xMac && xIE4Up ) ? -13 : 0;
                var tc = headLeftPos - ( DDWidth - headWidth ) + ieMacOffset;

                // set position of drop down to right flush with menulist option
                xLeft( mDD, tc );
            }
        
            // initialize onmouseover handler
            tcObj[i].onmouseover = function()
            {
                // reinitialize variables dynamically
                var mHead = this.id;
                var mDD = this.id + "DD";

                // check current menu status
                if( currentMenu["dd"] )
                {
                    if( currentMenu["dd"] == mDD )
                    {
                        // this menu already open
                        clearTimeout( menuTimer );
                    }
                    else
                    {
                        // hide another menu that's open
                        clearTimeout( menuTimer );
                        resetAll();
                    }
                }

                // set array for current menu
                currentMenu["head"] = mHead;
                currentMenu["dd"] = mDD;

                showMenu();
            } // end tcObj[i].onmouseover

            // initialize onmouseout handler
            tcObj[i].onmouseout = hideMenu;
        } // end dropdown menu head

        else if( tcObj[i].className.indexOf( "profile" ) != -1 )
        {
            tcObj[i].onmouseover = showMenu;
            tcObj[i].onmouseout = hideMenu;
        } // end dropdown element stay opens
    }

    currentMenu["init"] = true;
}