
/**************************************************
    Utils
**************************************************/

// Here is the list of domain urls that are used throughout this script.  The values
// should be changed to match the environment the site is running on.  The following 
// are the domain urls for test and production environments.
//
// TEST:    bairdLocation="tstrwbaird.rwbaird.com"
//          scivantageLocation="tstbairdonline.rwbaird.com"
// PROD:    bairdLocation="www.rwbaird.com"
//          scivantageLocation="bairdonline.rwbaird.com"
var bairdLocation="www.rwbaird.com";
var scivantageLocation="bairdonline.rwbaird.com";


// This is the key used to tell the go page which
// search results page to go to.
var searchResultsGotoKey="SearchResults_RWB";


// This function should be called each time the page loads.  It sets up 
// what the navigation should look like depending on the segment of the page
// and if the page is a public page or not.  A public page is a page that a
// user does not need to be logged in to view.
function Baird_OnPageLoad(segment, publicPage)  {

    // Setup the url for the images to keep sessions alive.
    Baird_LoadKeepAliveImages();
    
    // If a user is logged in or the page is a private page, display 
    // the correct Login Selector Controls. 
    if (Baird_CheckForLoginCookie()==true || !publicPage)  {
    
        if (Baird_ElementExists("Master_LoginSelector_Panel"))  {
            document.getElementById("Master_LoginSelector_LoginPanel").style.display="none";
            document.getElementById("Master_LoginSelector_LogoutPanel").style.display="";
        }
        
        // If the page is a private page and the user is logged in, do
        // not show the Return To, Find Advisor, and Market Tool Links.
        if (!publicPage)  {
            
            if (Baird_ElementExists("Master_LoginSelector_Panel"))  {
                document.getElementById("Master_LoginSelector_ReturnToLoginCell").style.display="none";
            }
            if (Baird_ElementExists("Master_FunctionalNavigation_Panel"))  {
                document.getElementById("Master_FunctionalNavigation_AdvisorCell").style.display="none";
                document.getElementById("Master_FunctionalNavigation_MarketToolsCell").style.display="none";
            }
        }
    }
    
    // Show/Hide controls in the navigation depending on the segment of the page.
    Baird_SetSegmentControls(segment);
    
    // Set some search control styles when the page loads.
    Baird_SearchEntry_OnLoad();
}


// This function is called when the page loads to set the urls to the images
// used to keep cookie sessions alive so when a user is browsing pages at
// a vendor the login cookie for Baird does not expire and vice versa.
function Baird_LoadKeepAliveImages()  {
    
    if (Baird_ElementExists("Baird_KeepAliveImage"))  {
        document.getElementById("Baird_KeepAliveImage").src="https://" + bairdLocation + "/Images/BairdKeepAlive.gif";
    }
    if (Baird_ElementExists("Scivantage_KeepAliveImage"))  {
        document.getElementById("Scivantage_KeepAliveImage").src="https://" + scivantageLocation + "/Modules/Login/keepAlive.php";
    }
}


// All links that are going back to Baird come through this function to create the
// correct url back to Baird.  All links will be sent to a go.aspx page at baird 
// with the name of the page.  The go.aspx page will then redirect the user to 
// the correct page.
function Baird_GotoBairdPage(name, qstring, popup)  {
    var url
    
    // Assign qstring to an empty string if it was not set by the caller.
    if (qstring==undefined)  {
        qstring="";
    }    
    
    // Assign popup to false if it was not set by the caller.
    if (popup==undefined)  {
        popup=false;
    }    
    
    // Set the url we are going to goto.
    url=Baird_GetGotoUrl(name, qstring)    
    
    // Check the name of the page to see how this page should be opened.
    switch(name.toLowerCase())  {
        
        // These pages open with a warning message
        // before opening the page in a standard popup window.
        case "morningstarhome":
            if (!Baird_LeavingSiteWarning())  {
                break;
            }

        // These pages open in the standard popup window.
        case "helphome":
        case "importantinformation":
        case "privacypolicy":
        case "businesscontinuity":
        case "finra":
        case "sipc":
        case "accountprotection":
        case "useragreement":
        case "investorinformationsites":
            Baird_GotoPopUpPage(url);
            break;
            
        // Theses pages open in a new full window.
        case "marketwatchtermsofuse":
        case "comstockhome":
        case "comstocktermsofuse":
        case "ftinteractivedatahome":
        case "hemscotthome":
            window.open(url);
            break

        // Open all other page names in the current window.
        default:
            // Check to see if this should be opened in the standard popup.
            if (popup)  {
                Baird_GotoPopUpPage(url);
            } else {
                window.location.href=url;
            }
    }
}


// Opens the the url in a standard popup window.
function Baird_GotoPopUpPage(url)  {
    window.open(url,"HelpPopupPage","height=480px,width=990px,scrollbars=1,location=0,menubar=1,toolbar=0,resizable=1");
}


// Create the Goto page url
function Baird_GetGotoUrl(name, qstring)  {
    var url
    var protocol="http://"
    var loc=document.location.href.toLowerCase()
    
    // Add the to parameter and page name to the beginning of the query string.
    qstring="?to=" + name + qstring
    
    // Append the current account to the query string if it exists.
    qstring=Baird_AppendCurrentAccount(qstring)

    // See if we are on a secure page and change the protocol accordingly

    if (loc.indexOf("https")==0)  {
        protocol="https://"
    }
    
    // Create the url to send the user too.
    url = protocol + bairdLocation + "/Go.aspx" + qstring;
    
    return url
}


// Lets the user know that they are leaving the Baird site 
// and allows them to cancel before redirecting them.
function Baird_LeavingSiteWarning()  {
    return confirm("You are now leaving the Robert W. Baird site. We are not endorsing or responsible for the content on other sites. Please read the TERMS AND CONDITIONS in the Help section of our site for more information. Do you wish to proceed?");
}


// This will search the current page location and look for a
// current account query string value.  If one is found it is
// parsed out of the string and appended to the query
// string and returned to the caller.
function Baird_AppendCurrentAccount(qstring)  {
    var queryString=window.location.search.toLowerCase();
    var currentAccountIndex=queryString.indexOf("currentaccount");
    var value="";
    
    // If the currentAccount text is in the query string parse out the value.
    if (currentAccountIndex != -1)  {
        var acctToEnd = queryString.substr(currentAccountIndex+15)
        var ampPos = acctToEnd.indexOf("&");
        if (ampPos == -1) {
            value=acctToEnd;
        }  else  {
            value=acctToEnd.substr(0,ampPos);
        }
    }

    // Append the current account to the query string if it exists.
    if (value != "")  {
        if (qstring.indexOf("?") != -1) {
            qstring=qstring+"&";
        }  else  {
            qstring=qstring+"?";
        }
        
        qstring = qstring + "currentAccount=" + value;
    }
    
    return qstring;
}


// This function is called on each page load to setup the look
// of the navigation depending on the segment the page is for.
function Baird_SetSegmentControls(segment)  {

    if (Baird_ElementExists("Master_MainNavigationHolder"))  {
        switch(segment.toLowerCase())  {
            case "about":
                document.getElementById("Master_FunctionalNavigation_AdvisorCell").style.display="none";
                document.getElementById("Master_FunctionalNavigation_MarketToolsCell").style.display="none";
                document.getElementById("Master_GlobalNavigation_AboutLink").style.color="#999999";
                document.getElementById("Master_FunctionalNavigation_ContactUsLink").href="javascript:Baird_GotoBairdPage('AboutBairdContactUs')";
                document.getElementById("Master_SearchEntry_SearchSegment").value="AboutBaird";
                break;
            case "individuals":
                document.getElementById("Master_GlobalNavigation_IndividualLink").style.color="#999999";
                document.getElementById("Master_FunctionalNavigation_ContactUsLink").href="javascript:Baird_GotoBairdPage('IndividualsContactUs')";
                document.getElementById("Master_SearchEntry_SearchSegment").value="Individuals";
                break;
            case "corporations":
                document.getElementById("Master_FunctionalNavigation_AdvisorCell").style.display="none";
                document.getElementById("Master_FunctionalNavigation_MarketToolsCell").style.display="none";
                document.getElementById("Master_GlobalNavigation_CorporationsLink").style.color="#999999";
                document.getElementById("Master_FunctionalNavigation_ContactUsLink").href="javascript:Baird_GotoBairdPage('CorporationsInstitutionsContactUs')";
                document.getElementById("Master_SearchEntry_SearchSegment").value="CorporationsInstitutions";
                break;
            case "research":
                document.getElementById("Master_GlobalNavigation_ResearchLink").style.color="#999999";
                document.getElementById("Master_FunctionalNavigation_ContactUsLink").href="javascript:Baird_GotoBairdPage('ResearchInsightsContactUs')";
                document.getElementById("Master_SearchEntry_SearchSegment").value="ResearchInsights";
                break;
            default:
                document.getElementById("Master_FunctionalNavigation_AdvisorCell").style.display="none";
                document.getElementById("Master_FunctionalNavigation_MarketToolsCell").style.display="none";
                document.getElementById("Master_FunctionalNavigation_ContactUsLink").href="javascript:Baird_GotoBairdPage('AboutBairdContactUs')";
                document.getElementById("Master_SearchEntry_SearchSegment").value="none";
        }
    }
    
    // Now that we are done changing around the panels, show them.
    Baird_ShowHiddenPanels();
    
}


// Function shows the panels that are hidden until
// thier segment changes have been made
function Baird_ShowHiddenPanels()  {
    
    if (Baird_ElementExists("Master_LoginSelector_Panel"))  {
        document.getElementById("Master_LoginSelector_Panel").style.display="";
    }
    if (Baird_ElementExists("Master_FunctionalNavigation_Panel"))  {
        document.getElementById("Master_FunctionalNavigation_Panel").style.display="";
    }

}


// This function will look for the Baird authorization cookie and
// return true if it was found or false if it was not found.
function Baird_CheckForLoginCookie()  {
    var index;

    if (window.document.cookie.length > 0) {
        index = window.document.cookie.indexOf('bear');
    } else {
        index=-1;
    }

    if (index == -1) {
        return false;
    }  else  {
        return true;
    }
}


// Function checks to see if the element passed to it exists on the page.
// Return true if it does, otherwise it returns false.
function Baird_ElementExists(id)  {
    if (document.getElementById(id) != null)  {
        return true;
    } else {
        return false;
    }
}


/**************************************************
    Login Selector
**************************************************/

// This function is called when there is a change to the value
// selected for the login selector.  If a login is selected the
// user is redirected to the correct login page through the go.asx page.
function Baird_LoginSelector_Change(element)  {
    var selectorValue=document.getElementById("Master_LoginSelector_LoginSelectionList").value;
    
    if (selectorValue.toLowerCase() != "none")  {
        Baird_GotoBairdPage(selectorValue,'')
    }    
}



/**************************************************
    Search Entry
**************************************************/

// Called each time the page is loaded to set some styles 
// depending on the browser being used to view the page.
function Baird_SearchEntry_OnLoad()  {
    var isIE = window.navigator && window.navigator.appName == "Microsoft Internet Explorer" && !window.opera;
    if (isIE)  {
        if (Baird_ElementExists("Master_SearchEntry_Panel"))  {
            window.document.getElementById("Master_SearchEntry_SearchButtonSpacer").style.height=16;
        }
    }
}


// When the user clicks to enter a value to search for this function
// is called to remove the default text if it is in the text box.
function Baird_SearchEntryText_OnFocus(element)  {
    if (element.value.replace(/^\s+|\s+$/g,"") == document.getElementById("Master_SearchEntry_DefaultSearchText").value)  {
        element.value="";
    }
}


// If the user exits the search text box this function is called and puts the
// default text back into the search text box if nothing else was entered.
function Baird_SearchEntryText_OnBlur(element)  {
    if (element.value.replace(/^\s+|\s+$/g,"") == "")  {
        element.value=document.getElementById("Master_SearchEntry_DefaultSearchText").value;
    }
}


// Is called whenever a key press event occurs in the search text box
// in order to catch an enter key click.  We want to have the enter key
// press act as if the search button was clicked.
function Baird_SearchEntryText_EnterKeyPress(e, buttonid)  { 
    var evt = e ? e : window.event;
    if (evt.keyCode == 13)  { 
        Baird_SearchEntryButton_OnClick(document.getElementById(buttonid));
        return false; 
    } 
}


// Function captures the search entry button click and checks to see if the user has
// entered a search string.  If there is a search string the user is redirected to
// the baird search page through the go.aspx page, otherwise an error message is displayed.
function Baird_SearchEntryButton_OnClick(element)  {
    var searchText = document.getElementById("Master_SearchEntry_SearchText").value.replace(/^\s+|\s+$/g,"");
    if (searchText=="" || searchText==document.getElementById("Master_SearchEntry_DefaultSearchText").value)  {
        alert("Please enter a word or phrase and search again.");
    }  else  {
        Baird_GotoBairdPage(searchResultsGotoKey,"&query=" + escape(searchText));
    }
}



/**************************************************
    BreadcrumbMenu
**************************************************/

// The following functions and settings are a modified version of the
// script code that Microsoft spits out when the menu control is being
// used.  Some modifications were needed to be made to the code in
// order to get the breadcrumb control (which is a modified version 
// of the menu control) to work according to the requirements for it.
var Master_GlobalBreadcrumbMenu_Data = new Object();
Master_GlobalBreadcrumbMenu_Data.disappearAfter = 500;
Master_GlobalBreadcrumbMenu_Data.horizontalOffset = 0;
Master_GlobalBreadcrumbMenu_Data.verticalOffset = 0;
Master_GlobalBreadcrumbMenu_Data.hoverClass = 'DynamicHoverStyle';
Master_GlobalBreadcrumbMenu_Data.hoverHyperLinkClass = 'DynamicHoverStyle';
Master_GlobalBreadcrumbMenu_Data.staticHoverClass = 'StaticHoverStyle';
Master_GlobalBreadcrumbMenu_Data.staticHoverHyperLinkClass = 'StaticHoverStyle';

var __rootBreadcrumbMenuItem;
var __breadcrumbMenuInterval;
var __breadcrumbMenuScrollPanel;
var __breadcrumbMenuDisappearAfter = 500;
function BreadcrumbMenu_ClearInterval() {
    if (__breadcrumbMenuInterval) {
        window.clearInterval(__breadcrumbMenuInterval);
    }
}
function BreadcrumbMenu_Collapse(item) {
    BreadcrumbMenu_SetRoot(item);
    if (__rootBreadcrumbMenuItem) {
        BreadcrumbMenu_ClearInterval();
        if (__breadcrumbMenuDisappearAfter >= 0) {
            __breadcrumbMenuInterval = window.setInterval("BreadcrumbMenu_HideItems()", __breadcrumbMenuDisappearAfter);
        }
    }
}
function BreadcrumbMenu_Expand(item, horizontalOffset, verticalOffset, hideScrollers) {
    // Opera does not expand menus correctly so do not show them
    if (window.opera) { 
        return null;
    }    
    
    BreadcrumbMenu_ClearInterval();
    var tr = item.parentNode.parentNode.parentNode.parentNode.parentNode;
    var horizontal = true;
    if (!tr.id) {
        horizontal = false;
        tr = tr.parentNode;
    }
    var child = BreadcrumbMenu_FindSubMenu(item);
    if (child) {
        var menudepth = child.getAttribute("menudepth");
        var isIE = window.navigator && window.navigator.appName == "Microsoft Internet Explorer" && !window.opera;
        var isSafari = window.navigator.userAgent.toLowerCase().indexOf('safari') != -1
        var isFirefox = window.navigator.userAgent.toLowerCase().indexOf('firefox') != -1
        
        if (menudepth == 1) {
            verticalOffset=verticalOffset-1;
        }
        else {
            
            if (isIE || isSafari) {
                horizontalOffset=horizontalOffset-1;
            }
            else {
                horizontalOffset=horizontalOffset+1;
            }

        }
        var data = BreadcrumbMenu_GetData(item);
        if (!data) {
            return null;
        }
        child.rel = tr.id;
        child.x = horizontalOffset;
        child.y = verticalOffset;
        if (horizontal) child.pos = "bottom";
        BreadcrumbMenu_PopOut_Show(child.id, hideScrollers, data);
    }
    BreadcrumbMenu_SetRoot(item);
    if (child) {
        if (!document.body.__oldOnClick && document.body.onclick) {
            document.body.__oldOnClick = document.body.onclick;
        }
        if (__rootBreadcrumbMenuItem) {
            document.body.onclick = BreadcrumbMenu_HideItems;
        }
    }
    BreadcrumbMenu_ResetSiblings(tr);
    return child;
}
function BreadcrumbMenu_FindMenu(item) {
    if (item && item.menu) return item.menu;
    var tr = item.parentNode.parentNode.parentNode.parentNode.parentNode;
    if (!tr.id) {
        tr = tr.parentNode;
    }
    for (var i = tr.id.length - 1; i >= 0; i--) {
        if (tr.id.charAt(i) < '0' || tr.id.charAt(i) > '9') {
            var menu = BreadcrumbMenu_GetElementById(tr.id.substr(0, i));
            if (menu) {
                item.menu = menu;
                return menu;
            }
        }
    }
    return null;
}
function BreadcrumbMenu_FindNext(item) {
    var a = BreadcrumbMenu_GetElementByTagName(item, "A");
    var parent = BreadcrumbMenu_FindParentContainer(item);
    var first = null;
    if (parent) {
        var links = BreadcrumbMenu_GetElementsByTagName(parent, "A");
        var match = false;
        for (var i = 0; i < links.length; i++) {
            var link = links[i];
            if (BreadcrumbMenu_IsSelectable(link)) {
                if (BreadcrumbMenu_FindParentContainer(link) == parent) {
                    if (match) {
                        return link;
                    }
                    else if (!first) {
                        first = link;
                    }
                }
                if (!match && link == a) {
                    match = true;
                }
            }
        }
    }
    return first;
}
function BreadcrumbMenu_FindParentContainer(item) {
    if (item.menu_ParentContainerCache) return item.menu_ParentContainerCache;
    var a = (item.tagName.toLowerCase() == "a") ? item : BreadcrumbMenu_GetElementByTagName(item, "A");
    var menu = BreadcrumbMenu_FindMenu(a);
    if (menu) {
        var parent = item;
        while (parent && parent.tagName &&
            parent.id != menu.id &&
            parent.tagName.toLowerCase() != "div") {
            parent = parent.parentNode;
        }
        item.menu_ParentContainerCache = parent;
        return parent;
    }
}
function BreadcrumbMenu_FindParentItem(item) {
    var parentContainer = BreadcrumbMenu_FindParentContainer(item);
    var parentContainerID = parentContainer.id;
    var len = parentContainerID.length;
    if (parentContainerID && parentContainerID.substr(len - 5) == "Items") {
        var parentItemID = parentContainerID.substr(0, len - 5);
        return BreadcrumbMenu_GetElementById(parentItemID);
    }
    return null;
}
function BreadcrumbMenu_FindPrevious(item) {
    var a = BreadcrumbMenu_GetElementByTagName(item, "A");
    var parent = BreadcrumbMenu_FindParentContainer(item);
    var last = null;
    if (parent) {
        var links = BreadcrumbMenu_GetElementsByTagName(parent, "A");
        for (var i = 0; i < links.length; i++) {
            var link = links[i];
            if (BreadcrumbMenu_IsSelectable(link)) {
                if (link == a && last) {
                    return last;
                }
                if (BreadcrumbMenu_FindParentContainer(link) == parent) {
                    last = link;
                }
            }
        }
    }
    return last;
}
function BreadcrumbMenu_FindSubMenu(item) {
    var tr = item.parentNode.parentNode.parentNode.parentNode.parentNode;
    if (!tr.id) {
        tr=tr.parentNode;
    }
    return BreadcrumbMenu_GetElementById(tr.id + "Items");
}
function BreadcrumbMenu_Focus(item) {
    if (item && item.focus) {
        var pos = BreadcrumbMenu_GetElementPosition(item);
        var parentContainer = BreadcrumbMenu_FindParentContainer(item);
        if (!parentContainer.offset) {
            parentContainer.offset = 0;
        }
        var posParent = BreadcrumbMenu_GetElementPosition(parentContainer);
        var delta;
        if (pos.y + pos.height > posParent.y + parentContainer.offset + parentContainer.clippedHeight) {
            delta = pos.y + pos.height - posParent.y - parentContainer.offset - parentContainer.clippedHeight;
            BreadcrumbMenu_PopOut_Scroll(parentContainer, delta);
        }
        else if (pos.y < posParent.y + parentContainer.offset) {
            delta = posParent.y + parentContainer.offset - pos.y;
            BreadcrumbMenu_PopOut_Scroll(parentContainer, -delta);
        }
        BreadcrumbMenu_PopOut_HideScrollers(parentContainer);
        item.focus();
    }
}
function BreadcrumbMenu_GetData(item) {
    if (!item.data) {
        var a = (item.tagName.toLowerCase() == "a" ? item : BreadcrumbMenu_GetElementByTagName(item, "a"));
        var menu = BreadcrumbMenu_FindMenu(a);
        try {
            item.data = eval(menu.id + "_Data");
        }
        catch(e) {}
    }
    return item.data;
}
function BreadcrumbMenu_HideItems(items) {
    
    if (document.body.__oldOnClick) {
        document.body.onclick = document.body.__oldOnClick;
        document.body.__oldOnClick = null;
    }
    BreadcrumbMenu_ClearInterval();
    if (!items || ((typeof(items.tagName) == "undefined") && (items instanceof Event))) {
        items = __rootBreadcrumbMenuItem;
    }
    var table = items;
    if ((typeof(table) == "undefined") || (table == null) || !table.tagName || (table.tagName.toLowerCase() != "table")) {
        table = BreadcrumbMenu_GetElementByTagName(table, "TABLE");
    }
    if ((typeof(table) == "undefined") || (table == null) || !table.tagName || (table.tagName.toLowerCase() != "table")) {
        return;
    }
    var rows = table.rows ? table.rows : table.firstChild.rows;
    var isVertical = false;
    for (var r = 0; r < rows.length; r++) {
        if (rows[r].id) {
            isVertical = true;
            break;
        }
    }
    var i, child, nextLevel;
    if (isVertical) {
        for(i = 0; i < rows.length; i++) {
            if (rows[i].id) {
                child = BreadcrumbMenu_GetElementById(rows[i].id + "Items");
                if (child) {
                    BreadcrumbMenu_HideItems(child);
                }
            }
            else if (rows[i].cells[0]) {
                nextLevel = BreadcrumbMenu_GetElementByTagName(rows[i].cells[0], "TABLE");
                if (nextLevel) {
                    BreadcrumbMenu_HideItems(nextLevel);
                }
            }
        }
    }
    else {
        for(i = 0; i < rows[0].cells.length; i++) {
            if (rows[0].cells[i].id) {
                child = BreadcrumbMenu_GetElementById(rows[0].cells[i].id + "Items");
                if (child) {
                    BreadcrumbMenu_HideItems(child);
                }
            }
            else {
                nextLevel = BreadcrumbMenu_GetElementByTagName(rows[0].cells[i], "TABLE");
                if (nextLevel) {
                    BreadcrumbMenu_HideItems(rows[0].cells[i].firstChild);
                }
            }
        }
    }
    if (items && items.id) {
        BreadcrumbMenu_PopOut_Hide(items.id);
    }
}
function BreadcrumbMenu_HoverDisabled(item) {
    var node = (item.tagName.toLowerCase() == "td") ?
        item:
        item.cells[0];
    var data = BreadcrumbMenu_GetData(item);
    if (!data) return;
    node = BreadcrumbMenu_GetElementByTagName(node, "table").rows[0].cells[0].childNodes[0];
    if (data.disappearAfter >= 200) {
        __breadcrumbMenuDisappearAfter = data.disappearAfter;
    }
    BreadcrumbMenu_Expand(node, data.horizontalOffset, data.verticalOffset); 
}
function BreadcrumbMenu_HoverDynamic(item) {
    var node = (item.tagName.toLowerCase() == "td") ?
        item:
        item.cells[0];
    var data = BreadcrumbMenu_GetData(item);
    if (!data) return;
    var nodeTable = BreadcrumbMenu_GetElementByTagName(node, "table");
    if (data.hoverClass) {
        nodeTable.hoverClass = data.hoverClass;
        BreadcrumbMenu_AppendToClassName(nodeTable, data.hoverClass);
    }
    node = nodeTable.rows[0].cells[0].childNodes[0];
    if (data.hoverHyperLinkClass) {
        node.hoverHyperLinkClass = data.hoverHyperLinkClass;
        BreadcrumbMenu_AppendToClassName(node, data.hoverHyperLinkClass);
    }
    if (data.disappearAfter >= 200) {
        __breadcrumbMenuDisappearAfter = data.disappearAfter;
    }
    BreadcrumbMenu_Expand(node, data.horizontalOffset, data.verticalOffset); 
}
function BreadcrumbMenu_HoverRoot(item) {
    var node = (item.tagName.toLowerCase() == "td") ?
        item:
        item.cells[0];
    var data = BreadcrumbMenu_GetData(item);
    if (!data) {
        return null;
    }
    var nodeTable = BreadcrumbMenu_GetElementByTagName(node, "table");
    if (data.staticHoverClass) {
        nodeTable.atRestClass = nodeTable.className;
        nodeTable.hoverClass = data.staticHoverClass;
        BreadcrumbMenu_AppendToClassName(nodeTable, data.staticHoverClass);
    }
    node = nodeTable.rows[0].cells[0].childNodes[0];
    if (data.staticHoverHyperLinkClass) {
        node.hoverHyperLinkClass = data.staticHoverHyperLinkClass;
        BreadcrumbMenu_AppendToClassName(node, data.staticHoverHyperLinkClass);
    }
    return node;
}
function BreadcrumbMenu_HoverStatic(item) {
    // Opera does not expand menus correctly so do not do anything on a hover.
    if (window.opera) { 
        return null;
    }    

    // Do not do hover if static menu item does not have children    
    var child = BreadcrumbMenu_GetElementById(item.id+"Items");
    if (!child) {
        return null;
    }
    
    var node = BreadcrumbMenu_HoverRoot(item);
    var data = BreadcrumbMenu_GetData(item);
    if (!data) return;
    __breadcrumbMenuDisappearAfter = data.disappearAfter;
    BreadcrumbMenu_Expand(node, data.horizontalOffset, data.verticalOffset); 
}
function BreadcrumbMenu_IsHorizontal(item) {
    if (item) {
        var a = ((item.tagName && (item.tagName.toLowerCase == "a")) ? item : BreadcrumbMenu_GetElementByTagName(item, "A"));
        if (!a) {
            return false;
        }
        var td = a.parentNode.parentNode.parentNode.parentNode.parentNode;
        if (td.id) {
            return true;
        }
    }
    return false;
}
function BreadcrumbMenu_IsSelectable(link) {
    return (link && link.href)
}
function BreadcrumbMenu_Key(item) {
    var event;
    if (window.event) {
        event = window.event;
    }
    else {
        event = item;
        item = event.currentTarget;
    }
    var key = (event ? event.keyCode : -1);
    var data = BreadcrumbMenu_GetData(item);
    if (!data) return;
    var horizontal = BreadcrumbMenu_IsHorizontal(item);
    var a = BreadcrumbMenu_GetElementByTagName(item, "A");
    var nextItem, parentItem, previousItem;
    if ((!horizontal && key == 38) || (horizontal && key == 37)) {
        previousItem = BreadcrumbMenu_FindPrevious(item);
        while (previousItem && previousItem.disabled) {
            previousItem = BreadcrumbMenu_FindPrevious(previousItem);
        }
        if (previousItem) {
            BreadcrumbMenu_Focus(previousItem);
            BreadcrumbMenu_Expand(previousItem, data.horizontalOffset, data.verticalOffset, true);
            event.cancelBubble = true;
            if (event.stopPropagation) event.stopPropagation();
            return;
        }
    }
    if ((!horizontal && key == 40) || (horizontal && key == 39)) {
        if (horizontal) {
            var subMenu = BreadcrumbMenu_FindSubMenu(a);
            if (subMenu && subMenu.style && subMenu.style.visibility && 
                subMenu.style.visibility.toLowerCase() == "hidden") {
                BreadcrumbMenu_Expand(a, data.horizontalOffset, data.verticalOffset, true);
                event.cancelBubble = true;
                if (event.stopPropagation) event.stopPropagation();
                return;
            }
        }
        nextItem = BreadcrumbMenu_FindNext(item);
        while (nextItem && nextItem.disabled) {
            nextItem = BreadcrumbMenu_FindNext(nextItem);
        }
        if (nextItem) {
            BreadcrumbMenu_Focus(nextItem);
            BreadcrumbMenu_Expand(nextItem, data.horizontalOffset, data.verticalOffset, true);
            event.cancelBubble = true;
            if (event.stopPropagation) event.stopPropagation();
            return;
        }
    }
    if ((!horizontal && key == 39) || (horizontal && key == 40)) {
        var children = BreadcrumbMenu_Expand(a, data.horizontalOffset, data.verticalOffset, true);
        if (children) {
            var firstChild;
            children = BreadcrumbMenu_GetElementsByTagName(children, "A");
            for (var i = 0; i < children.length; i++) {
                if (!children[i].disabled && BreadcrumbMenu_IsSelectable(children[i])) {
                    firstChild = children[i];
                    break;
                }
            }
            if (firstChild) {
                BreadcrumbMenu_Focus(firstChild);
                BreadcrumbMenu_Expand(firstChild, data.horizontalOffset, data.verticalOffset, true);
                event.cancelBubble = true;
                if (event.stopPropagation) event.stopPropagation();
                return;
            }
        }
        else {
            parentItem = BreadcrumbMenu_FindParentItem(item);
            while (parentItem && !BreadcrumbMenu_IsHorizontal(parentItem)) {
                parentItem = BreadcrumbMenu_FindParentItem(parentItem);
            }
            if (parentItem) {
                nextItem = BreadcrumbMenu_FindNext(parentItem);
                while (nextItem && nextItem.disabled) {
                    nextItem = BreadcrumbMenu_FindNext(nextItem);
                }
                if (nextItem) {
                    BreadcrumbMenu_Focus(nextItem);
                    BreadcrumbMenu_Expand(nextItem, data.horizontalOffset, data.verticalOffset, true);
                    event.cancelBubble = true;
                    if (event.stopPropagation) event.stopPropagation();
                    return;
                }
            }
        }
    }
    if ((!horizontal && key == 37) || (horizontal && key == 38)) {
        parentItem = BreadcrumbMenu_FindParentItem(item);
        if (parentItem) {
            if (BreadcrumbMenu_IsHorizontal(parentItem)) {
                previousItem = BreadcrumbMenu_FindPrevious(parentItem);
                while (previousItem && previousItem.disabled) {
                    previousItem = BreadcrumbMenu_FindPrevious(previousItem);
                }
                if (previousItem) {
                    BreadcrumbMenu_Focus(previousItem);
                    BreadcrumbMenu_Expand(previousItem, data.horizontalOffset, data.verticalOffset, true);
                    event.cancelBubble = true;
                    if (event.stopPropagation) event.stopPropagation();
                    return;
                }
            }
            var parentA = BreadcrumbMenu_GetElementByTagName(parentItem, "A");
            if (parentA) {
                BreadcrumbMenu_Focus(parentA);
            }
            BreadcrumbMenu_ResetSiblings(parentItem);
            event.cancelBubble = true;
            if (event.stopPropagation) event.stopPropagation();
            return;
        }
    }
    if (key == 27) {
        BreadcrumbMenu_HideItems();
        event.cancelBubble = true;
        if (event.stopPropagation) event.stopPropagation();
        return;
    }
}
function BreadcrumbMenu_ResetSiblings(item) {
    var table = (item.tagName.toLowerCase() == "td") ?
        item.parentNode.parentNode.parentNode :
        item.parentNode.parentNode;
    var isVertical = false;
    for (var r = 0; r < table.rows.length; r++) {
        if (table.rows[r].id) {
            isVertical = true;
            break;
        }
    }
    var i, child, childNode;
    if (isVertical) {
        for(i = 0; i < table.rows.length; i++) {
            childNode = table.rows[i];
            if (childNode != item) {
                child = BreadcrumbMenu_GetElementById(childNode.id + "Items");
                if (child) {
                    BreadcrumbMenu_HideItems(child);
                }
            }
        }
    }
    else {
        for(i = 0; i < table.rows[0].cells.length; i++) {
            childNode = table.rows[0].cells[i];
            if (childNode != item) {
                child = BreadcrumbMenu_GetElementById(childNode.id + "Items");
                if (child) {
                    BreadcrumbMenu_HideItems(child);
                }
            }
        }
    }
    BreadcrumbMenu_ResetTopMenus(table, table, 0, true);
}
function BreadcrumbMenu_ResetTopMenus(table, doNotReset, level, up) {
    var i, child, childNode;
    if (up && table.id == "") {
        var parentTable = table.parentNode.parentNode.parentNode.parentNode;
        if (parentTable.tagName.toLowerCase() == "table") {
            BreadcrumbMenu_ResetTopMenus(parentTable, doNotReset, level + 1, true);
        }
    }
    else {
        if (level == 0 && table != doNotReset) {
            if (table.rows[0].id) {
                for(i = 0; i < table.rows.length; i++) {
                    childNode = table.rows[i];
                    child = BreadcrumbMenu_GetElementById(childNode.id + "Items");
                    if (child) {
                        BreadcrumbMenu_HideItems(child);
                    }
                }
            }
            else {
                for(i = 0; i < table.rows[0].cells.length; i++) {
                    childNode = table.rows[0].cells[i];
                    child = BreadcrumbMenu_GetElementById(childNode.id + "Items");
                    if (child) {
                        BreadcrumbMenu_HideItems(child);
                    }
                }
            }
        }
        else if (level > 0) {
            for (i = 0; i < table.rows.length; i++) {
                for (var j = 0; j < table.rows[i].cells.length; j++) {
                    var subTable = table.rows[i].cells[j].firstChild;
                    if (subTable && subTable.tagName.toLowerCase() == "table") {
                        BreadcrumbMenu_ResetTopMenus(subTable, doNotReset, level - 1, false);
                    }
                }
            }
        }
    }
}
function BreadcrumbMenu_RestoreInterval() {
    if (__breadcrumbMenuInterval && __rootBreadcrumbMenuItem) {
        BreadcrumbMenu_ClearInterval();
        __breadcrumbMenuInterval = window.setInterval("BreadcrumbMenu_HideItems()", __breadcrumbMenuDisappearAfter);
    }
}
function BreadcrumbMenu_SetRoot(item) {
    var newRoot = BreadcrumbMenu_FindMenu(item);
    if (newRoot) {
        if (__rootBreadcrumbMenuItem && __rootBreadcrumbMenuItem != newRoot) {
            BreadcrumbMenu_HideItems();
        }
        __rootBreadcrumbMenuItem = newRoot;
    }
}
function BreadcrumbMenu_UnhoverStatic(item) {
    var node = (item.tagName.toLowerCase() == "td") ?
        item:
        item.cells[0];
    BreadcrumbMenu_Collapse(node);
}
function BreadcrumbMenu_UnhoverDynamic(item) {
    var node = (item.tagName.toLowerCase() == "td") ?
        item:
        item.cells[0];
    var children = BreadcrumbMenu_GetElementById(item.id + "Items");
    if(!children) {
        var nodeTable = BreadcrumbMenu_GetElementByTagName(node, "table");
        if (nodeTable.hoverClass) {
            BreadcrumbMenu_RemoveClassName(nodeTable, nodeTable.hoverClass);
        }
        node = nodeTable.rows[0].cells[0].childNodes[0];
        if (node.hoverHyperLinkClass) {
            BreadcrumbMenu_RemoveClassName(node, node.hoverHyperLinkClass);
        }
    }
    BreadcrumbMenu_Collapse(node);
}
function BreadcrumbMenu_UnhoverClass(item) {
    var counter;
    var node = (item.tagName.toLowerCase() == "td") ?
        item:
        item.cells[0];
    var nodeTable = BreadcrumbMenu_GetElementByTagName(node, "table");
    counter=0;
    if (nodeTable.hoverClass) {
        do {
            BreadcrumbMenu_RemoveClassName(nodeTable, nodeTable.hoverClass);
            counter=counter+1;
        }
        while (nodeTable.className.indexOf(nodeTable.hoverClass)!=-1 && counter<20)
    }
    node = nodeTable.rows[0].cells[0].childNodes[0];
    counter=0;
    if (node.hoverHyperLinkClass) {
        do {
            BreadcrumbMenu_RemoveClassName(node, node.hoverHyperLinkClass);
            counter=counter+1;
        }
        while (node.className.indexOf(node.hoverHyperLinkClass)!=-1 && counter<20)
    }
}
function BreadcrumbMenu_PopOut_Clip(element, y, height) {
    if (element && element.style) {
        element.style.clip = "rect(" + y + "px auto " + (y + height) + "px auto)";
        element.style.overflow = "hidden";
    }
}
function BreadcrumbMenu_PopOut_Down(scroller) {
    BreadcrumbMenu_ClearInterval();
    var panel;
    if (scroller) {
        panel = scroller.parentNode
    }
    else {
        panel = __breadcrumbMenuScrollPanel;
    }
    if (panel && ((panel.offset + panel.clippedHeight) < panel.physicalHeight)) {
        BreadcrumbMenu_PopOut_Scroll(panel, 2)
        __breadcrumbMenuScrollPanel = panel;
        BreadcrumbMenu_PopOut_ShowScrollers(panel);
        BreadcrumbMenu_PopOut_Stop();
        __breadcrumbMenuScrollPanel.interval = window.setInterval("BreadcrumbMenu_PopOut_Down()", 8);
    }
    else {
        BreadcrumbMenu_PopOut_ShowScrollers(panel);
    }
}
function BreadcrumbMenu_PopOut_Hide(panelId) {
    var panel = BreadcrumbMenu_GetElementById(panelId);

    if (panel && panel.tagName.toLowerCase() == "div") {
        panel.style.visibility = "hidden";
        panel.style.display = "none";
        panel.offset = 0;
        panel.scrollTop = 0;

        var td = BreadcrumbMenu_GetElementById(panelId.substr(0, panelId.length - 5));
        BreadcrumbMenu_UnhoverClass(td);

        var table = BreadcrumbMenu_GetElementByTagName(panel, "TABLE");
        if (table) {
            BreadcrumbMenu_SetElementY(table, 0);
        }
        if (window.navigator && window.navigator.appName == "Microsoft Internet Explorer" &&
            !window.opera) {
            var childFrameId = panel.id + "_MenuIFrame";
            var childFrame = BreadcrumbMenu_GetElementById(childFrameId);
            if (childFrame) {
                childFrame.style.display = "none";
            }
        }
    }
}
function BreadcrumbMenu_PopOut_HideScrollers(panel) {
    if (panel && panel.style) {
        var up = BreadcrumbMenu_GetElementById(panel.id + "Up");
        var dn = BreadcrumbMenu_GetElementById(panel.id + "Dn");
        if (up) {
            up.style.visibility = "hidden";
            up.style.display = "none";
        }
        if (dn) {
            dn.style.visibility = "hidden";
            dn.style.display = "none";
        }
    }
}
function BreadcrumbMenu_PopOut_Position(panel, hideScrollers) {
    if (window.opera) {
        panel.parentNode.removeChild(panel);
        document.forms[0].appendChild(panel);
    }
    var rel = BreadcrumbMenu_GetElementById(panel.rel);
    var relTable = BreadcrumbMenu_GetElementByTagName(rel, "TABLE");
    var relCoordinates = BreadcrumbMenu_GetElementPosition(relTable ? relTable : rel);
    var panelCoordinates = BreadcrumbMenu_GetElementPosition(panel);
    var panelHeight = ((typeof(panel.physicalHeight) != "undefined") && (panel.physicalHeight != null)) ?
        panel.physicalHeight :
        panelCoordinates.height;
    panel.physicalHeight = panelHeight;
    var panelParentCoordinates;
    if (panel.offsetParent) {
        panelParentCoordinates = BreadcrumbMenu_GetElementPosition(panel.offsetParent);
    }
    else {
        panelParentCoordinates = new Object();
        panelParentCoordinates.x = 0;
        panelParentCoordinates.y = 0;
    }
    var overflowElement = BreadcrumbMenu_GetElementById("__overFlowElement");
    if (!overflowElement) {
        overflowElement = document.createElement("img");
        overflowElement.id="__overFlowElement";
        BreadcrumbMenu_SetElementWidth(overflowElement, 1);
        document.body.appendChild(overflowElement);
    }
    BreadcrumbMenu_SetElementHeight(overflowElement, panelHeight + relCoordinates.y + parseInt(panel.y ? panel.y : 0));
    overflowElement.style.visibility = "visible";
    overflowElement.style.display = "inline";
    var clientHeight = 0;
    var clientWidth = 0;
    if (window.innerHeight) {
        clientHeight = window.innerHeight;
        clientWidth = window.innerWidth;
    }
    else if (document.documentElement && document.documentElement.clientHeight) {
        clientHeight = document.documentElement.clientHeight;
        clientWidth = document.documentElement.clientWidth;
    }
    else if (document.body && document.body.clientHeight) {
        clientHeight = document.body.clientHeight;
        clientWidth = document.body.clientWidth;
    }
    var scrollTop = 0;
    var scrollLeft = 0;
    if (typeof(window.pageYOffset) != "undefined") {
        scrollTop = window.pageYOffset;
        scrollLeft = window.pageXOffset;
    }
    else if (document.documentElement && (typeof(document.documentElement.scrollTop) != "undefined")) {
        scrollTop = document.documentElement.scrollTop;
        scrollLeft = document.documentElement.scrollLeft;
    }
    else if (document.body && (typeof(document.body.scrollTop) != "undefined")) {
        scrollTop = document.body.scrollTop;
        scrollLeft = document.body.scrollLeft;
    }
    overflowElement.style.visibility = "hidden";
    overflowElement.style.display = "none";
    var bottomWindowBorder = clientHeight + scrollTop;
    var rightWindowBorder = clientWidth + scrollLeft;
    var position = panel.pos;
    if ((typeof(position) == "undefined") || (position == null) || (position == "")) {
        position = (BreadcrumbMenu_GetElementDir(rel) == "rtl" ? "middleleft" : "middleright");
    }
    position = position.toLowerCase();
    var y = relCoordinates.y + parseInt(panel.y ? panel.y : 0) - panelParentCoordinates.y;
    var borderParent = (rel && rel.parentNode && rel.parentNode.parentNode && rel.parentNode.parentNode.parentNode
        && rel.parentNode.parentNode.parentNode.tagName.toLowerCase() == "div") ?
        rel.parentNode.parentNode.parentNode : null;
    BreadcrumbMenu_SetElementY(panel, y);
    BreadcrumbMenu_PopOut_SetPanelHeight(panel, panelHeight, true);
    var clip = false;
    var overflow;
    if (position.indexOf("top") != -1) {
        y -= panelHeight;
        BreadcrumbMenu_SetElementY(panel, y); 
        if (y < -panelParentCoordinates.y) {
            y = -panelParentCoordinates.y;
            BreadcrumbMenu_SetElementY(panel, y); 
            if (panelHeight > clientHeight - 2) {
                clip = true;
                BreadcrumbMenu_PopOut_SetPanelHeight(panel, clientHeight - 2);
            }
        }
    }
    else {
        if (position.indexOf("bottom") != -1) {
            y += relCoordinates.height;
            BreadcrumbMenu_SetElementY(panel, y); 
        }
        overflow = y + panelParentCoordinates.y + panelHeight - bottomWindowBorder;
        if (overflow > 0) {
            y -= overflow;
            BreadcrumbMenu_SetElementY(panel, y); 
            if (y < -panelParentCoordinates.y) {
                y = 2 - panelParentCoordinates.y + scrollTop;
                BreadcrumbMenu_SetElementY(panel, y); 
                clip = true;
                BreadcrumbMenu_PopOut_SetPanelHeight(panel, clientHeight - 2);
            }
        }
    }
    if (!clip) {
        BreadcrumbMenu_PopOut_SetPanelHeight(panel, panel.clippedHeight, true);
    }
    var panelParentOffsetY = 0;
    if (panel.offsetParent) {
        panelParentOffsetY = BreadcrumbMenu_GetElementPosition(panel.offsetParent).y;
    }
    var panelY = ((typeof(panel.originY) != "undefined") && (panel.originY != null)) ?
        panel.originY :
        y - panelParentOffsetY;
    panel.originY = panelY;
    if (!hideScrollers) {
        BreadcrumbMenu_PopOut_ShowScrollers(panel);
    }
    else {
        BreadcrumbMenu_PopOut_HideScrollers(panel);
    }
    var x = relCoordinates.x + parseInt(panel.x ? panel.x : 0) - panelParentCoordinates.x;
    if (borderParent && borderParent.clientLeft) {
        x += 2 * borderParent.clientLeft;
    }
    BreadcrumbMenu_SetElementX(panel, x);
    if (position.indexOf("left") != -1) {
        x -= panelCoordinates.width;
        BreadcrumbMenu_SetElementX(panel, x);
        if (x < -panelParentCoordinates.x) {
            BreadcrumbMenu_SetElementX(panel, -panelParentCoordinates.x);
        }
    }
    else {
        if (position.indexOf("right") != -1) {
            x += relCoordinates.width;
            BreadcrumbMenu_SetElementX(panel, x);
        }
        overflow = x + panelParentCoordinates.x + panelCoordinates.width - rightWindowBorder;
        if (overflow > 0) {
            if (position.indexOf("bottom") == -1 && relCoordinates.x > panelCoordinates.width) {
                x -= relCoordinates.width + panelCoordinates.width;
            }
            else {
                x -= overflow;
            }
            BreadcrumbMenu_SetElementX(panel, x);
            if (x < -panelParentCoordinates.x) {
                BreadcrumbMenu_SetElementX(panel, -panelParentCoordinates.x);
            }
        }
    }
}
function BreadcrumbMenu_PopOut_Scroll(panel, offsetDelta) {
    var table = BreadcrumbMenu_GetElementByTagName(panel, "TABLE");
    if (!table) return;
    table.style.position = "relative";
    var tableY = (table.style.top ? parseInt(table.style.top) : 0);
    panel.offset += offsetDelta;
    BreadcrumbMenu_SetElementY(table, tableY - offsetDelta);
}
function BreadcrumbMenu_PopOut_SetPanelHeight(element, height, doNotClip) {
    if (element && element.style) {
        var size = BreadcrumbMenu_GetElementPosition(element);
        element.physicalWidth = size.width;
        element.clippedHeight = height;
        BreadcrumbMenu_SetElementHeight(element, height - (element.clientTop ? (2 * element.clientTop) : 0));
        if (doNotClip && element.style) {
            element.style.clip = "rect(auto auto auto auto)";
        }
        else {
            BreadcrumbMenu_PopOut_Clip(element, 0, height);
        }
    }
}
function BreadcrumbMenu_PopOut_Show(panelId, hideScrollers, data) {
    var panel = BreadcrumbMenu_GetElementById(panelId);
    if (panel && panel.tagName.toLowerCase() == "div") {
        panel.style.visibility = "visible";
        panel.style.display = "inline";
        if (!panel.offset || hideScrollers) {
            panel.scrollTop = 0;
            panel.offset = 0;
            var table = BreadcrumbMenu_GetElementByTagName(panel, "TABLE");
            if (table) {
                BreadcrumbMenu_SetElementY(table, 0);
            }
        }
        BreadcrumbMenu_PopOut_Position(panel, hideScrollers);
        var z = 1;
        var isIE = window.navigator && window.navigator.appName == "Microsoft Internet Explorer" && !window.opera;
        if (isIE && data) {
            var childFrameId = panel.id + "_MenuIFrame";
            var childFrame = BreadcrumbMenu_GetElementById(childFrameId);
            var parent = panel.offsetParent;
            if (!childFrame) {
                childFrame = document.createElement("iframe");
                childFrame.id = childFrameId;
                childFrame.src = (data.iframeUrl ? data.iframeUrl : "about:blank");
                childFrame.style.position = "absolute";
                childFrame.style.display = "none";
                childFrame.scrolling = "no";
                childFrame.frameBorder = "0";
                if (parent.tagName.toLowerCase() == "html") {
                    document.body.appendChild(childFrame);
                }
                else {
                    parent.appendChild(childFrame);
                }
            }
            var pos = BreadcrumbMenu_GetElementPosition(panel);
            var parentPos = BreadcrumbMenu_GetElementPosition(parent);
            BreadcrumbMenu_SetElementX(childFrame, pos.x - parentPos.x);
            BreadcrumbMenu_SetElementY(childFrame, pos.y - parentPos.y);
            BreadcrumbMenu_SetElementWidth(childFrame, pos.width);
            BreadcrumbMenu_SetElementHeight(childFrame, pos.height);
            childFrame.style.display = "block";
            if (panel.currentStyle && panel.currentStyle.zIndex) {
                z = panel.currentStyle.zIndex;
            }
            else if (panel.style.zIndex) {
                z = panel.style.zIndex;
            }
        }
        panel.style.zIndex = z;
    }
}
function BreadcrumbMenu_PopOut_ShowScrollers(panel) {
    if (panel && panel.style) {
        var up = BreadcrumbMenu_GetElementById(panel.id + "Up");
        var dn = BreadcrumbMenu_GetElementById(panel.id + "Dn");
        var cnt = 0;
        if (up && dn) {
            if (panel.offset && panel.offset > 0) {
                up.style.visibility = "visible";
                up.style.display = "inline";
                cnt++;
                if (panel.clientWidth) {
                    BreadcrumbMenu_SetElementWidth(up, panel.clientWidth
                        - (up.clientLeft ? (2 * up.clientLeft) : 0));
                }
                BreadcrumbMenu_SetElementY(up, 0);
            }
            else {
                up.style.visibility = "hidden";
                up.style.display = "none";
            }
            if (panel.offset + panel.clippedHeight + 2 <= panel.physicalHeight) {
                dn.style.visibility = "visible";
                dn.style.display = "inline";
                cnt++;
                if (panel.clientWidth) {
                    BreadcrumbMenu_SetElementWidth(dn, panel.clientWidth
                        - (dn.clientLeft ? (2 * dn.clientLeft) : 0));
                }
                BreadcrumbMenu_SetElementY(dn, panel.clippedHeight - BreadcrumbMenu_GetElementPosition(dn).height
                    - (panel.clientTop ? (2 * panel.clientTop) : 0));
            }
            else {
                dn.style.visibility = "hidden";
                dn.style.display = "none";
            }
            if (cnt == 0) {
                panel.style.clip = "rect(auto auto auto auto)";
            }
        }
    }
}
function BreadcrumbMenu_PopOut_Stop() {
    if (__breadcrumbMenuScrollPanel && __breadcrumbMenuScrollPanel.interval) {
        window.clearInterval(__breadcrumbMenuScrollPanel.interval);
    }
    BreadcrumbMenu_RestoreInterval();
}
function BreadcrumbMenu_PopOut_Up(scroller) {
    BreadcrumbMenu_ClearInterval();
    var panel;
    if (scroller) {
        panel = scroller.parentNode
    }
    else {
        panel = __breadcrumbMenuScrollPanel;
    }
    if (panel && panel.offset && panel.offset > 0) {
        BreadcrumbMenu_PopOut_Scroll(panel, -2);
        __breadcrumbMenuScrollPanel = panel;
        BreadcrumbMenu_PopOut_ShowScrollers(panel);
        BreadcrumbMenu_PopOut_Stop();
        __breadcrumbMenuScrollPanel.interval = window.setInterval("BreadcrumbMenu_PopOut_Up()", 8);
    }
}

function BreadcrumbMenu_AppendToClassName(element, className) {
    var current = element.className;
    if (current) {
        if (current.charAt(current.length - 1) != ' ') {
            current += ' ';
        }
        current += className;
    }
    else {
        current = className;
    }
    element.className = current;
}
function BreadcrumbMenu_RemoveClassName(element, className) {
    var current = element.className;
    if (current) {
        if (current.substring(current.length - className.length - 1, current.length) == ' ' + className) {
            element.className = current.substring(0, current.length - className.length - 1);
            return;
        }
        if (current == className) {
            element.className = "";
            return;
        }
        var index = current.indexOf(' ' + className + ' ');
        if (index != -1) {
            element.className = current.substring(0, index) + current.substring(index + className.length + 2, current.length);
            return;
        }
        if (current.substring(0, className.length) == className + ' ') {
            element.className = current.substring(className.length + 1, current.length);
        }
    }
}
function BreadcrumbMenu_GetElementById(elementId) {
    if (document.getElementById) {
        return document.getElementById(elementId);
    }
    else if (document.all) {
        return document.all[elementId];
    }
    else return null;
}
function BreadcrumbMenu_GetElementByTagName(element, tagName) {
    var elements = BreadcrumbMenu_GetElementsByTagName(element, tagName);
    if (elements && elements.length > 0) {
        return elements[0];
    }
    else return null;
}
function BreadcrumbMenu_GetElementsByTagName(element, tagName) {
    if (element && tagName) {
        if (element.getElementsByTagName) {
            return element.getElementsByTagName(tagName);
        }
        if (element.all && element.all.tags) {
            return element.all.tags(tagName);
        }
    }
    return null;
}
function BreadcrumbMenu_GetElementDir(element) {
    if (element) {
        if (element.dir) {
            return element.dir;
        }
        return BreadcrumbMenu_GetElementDir(element.parentNode);
    }
    return "ltr";
}
function BreadcrumbMenu_GetElementPosition(element) {
    var result = new Object();
    result.x = 0;
    result.y = 0;
    result.width = 0;
    result.height = 0;
    if (element.offsetParent) {
        result.x = element.offsetLeft;
        result.y = element.offsetTop;
        var parent = element.offsetParent;
        while (parent) {
            result.x += parent.offsetLeft;
            result.y += parent.offsetTop;
            var parentTagName = parent.tagName.toLowerCase();
            if (parentTagName != "table" &&
                parentTagName != "body" && 
                parentTagName != "html" && 
                parentTagName != "div" && 
                parent.clientTop && 
                parent.clientLeft) {
                result.x += parent.clientLeft;
                result.y += parent.clientTop;
            }
            parent = parent.offsetParent;
        }
    }
    else if (element.left && element.top) {
        result.x = element.left;
        result.y = element.top;
    }
    else {
        if (element.x) {
            result.x = element.x;
        }
        if (element.y) {
            result.y = element.y;
        }
    }
    if (element.offsetWidth && element.offsetHeight) {
        result.width = element.offsetWidth;
        result.height = element.offsetHeight;
    }
    else if (element.style && element.style.pixelWidth && element.style.pixelHeight) {
        result.width = element.style.pixelWidth;
        result.height = element.style.pixelHeight;
    }
    return result;
}
function BreadcrumbMenu_GetParentByTagName(element, tagName) {
    var parent = element.parentNode;
    var upperTagName = tagName.toUpperCase();
    while (parent && (parent.tagName.toUpperCase() != upperTagName)) {
        parent = parent.parentNode ? parent.parentNode : parent.parentElement;
    }
    return parent;
}
function BreadcrumbMenu_SetElementHeight(element, height) {
    if (element && element.style) {
        element.style.height = height + "px";
    }
}
function BreadcrumbMenu_SetElementWidth(element, width) {
    if (element && element.style) {
        element.style.width = width + "px";
    }
}
function BreadcrumbMenu_SetElementX(element, x) {
    if (element && element.style) {
        element.style.left = x + "px";
    }
}
function BreadcrumbMenu_SetElementY(element, y) {
    if (element && element.style) {
        element.style.top = y + "px";
    }
}
