    // widgets_ns.js

    var AWPreviousMenuCell = null;
    // the hacked number for the correct display of the popupmenu,
    // we should figure out where it comes from
    var AWMagicNumber = 6;

    ////////////////
    // Browser type
    ////////////////
    var IsNS4 = (document.layers) ? true : false;
    var IsNS6 = (!document.all && document.getElementById) ? true : false;

    ////////////////////
    // Menu Positioning
    ////////////////////
    function awpositionMenu_NS6 (menu, mevent)
    {
        var styleObject = menu.style;

        var styleDisplay = styleObject.display;
        if (styleDisplay == 'none') {
            styleObject.display = '';
        }

        var menuTop    = mevent.pageY;
        var menuLeft   = mevent.pageX;
        // get the offsetHeight and the offsetWidth values before changing the styleObject,
        // because the change of the top and the left in the styleObject may impact these values
        var menuHeight = menu.offsetHeight;
        var menuWidth  = menu.offsetWidth;

        // ensure div is not displaying off screen

        styleObject.top = 0;
        var menuMax = mevent.clientY + menuHeight;
        if (menuMax > window.innerHeight) {
            var delta = menuMax - window.innerHeight;
            menuTop = menuTop - delta;
        }
        menuTop = menuTop - AWMenuOffset;
        if (menuTop < 0) {
            menuTop = 0;
        }
        styleObject.top = menuTop + "px";


        styleObject.left = 0;
        menuMax = mevent.clientX + menuWidth;
        if (menuMax > window.innerWidth) {
            var delta = menuMax - window.innerWidth;
            menuLeft = menuLeft - delta;
        }
        menuLeft = menuLeft - AWMenuOffset;
        if (menuLeft < 0) {
            menuLeft = 0;
        }
        styleObject.left = menuLeft + "px";

        // it is a hack for a defect in the Netscape
        var newWidth  = menuWidth - AWMagicNumber;
        styleObject.width  = newWidth + 'px';
        // we don't handle it for the height, until there is a problem for it
        // var newHeight = menuHeight - 6;
        // styleObject.height = newHeight + 'px';

        styleObject.display = styleDisplay;
    }

    function awpositionMenu (menu, mevent)
    {
        if (IsNS6) {
            awpositionMenu_NS6(menu, mevent);
        }
        else {
            awunsupportedBrowser();
        }
    }

/*
    // unused?
    function awisMouseInDiv_NS (divObject, mevent)
    {
        var docBody = document.body;
        var isMouseInMenu = false;
        var mouseX = mevent.pageX;
        var menuLeft = parseInt(divObject.style.left);
        // Note: no need to adjust for scrolling
        var menuRight = menuLeft + divObject.offsetWidth;
        if (mouseX > (menuLeft + AWMenuBorderWidth) &&
            mouseX < (menuRight - AWMenuBorderWidth))
        {
            var mouseY = mevent.pageY;
            var menuTop = parseInt(divObject.style.top);
            // Note: no need to adjust for scrolling
            var menuBottom = menuTop + divObject.offsetHeight;
            if (mouseY > (menuTop + AWMenuBorderWidth) &&
                mouseY < (menuBottom - AWMenuBorderWidth))
            {
                isMouseInMenu = true;
            }
        }
        return isMouseInMenu;
    }
*/
    //////////////////
    // Event Handlers
    //////////////////

    /*
        Called when the user types a key while in the popup menu
    */

    function awShouldHandleMenuKeyDown(menuCellDivLink, mevent)
    {
        var shouldHandle = false;

        var mcdlParent = awgetParentElement(menuCellDivLink);
        var menuDivId = mcdlParent.id;

        var keyCode = awkeyCode(mevent);
        //if (keyCode == 16) {
            // ignore shift button press
        //    return;
        //}
        if (keyCode == 13) {
            shouldHandle = true;
        }
        else if (keyCode == 27) {
            // Escape key
            awhideActiveMenu();
        }
        else if (keyCode == 9) {
            // tab key
            if (mevent.shiftKey) {
                if (menuCellDivLink == awfirstMenuLink(menuDivId)) {
                    // in NS, the focus has already been moved because the
                    // event handler for an ancestor has already fired. Need to refocus on the last menu item.
                    awlastMenuLink(menuDivId).focus();
                    mevent.stopPropagation();
                    mevent.preventDefault();
                }
            }
            else {
                if (menuCellDivLink == awlastMenuLink(menuDivId)) {
                    // in NS, the focus has already been moved because the
                    // event handler for an ancestor has already fired. Need to refocus on the first menu item.
                    awfirstMenuLink(menuDivId).focus();
                    mevent.stopPropagation();
                    mevent.preventDefault();
                }
            }
        }
        return shouldHandle;
    }

    ////////////////////////////////
    // Div positioning / lazy div
    ////////////////////////////////
    // The following methods are used to workaround the problem that NS has with
    // resizing divs when dynamic content is wider than the original div.  IE automatically
    // resizes the awmenu div to fit all content brought in by AWLazyDiv, but NS does not.
    var AWCurrDiv_NS;
    function awResizeDivToContent_NS (divObject)
    {
        if (divObject) {
            // set scroll on so we can figure out the width of the content in the div,
            // then hide hide the scrollbars and resize the div to fit content
            divObject.style.overflow = "scroll";
            var width = divObject.scrollWidth;
            var height = divObject.scrollHeight;
            divObject.style.overflow = "hidden";
            divObject.style.width = width + "px";
            divObject.style.height = height + "px";
        }
    }

    function awPostLoadLazyDiv ()
    {
        if (AWCurrDiv_NS) {
            // display the div so all sizes are established
            AWCurrDiv_NS.style.display = '';
            awResizeDivToContent_NS(AWCurrDiv_NS);
            awrepositionDivToWindow(AWCurrDiv_NS);
            AWCurrDiv_NS = null;
        }
    }

    function awdisplayDiv (divObject)
    {
        if (divObject != null) {

            // display the div so user sees something while we go and fetch the lazy div
            divObject.style.display = '';

            // save the main div for post child div load callback
            AWCurrDiv_NS = divObject;
            if (!awloadLazyDiv(divObject)) {
                // if we don't need to load lazy divs, then just call awPostLoadLazyDiv
                awPostLoadLazyDiv();
            }
        }
    }

    function awPositionActiveDialogBox ()
    {
        if (AWActiveDialogDiv) {
            awResizeDivToContent_NS(AWActiveDialogDiv);
            awPositionDialogBox(AWActiveDialogDiv);
        }
    }

    ////////////////////////////////
    // Work-around for div vs select
    ////////////////////////////////
    function awhideIntersectingSelects (target)
    {
        // no-op
    }

    function awsetElementsVisibility (targetName, newDisplay)
    {
        // no-op
    }
