    // widgets_ie.js


    ////////////////////
    // Menu Positioning
    ////////////////////

    function awmenuTop_IE (menuDiv, mevent, docElement)
    {
        var srcElement = mevent.srcElement;
        var menuTop = awabsoluteTop(srcElement.offsetParent) + mevent.offsetY;
        // ensure div is not displaying off screen
        var adjustedMenuTop = awcorrectForBottomEdge(menuTop, menuDiv);
        if (adjustedMenuTop == menuTop) {
            menuTop -= AWMenuOffset;
        }
        else {
            menuTop = adjustedMenuTop;
        }
        return menuTop;
    }

    function awmenuLeft_IE (menuDiv, mevent, docElement)
    {
        var srcElement = mevent.srcElement;
        var menuLeft = awabsoluteLeft(srcElement.offsetParent) + mevent.offsetX;
        // ensure div is not displaying off screen
        var adjustedMenuLeft = awcorrectForRightEdge(menuLeft, menuDiv);
        if (adjustedMenuLeft == menuLeft) {
            menuLeft -= AWMenuOffset;
        }
        else {
            menuLeft = adjustedMenuLeft;
        }
        return menuLeft;
    }

    function awpositionMenu (menuDiv, mevent)
    {
        // must display first to get proper coordinates.
        menuDiv.style.display = '';
        var docElement = awdocumentElement();
        var styleObject = menuDiv.style;
        var menuTop = awmenuTop_IE(menuDiv, mevent, docElement);
        var menuLeft = awmenuLeft_IE(menuDiv, mevent, docElement);
        styleObject.top = menuTop;
        styleObject.left = menuLeft;
    }

    //////////////////
    // Event Handlers
    //////////////////

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

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

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

        if (keyCode == 16) {
            // ignore shift button press
            shouldHandle = false;
        }
        else if (keyCode == 13) {
            shouldHandle = true;
        }
        else if (keyCode == 27) {
            shouldHandle = false;
            // Escape key
            awhideActiveMenu();
        }
        else if (keyCode == 9) {
            // tab key
            var stopBubbling = false;
            if (mevent.shiftKey) {
                if (menuCellDivLink == awfirstMenuLink(menuDivId)) {
                    stopBubbling = true;
                    shouldHandle = false;
                }
            }
            else {
                if (menuCellDivLink == awlastMenuLink(menuDivId)) {
                    stopBubbling = true;
                    shouldHandle = false;
                }
            }
            if (stopBubbling) {
                awcancelBubble(mevent);
            }
        }
        return shouldHandle;
    }

    ////////////////////////////////
    // Div positioning / lazy div
    ////////////////////////////////

    var AWCurrDiv_IE;

    function awPostLoadLazyDiv ()
    {
        if (AWCurrDiv_IE) {
            awrepositionDivToWindow(AWCurrDiv_IE);
        }
        AWCurrDiv_IE = null;
    }

    function awdisplayDiv (divObject)
    {
        if (divObject != null) {
            divObject.style.display = '';
            AWCurrDiv_IE = divObject;
            awloadLazyDiv(divObject);
            awhideIntersectingSelects(divObject);
        }
    }

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

    ////////////////////////////////
    // Work-around for div vs select
    ////////////////////////////////
    function awsetElementsVisibility (targetName, newDisplay)
    {
        // Should consider keeing array of hidden elements
        // (from awhideIntersectingSelects)
        // and using that in here rather than scanning all
        var allElements = document.all
        var index = 0;
        for (index = allElements.length - 1;index > -1; index--) {
            var currentElement = allElements[index];
            if (currentElement.tagName == targetName) {
                currentElement.style.visibility = newDisplay;
            }
        }
        return false;
    }

    function awhideIntersectingSelects (divObject)
    {
        var allElements = document.all
        var index = 0;
        var divObjectTop = awabsoluteTop(divObject);
        var divObjectBottom = divObjectTop + divObject.offsetHeight;
        var divObjectLeft = awabsoluteLeft(divObject);
        var divObjectRight = divObjectLeft + divObject.offsetWidth;
        for (index = allElements.length - 1;index > -1; index--) {
            var currentElement = allElements[index];
            if (currentElement.tagName == 'SELECT' && currentElement.id != "awexempt") {
                if (awdoesIntersect(divObjectTop, divObjectBottom, divObjectLeft, divObjectRight, currentElement)) {
                    currentElement.style.visibility = 'hidden';
                }
            }
        }
        return false;
    }

    /* Intersecting rectangles

        If the bottom of one rectangle is below the top of the other, and.
        If the top of one rectangle is above the bottom of the other, and.
        If the left of one rectangle is to the left of the right side of the other, and
        If the right of one rectangle is to the right of the left side of the other

        then the two rectangles intersect.
    */
    function awdoesIntersect (divObjectTop, divObjectBottom, divObjectLeft, divObjectRight, targetElement)
    {
        var doesIntersect = false;
        var targetElementTop = awabsoluteTop(targetElement);
        if (divObjectBottom >= targetElementTop) {
            var targetElementBottom = targetElementTop + targetElement.offsetHeight;
            if (divObjectTop <= targetElementBottom) {
                var targetElementLeft = awabsoluteLeft(targetElement);
                if (divObjectRight >= targetElementLeft) {
                    var targetElementRight = targetElementLeft + targetElement.offsetWidth;
                    if (divObjectLeft <= targetElementRight) {
                        doesIntersect = true;
                    }
                }
            }
        }
        return doesIntersect;
    }


    ////////////////////////////////////////////////
    // Functions for IE 5.X compatibility on the Mac
    ////////////////////////////////////////////////

    function awpositionDisplayMacIE (menuDiv, popupDiv, mevent)
    {
        awpositionMenuMacIE(menuDiv, popupDiv, mevent);
        // call awdisplayDiv after awpositionMenu so that
        // menu is in final place before computing the intersections
        awdisplayDiv(popupDiv);
    }

    function awpositionMenuMacIE (menuDiv, popupDiv, mevent)
    {
        var left =  mevent.clientX + awdocumentElement().scrollLeft;
        var top = mevent.clientY + awdocumentElement().scrollTop;
        if ((left - 15) >= 0) {
            left = left - 15;
        }
        if ((top - 15) >= 0) {
            top = top - 15;
        }

        // the menu HTML is wrapped in a table, row, and cell in order to prevent the
        // display div from running off of the page on IE5 MacOS.
        var newHTML = '<table><tr><td class="awmenuCell">' + menuDiv.innerHTML + '</td></tr></table>';

        // The zIndex is set very high to tell the layout engine not to process the rest
        // of the page.
        popupDiv.style.zIndex = 1000000;
        popupDiv.innerHTML = newHTML;
        // position must be set absolute in order for the following code to set
        // the left and top positions to work.
        popupDiv.style.position = 'absolute'
        popupDiv.style.left = left + 'px';
        popupDiv.style.top = top + 'px';
    }
