/*
*	File: js/navDropdownMenuPositioner.js
*	Top nav dropdown menu sizing, positioning, and styling
*	Issue/Request #17447 - New Top Nav Test including Personal Loan
*	Author: jhunvanich
*	Date: 06.07.2005
*/

/********************************************************************
* BROWSER DETECTION
********************************************************************/
var isNN = (navigator.appName.indexOf("Net") >= 0
    || navigator.appName.indexOf("Mozilla") >= 0
    || navigator.appName.indexOf("Safari") >=0
    || navigator.userAgent.indexOf("Mac") >=0
    || navigator.userAgent.indexOf("Opera") >= 0);
var isIE = (navigator.appName.indexOf("Microsoft") >= 0
        && navigator.userAgent.indexOf("Opera") == -1);
var isIE7 = navigator.userAgent.indexOf("MSIE 7.0") != -1;
var isOp =  (navigator.userAgent.indexOf("Opera") >= 0);

/********************************************************************
* EVENT HANDLERS FOR MOUSEOVER AND MOUSEOUT
********************************************************************/
/*START DEBUG*/
var isMouseDown = false;
var isMouseUp = true;
var isMouseClick = false;
function handleMouseMove(event) {
    //window.status = event.clientX + ", " + event.clientY;
}
/*END DEBUG*/


/*START CONFIG VARIABLES*/
/*Timer settings*/
var _initialOpendelayms = isIE ? 0 : 0;
var _opendelayms = _initialOpendelayms; // sub-menu open delay (ms)
var _closedelayms = 500; // sub-menu close delay (ms)
var _fadeInDuration_s = "0.00"; // sub-menu fade in duration (s)
var _fadeOutDuration_s = "0.50"; // sub-menu fade out duration (s)

/*Visual settings*/
var _enableIEEffects = false;
var _opacity = 95; // submenu opacity
var _subMenuBackgroundGradStart = "#FF0E7009"; // start gradient color
var _subMenuBackgroundGradFinish = "#0065B33D"; // start gradient color
var _subMenuGradientDirection = "1"; // gradient direction
var _dsColor = "#6C6C6C"; //drop shadow color
var _dropshadowOpacity_finish = 0; // drop shadow finish opacity
var _dropshadowOpacity_start = 85; // drop shadow start opacity
var _dropshadowWidth = 1;
/*END CONFIG VARIABLES*/

/* IE browsers will crash if hitbox does not complete loading first */
var isPageLoadComplete = false;

/*CREATE IFRAME SHIM FOR IE BROWSERS*/
var loantypeiframeshim = isIE ? createIFrameShim("typeOfLoan") : undefined;
var statetypeiframeshim = isIE ? createIFrameShim("propertyStateCode") : undefined;
var divDropShadowL1 = isIE ? createDivDropShadow() : undefined;
var divDropShadowL2 = isIE ? createDivDropShadow() : undefined;
var divDropShadowL3 = isIE ? createDivDropShadow() : undefined;

var submenuelement = undefined; // initiate submenu element
var parentmenuelement = undefined; // initiate parent menu element
var activeParentMenuElement =  undefined; // initiate active parent menu element
var isMouseOverParentMenu = false; // dirty flag for parent menu mouseover
var isMouseOverSubMenu = false; // dirty flag for sub-menu mouseover
var sm_absposY = 0; // set initial abs Y value
var isMenuLockPositionY = false; // set initial lock value
var clearSubMenuTimeoutID = undefined; // sub menu timeout ID
var clearParentMenuTimeoutID = undefined; // parent menu timeout ID
var clearIFrameShimTimeoutID = undefined; // Iframe shim timeout ID
var clearDropShadowTimeoutID = undefined; // Iframe shim timeout ID

/************************************
SUB MENU OFFSET COMPATIBLITY FIX
************************************/
var _submenu = {
    getOffsetX : function() {
        try {
            return -Position.positionedOffset($('main_container'))[0];
        } catch(ex) {
            /*default offset is 0.  We also also assume if prototype does not exist
            then the top nav is not part of a refactored page.*/
            return 0;
        }
    },
    getOffsetY : function() {
        try {
            if($('main_container')) {
                if(/MSIE 7.0/.test(navigator.userAgent)) return -5;
                if(/MSIE 6.0/.test(navigator.userAgent)) return -5;
                return 0;
            }
        } catch(ex) {
            /*default offset is 0.  We also also assume if prototype does not exist
            then the top nav is not part of a refactored page.*/
            return 0;
        }
    }

}

/************************************
PARENT MENU MOUSEOVERS AND MOUSEOUTS
************************************/
function handleParentMenuToggle(event, img, visibility) {
    if (isPageLoadComplete) {
        /*clear any running delay timers*/
        if(clearParentMenuTimeoutID != undefined)
            window.clearTimeout(clearParentMenuTimeoutID);
        if(clearSubMenuTimeoutID != undefined)
            window.clearTimeout(clearSubMenuTimeoutID);
        if(clearIFrameShimTimeoutID != undefined)
            window.clearTimeout(clearIFrameShimTimeoutID);
        if(clearDropShadowTimeoutID != undefined)
            window.clearTimeout(clearDropShadowTimeoutID);

        var subYAdjust = 27;
        var imgOffsetX = _submenu.getOffsetX();
        var imgOffsetY = _submenu.getOffsetY();
        var elementHolder = img.offsetParent;
        var parentTagName = "";
        /* you're only provided x,y coordinates of an element relative to its parent.
        Traverse up the DOM and perform a running sum of x,y coordinates until
        the state code and loan type select elements share the same parent as the
        menu, which is "HTML"*/
        while(parentTagName != "BODY") {
            try {
                if(elementHolder != undefined) imgOffsetX += elementHolder.offsetLeft;
                if(elementHolder != undefined) imgOffsetY += elementHolder.offsetTop;

                /* set the elements to its parent for the next iteration */
                elementHolder = elementHolder.offsetParent;
                parentTagName = elementHolder.tagName;
            } catch (ex) {break;}
        }// end while
        sm_absposX = imgOffsetX;
        sm_absposY = imgOffsetY + subYAdjust;

        /* before setting the next parent and submenu global elements, hide the previous submenu if
        user mouses over next parent menu and previous submenu is still visible */
        var imgregex = /img\w/; //using JS RegExp object will not work.
        var smprefix = "sm_";
        var isSameSubmenuElement = false;
        if(submenuelement !=  document.getElementById((img.name).replace(imgregex, smprefix))
            && visibility == "on") {
            startSubMenuToggle("none");
            toggleParentMenu("off");
            if(isIE) {
                toggleIFrameShim(0, 0, "none");
                toggleDropShadowDiv(0,0,"none");
            }
        } else {
            isSameSubmenuElement = true;
        }

        /*set the next sub-menu containing block element*/
        /* set parent menu element */
        parentmenuelement = img;
        /*set sub menu element*/
        submenuelement = document
            .getElementById((img.name).replace(imgregex, smprefix));

        if(document.images) {
            if(visibility == "on") {
                isMouseOverParentMenu = true;
                toggleParentMenu("on");
                /*position sub-menus and IFrame shims*/
                submenuelement.style.position = "absolute";
                submenuelement.style.left = sm_absposX + "px";
                submenuelement.style.top = sm_absposY + "px";

                if(isIE) {
                    /*compensates for IE offsetWidth inconsistency - menus must display
                    twice before IE can catch the correct offsetWidth*/
                    executeMenuToggleTwice = true;
                    parentmenuelement.style.filter =
                        "progid:DXImageTransform.Microsoft.Alpha()";
                    parentmenuelement.filters(0).opacity = _opacity;
                }

                if(!isSameSubmenuElement || submenuelement.style.display == "none") {
                    clearSubMenuTimeoutID = window.setTimeout(
                        "startSubMenuToggle('block')", _opendelayms);
                    if(isIE) {
                        clearIFrameShimTimeoutID = window.setTimeout(
                            "toggleIFrameShim('" + sm_absposX + "','" +  sm_absposY +
                            "','block')", _opendelayms);
                        clearDropShadowTimeoutID = window.setTimeout(
                            "toggleDropShadowDiv('" + sm_absposX + "','" +  sm_absposY +
                            "','block')", _opendelayms);
                    }
                }
            } else if(visibility == "off") {
                isMouseOverParentMenu = false;
                clearSubMenuTimeoutID = window.setTimeout(
                    "startSubMenuToggle('none')", _closedelayms);
                clearParentMenuTimeoutID = window.setTimeout(
                    "toggleParentMenu('off')", _closedelayms);
                if(isIE) {
                    clearIFrameShimTimeoutID = window.setTimeout(
                        "toggleIFrameShim('" + sm_absposX + "','" +  sm_absposY +
                        "','none')", _closedelayms);
                    clearDropShadowTimeoutID = window.setTimeout(
                        "toggleDropShadowDiv('" + sm_absposX + "','" +  sm_absposY +
                        "','none')", _closedelayms);
                }
            }//end else if

            /* Displaying the sub-menu sets the delay to 0ms.  Reset value back
            to initialization setting after displaying main menu */
            _opendelayms = _initialOpendelayms;
            return false;
        }// end if
    }// end if(isPageLoadComplete)
    return false;
} // end function: handleParentMenuToggle()


/************************************
SUBMENU MOUSEOVERS AND MOUSEOUTS
************************************/
function handleSubMenuItemHLToggle(event, div, visibility) {
    /*clear any running timers and intervals*/
    if(clearParentMenuTimeoutID != undefined)
        window.clearTimeout(clearParentMenuTimeoutID);
    if(clearSubMenuTimeoutID != undefined)
        window.clearTimeout(clearSubMenuTimeoutID);
    if(clearIFrameShimTimeoutID != undefined)
        window.clearTimeout(clearIFrameShimTimeoutID);
    if(clearDropShadowTimeoutID != undefined)
        window.clearTimeout(clearDropShadowTimeoutID);

    /*parent menu block element*/
    var divregex = /sm\w/; //using JS RegExp object will not work.
    var imgprefix = "img_";
    var isSameParentMenuElement = false;

    /*if it's the same parent menu, the user is mousing back over
    the parent menu.  This flag prevents the submenu from being re-toggled on*/
    if(parentmenuelement ==
        document.getElementById((div.getAttribute("name")).replace(divregex, imgprefix))) {
        isSameParentMenuElement = true;
    }

    /*set sub menu element*/
    submenuelement = div;
    /*set parent menu element*/
    parentmenuelement = document
        .getElementById((div.getAttribute("name")).replace(divregex, imgprefix));

    if(visibility == "on") {
        isMouseOverSubMenu = true;

        submenuelement.style.display = "block";
        toggleParentMenu(visibility);

        /* In cases where the fade-in is still in progress, this forces the opacity
        to the completed level regardless */
        if(isIE) {
            submenuelement.style.filter =
                "progid:DXImageTransform.Microsoft.gradient() " +
                "progid:DXImageTransform.Microsoft.Alpha()";

            /*set gradient filter*/
            submenuelement.filters(0).StartColorStr = _subMenuBackgroundGradStart;
            submenuelement.filters(0).EndColorStr = _subMenuBackgroundGradFinish;
            submenuelement.filters(0).GradientType = _subMenuGradientDirection;
            /*set opacity filter*/
            submenuelement.filters(1).opacity = _opacity;

            loantypeiframeshim.style.display = "block";
            statetypeiframeshim.style.display = "block";
        }

        /* After displaying sub-menu, immediatly display parent menu.  Not
        setting this value to 0ms will result in submenus disappearing when mousing
        back over its parent menu */
        _opendelayms = 0; // This should ALWAYS be set to 0ms here.
        return  true;
    } else if (visibility == "off") {
        isMouseOverSubMenu = false;
        if(!isSameParentMenuElement || (!isMouseOverSubMenu && !isMouseOverParentMenu)) {
            clearSubMenuTimeoutID =
                window.setTimeout("startSubMenuToggle('none')",  _closedelayms);
            clearParentMenuTimeoutID =
                window.setTimeout("toggleParentMenu('" + visibility + "')",  _closedelayms);
            if(isIE) {
                clearIFrameShimTimeoutID = window.setTimeout(
                    "toggleIFrameShim('0','0','none')", _closedelayms);
                clearDropShadowTimeoutID = window.setTimeout(
                    "toggleDropShadowDiv('0','0','none')", _closedelayms);
            }
            /*on mouse out, reset the open menu delay to initial value*/
            _opendelayms = _initialOpendelayms;
        }
        return true;
    }
    return false;
}// end function: handleSubMenuItemHLToggle()


/********************************************************************
* HELPER FUNCTIONS
********************************************************************/
/*compensates for IE offsetWidth inconsistency - menus must display
twice before IE can catch the correct offsetWidth*/
var executeMenuToggleTwice = true;

/*Sub menu dimensions for IFrame Shim*/
var submenuDivWidth = 0;
var submenuDivHeight = 0;


/************************************
TOGGLES SUBMENU
************************************/
function startSubMenuToggle(display) {
    var isDisplay = (display == "block") ? true : false;
    if(submenuelement != undefined) {
        if(isDisplay) {
            /*style sub-menu containers*/
            /*apply initial alpha filter value for IE*/
            /*Compensating for IE offsetWidth inconsistency - menus must display
            twice before IE can catch the correct offsetWidth*/
            if(isIE && !executeMenuToggleTwice) {
                submenuelement.style.filter =
                    "progid:DXImageTransform.Microsoft.Fade() " +
                    "progid:DXImageTransform.Microsoft.gradient() " +
                    "progid:DXImageTransform.Microsoft.Alpha()";

                /*set fade filter*/
                submenuelement.filters(0).duration = parseFloat(_fadeInDuration_s);
                /*set gradient filter*/
                submenuelement.filters(1).StartColorStr = _subMenuBackgroundGradStart;
                submenuelement.filters(1).EndColorStr = _subMenuBackgroundGradFinish;
                submenuelement.filters(1).GradientType = _subMenuGradientDirection;
                /*set opacity filter*/
                submenuelement.filters(2).opacity = _opacity;

                submenuelement.filters(0).Apply();
                submenuelement.style.display = display;
                submenuelement.filters(0).Play();
            } //end if

            /*set global height and width after display*/
            submenuDivWidth = submenuelement.offsetWidth;
            submenuDivHeight = submenuelement.offsetHeight;

            var submenuelementItems = submenuelement.getElementsByTagName("a");
            var rightOffSetWidth = 12; // box right-side white space value - 12
            var bottomPaddingWidth = 4; // box bottom space value for last menu item

            for(var i=0; i < submenuelementItems.length; i++) {
                //IE renders CSS properties: padding and margins differently than NN
                if(isIE && !isIE7) {
                    submenuelementItems[i].style.paddingRight = rightOffSetWidth + "px";
                    submenuelementItems[i].style.width =
                        (submenuDivWidth > rightOffSetWidth ?
                        (submenuDivWidth - rightOffSetWidth) : submenuDivWidth) + "px";
                } else if (isNN) {
                    submenuelementItems[i].style.width = "100%";
                    submenuelementItems[i].style.marginRight = rightOffSetWidth + "px";
                } else if (isIE7) {
                    submenuelementItems[i].style.paddingRight = rightOffSetWidth + "px";
                }


                //add extra bottom space for the last menu item
                if(i == submenuelementItems.length - 1) {
                    submenuelementItems[i].style.paddingBottom =
                    bottomPaddingWidth + "px";
                }// end if
            }// end for

            /*IE has a bug where the width of the sub-menu container doesn't initially set*/
            if(isIE && executeMenuToggleTwice) {
                executeMenuToggleTwice = false;
                startSubMenuToggle(display);
            }

        } else { // do not show.
            if(isIE) {
                submenuelement.style.filter =
                    "progid:DXImageTransform.Microsoft.Fade()";

                /*set fade-out filter - this doens't seem to be working*/
                submenuelement.filters(0).duration = parseFloat(_fadeOutDuration_s);
                submenuelement.filters(0).Apply();
                submenuelement.style.display = display;
                submenuelement.filters(0).Play();
            } //end if
        }// end if(isDisplay)

        /*Extend the bottom border for active menus*/
        if(activeParentMenuElement == parentmenuelement && isDisplay) {
            parentmenuelement.style.borderBottomWidth = 8 + "px";
        }

        submenuelement.style.display = display; // activate display mode
    } // end if
}// end function: startSubMenuToggle()


/************************************
TOGGLES PARENTMENU
************************************/
function toggleParentMenu(visibility) {
    if(document.images && parentmenuelement != undefined) {

        if(navBar.activeTab.length != 0)
            activeParentMenuElement = document.getElementById("img_"+navBar.activeTab);

        if(visibility == "on") {
            document.images[parentmenuelement.name].src =
                imagesOn[parentmenuelement.name].src;
            toggleParentMenuStyle(visibility, parentmenuelement);

            if(activeParentMenuElement != parentmenuelement
                && activeParentMenuElement != undefined) {
                document.images[activeParentMenuElement.name].src =
                    imagesOff[activeParentMenuElement.name].src;
                toggleParentMenuStyle("off", activeParentMenuElement);
            }
        } else if(visibility == "off") {
            document.images[parentmenuelement.name].src =
                imagesOff[parentmenuelement.name].src;
            toggleParentMenuStyle(visibility, parentmenuelement);

            if(activeParentMenuElement != undefined) {
                document.images[activeParentMenuElement.name].src =
                    imagesOn[activeParentMenuElement.name].src;
                toggleParentMenuStyle("on", activeParentMenuElement);
            }
        }// end else if
    }// end if
}// end function: toggleParentMenu()


/*Parent Menu styling variables*/
var oncolor = "#0E7009";
var onborderStyle = "solid";
var onborderWidth = 7; //IE NN=7
var onborderTopWidth = 8; //IE NN=8
var onborderBottomWidth = 8; //IE NN=8
var onTopPosition = -1;

var offcolor = "#339900";
var offborderStyle = "solid";
var offborderWidth = 7; //IE NN=7
var offborderTopWidth = 7; //IE NN=7
var offborderBottomWidth = 5; //IE NN=5
var offTopPosition = 0;

/************************************
STYLE ON AND OFF PARENT MENU MODES
************************************/
function toggleParentMenuStyle(visibility, pelement) {
    if(visibility == "on") {
        pelement.style.background = oncolor;
        pelement.style.border = oncolor + " " + onborderStyle +
            " " + onborderWidth + "px";
        pelement.style.borderTop = oncolor + " " + onborderStyle +
            " " + onborderTopWidth + "px";

        /*Shorten the bottom border if it's an active menu*/
        if(pelement == activeParentMenuElement) {
            if(submenuelement != undefined
                    && submenuelement.style.display == "block") {
                onborderBottomWidth = 8;
            } else {
                onborderBottomWidth = 7;
            }
        } else {
            onborderBottomWidth = 8;
        }

        pelement.style.borderBottom = oncolor + " " + onborderStyle +
            " " + onborderBottomWidth + "px";
        pelement.style.top = onTopPosition + "px";
    } else {
        pelement.style.background = offcolor;
        pelement.style.border = offcolor + " " + offborderStyle +
            " " + offborderWidth + "px";
        pelement.style.borderTop = offcolor + " " + offborderStyle +
            " " + offborderTopWidth + "px";
        pelement.style.borderBottom = offcolor + " " + offborderStyle +
            " " + offborderBottomWidth + "px";
        pelement.style.top = offTopPosition + "px";
    }
}


/************************************
CREATES IFRAM SHIM FOR IE BROWSERS
************************************/
function createIFrameShim(elementName) {
    var pxURI = navBar.resourcePath + "/images/topnav/17204/trans.gif";
    var iframe = document.createElement("<iframe class='" + elementName + "Iframeshim'" +
        " id='" +elementName +"Iframeshim' name='" + elementName + "Iframeshim' scrolling='no' frameborder='0' " +
        "style='position:absolute; top:0px; left:0px; display:none: border: red solid 1px;' z-order='500' src='" + pxURI + "'></iframe>");
    return iframe;
}


/************************************
CREATES DIV DROP SHADOWS FOR IE BROWSERS
************************************/
function createDivDropShadow() {
    var div = document.createElement("<div style='" +
        "position:absolute; top:0px; left:0px; display:none' z-order='400'></div>");
    return div;
}


/************************************
TOGGLES IFRAME SHIMS FOR IE BROWSERS
************************************/
function toggleIFrameShim(abX, abY, display){
        var loantypeDropDown = document.getElementsByName("typeOfLoan")[0];
        var loanTypeOffsetWidth =
                (loantypeDropDown == undefined) ? 0 : loantypeDropDown.offsetWidth;
        var loanTypeOffsetHeight =
                (loantypeDropDown == undefined) ? 0 : loantypeDropDown.offsetHeight;
        var statecodeDropDown = document.getElementsByName("propertyStateCode")[0];
        var statecodeOffsetWidth =
                (statecodeDropDown == undefined) ? 0 : statecodeDropDown.offsetWidth;
        var statecodeOffsetHeight =
                (statecodeDropDown == undefined) ? 0 : statecodeDropDown.offsetHeight;

        var loanTypeHtmlOffsetX = 0;
        var loanTypeHtmlOffsetY = 0;
        var stateHtmlOffsetX = 0;
        var stateHtmlOffsetY = 0;
        var parentTagName = "";
        /* you're only provided x,y coordinates of an element relative to its parent.
        Traverse up the DOM and perform a running sum of x,y coordinates until
        the state code and loan type select elements share the same parent as the
        menu, which is "HTML"*/
        while(parentTagName != "HTML") {
            try {
                if(loantypeDropDown != undefined) {
                    loanTypeHtmlOffsetX += loantypeDropDown.offsetLeft;
                    loanTypeHtmlOffsetY +=loantypeDropDown.offsetTop;
                }

                /* set the elements to its parent for the next iteration */
                loantypeDropDown = loantypeDropDown.offsetParent;
                parentTagName = loantypeDropDown.tagName;
            } catch (ex) {
                //This is a hack for Mortgage calculators.
                stateHtmlOffsetX += 10;
                break;
            }
        }// end while

        /* you're only provided x,y coordinates of an element relative to its parent.
        Traverse up the DOM and perform a running sum of x,y coordinates until
        the state code and loan type select elements share the same parent as the
        menu, which is "HTML"*/
        while(parentTagName != "HTML") {
            try {
                if(statecodeDropDown != undefined) {
                    stateHtmlOffsetX += statecodeDropDown.offsetLeft;
                    stateHtmlOffsetY += statecodeDropDown.offsetTop;
                }

                /* set the elements to its parent for the next iteration */
                statecodeDropDown = statecodeDropDown.offsetParent;
                parentTagName = statecodeDropDown.tagName;
            } catch (ex) {
                //This is a hack for Mortgage calculators.
                stateHtmlOffsetX += 10;
                break;
            }
        }// end while

        /*size and position loan type Iframe shim*/
        sizeAndPositionIFrameShim(loantypeiframeshim, parseInt(abX), parseInt(loanTypeHtmlOffsetX), parseInt(abY),
            parseInt(loanTypeHtmlOffsetY), parseInt(loanTypeOffsetWidth), parseInt(loanTypeOffsetHeight), display);

        /*size and position state property Iframe shim*/
        sizeAndPositionIFrameShim(statetypeiframeshim, parseInt(abX), parseInt(stateHtmlOffsetX), parseInt(abY), parseInt(stateHtmlOffsetY),
            parseInt(statecodeOffsetWidth), parseInt(statecodeOffsetHeight), display);
}// end function: toggleIFrameShim(...)


/************************************
SIZES AND POSITIONS IFRAME SHIMS FOR IE BROWSERS
************************************/
function sizeAndPositionIFrameShim(iframeshim, aX, oX, aY, oY, oW, oH, display) {
    if(iframeshim != undefined) {
        var ifrmX = 0;
        var ifrmY = 0;
        var ifrmW = 0;
        var ifrmH = 0;
        window.document.body.appendChild(iframeshim);

/*        window.status = iframeshim.getAttribute("id") + " aX: " + aX + " oX: " +
            oX + " aY: " + aY + " aW: " +  submenuDivWidth + " oW: " + oW +
            " aH: " + submenuDivHeight + " oH: " + oH;*/

        /*set iframX position and width*/
        if(oX <= aX && (oX + oW) >= aX) {
            ifrmX = aX;
            ifrmW = (oW + oX) - aX;
        } else if(oX >= aX && oX <= (aX + submenuDivWidth)) {
            ifrmX = oX;

            if((ifrmX + oW) <= (aX + submenuDivWidth)) {
                ifrmW = oW;
            } else if ((ifrmX + oW) > (aX + submenuDivWidth)) {
                ifrmW = (aX + submenuDivWidth) - ifrmX + (_dropshadowWidth*3);
            } // end else if
        }// enf if

        /*set iframeY position and height*/
        if(oY <= aY && (oY + oH) >= aY) {
            ifrmY = aY;
            ifrmH = (oH + oY) - aY;
        } else if(oY >= aY && oY <= (aY + submenuDivHeight)) {
            ifrmY = oY;

            if((ifrmY + oH) <= (aY + submenuDivHeight)) {
                ifrmH = oH;
            } else if ((ifrmY + oH) > (aY + submenuDivHeight)) {
                ifrmH = (aY + submenuDivHeight) - ifrmY + (_dropshadowWidth*3);
            } // end else if
        }// end if


        /*commit iframe size and position*/
        iframeshim.style.left = ifrmX + "px";
        iframeshim.style.top = ifrmY + "px";
        iframeshim.style.width = ifrmW + "px";
        iframeshim.style.height = ifrmH + "px";
        iframeshim.style.display = display;
    } // end if
} // end function: sizeAndPositionLoanTypeIFrameShim()


/************************************
TOGGLES TRI-LAYER DIV DROP SHADOWS FOR IE BROWSERS
************************************/
function toggleDropShadowDiv(abX, abY, display) {
    /*To make top nav compatible with new refactored pages,
    adjust offsets.*/
    var dsX = parseInt(abX) - _submenu.getOffsetX();
    var dsY = parseInt(abY) - _submenu.getOffsetY();
    var dsW = submenuDivWidth;
    var dsH = submenuDivHeight;
    window.document.body.appendChild(divDropShadowL1);
    window.document.body.appendChild(divDropShadowL2);
    window.document.body.appendChild(divDropShadowL3);

    /*style drop-shadow*/
    divDropShadowL1.style.borderRight = _dsColor + " " +
        _dropshadowWidth + "px solid";
    divDropShadowL1.style.borderBottom = _dsColor + " " +
        _dropshadowWidth + "px solid";
    divDropShadowL2.style.borderRight = _dsColor + " " +
        _dropshadowWidth + "px solid";
    divDropShadowL2.style.borderBottom = _dsColor + " " +
        _dropshadowWidth + "px solid";
    divDropShadowL2.style.zIndex = 399;
    divDropShadowL3.style.borderRight = _dsColor + " " +
        _dropshadowWidth + "px solid";
    divDropShadowL3.style.borderBottom = _dsColor + " " +
        _dropshadowWidth + "px solid";
    divDropShadowL3.style.zIndex = 398;

    divDropShadowL1.style.filter = "progid:DXImageTransform.Microsoft.Alpha()";
    divDropShadowL2.style.filter = "progid:DXImageTransform.Microsoft.Alpha()";
    divDropShadowL3.style.filter = "progid:DXImageTransform.Microsoft.Alpha()";

    /* style drop shadows*/
    divDropShadowL1.filters(0).style = "0";
    divDropShadowL1.filters(0).opacity = _dropshadowOpacity_start;
    divDropShadowL2.filters(0).style = "0";
    divDropShadowL2.filters(0).opacity = _dropshadowOpacity_start - 32;
    divDropShadowL3.filters(0).style = "0";
    divDropShadowL3.filters(0).opacity = _dropshadowOpacity_start - (32*2);

    /*commit dropshadow size and position*/
    divDropShadowL1.style.left = (dsX) + "px";
    divDropShadowL1.style.top = (dsY) + "px";
    divDropShadowL1.style.width = dsW + "px";
    divDropShadowL1.style.height = dsH + "px";
    divDropShadowL1.style.display = display;

    divDropShadowL2.style.left = (dsX + 1) + "px";
    divDropShadowL2.style.top = (dsY + 1) + "px";
    divDropShadowL2.style.width = dsW + "px";
    divDropShadowL2.style.height = dsH + "px";
    divDropShadowL2.style.display = display;

    divDropShadowL3.style.left = (dsX + 2) + "px";
    divDropShadowL3.style.top = (dsY + 2) + "px";
    divDropShadowL3.style.width = dsW + "px";
    divDropShadowL3.style.height = dsH + "px";
    divDropShadowL3.style.display = display;
}// end function: toggleDropShadowDiv();


/************************************
DRAWS THE MENU
************************************/
initDropDownTopNav();