﻿
    document.write('<script src="//quote.morningstar.com/acindex/ojacb.js" language="javascript"></' + 'script>');
    function srchTerm(sSearchType) {
        if (sSearchType == "search") {
            document.searchForm.SrchTerm.value = document.searchForm.sSrchTerm.value;
            document.searchForm.action = "http://search.morningstar.com/MstarSrch/MstarSrch2.aspx";
            document.searchForm.submit();
        }
        else {
            if (document.quoteForm.sSrchTerm.value == "") {
                document.quoteForm.action = "http://quote.morningstar.com/TickerNotFound.html";
                document.quoteForm.submit();
            }
            else {
                document.quoteForm.action = "http://quote.morningstar.com/switch.html?ticker=" + document.quoteForm.sSrchTerm.value;
                document.quoteForm.submit();
            }
        }
    }

    function ClearSearchBox(sSearchType) {
        if (sSearchType == "quote") {
            var text = document.quoteForm.sSrchTerm.value;
            if (text == "Quotes")
                document.quoteForm.sSrchTerm.value = "";
        }
        else {
            var text = document.searchForm.sSrchTerm.value;
            if (text == "Search")
                document.searchForm.sSrchTerm.color = "#FFFFFF";
            document.searchForm.sSrchTerm.value = "";
        }
    }



    //-->


    var newclass;
    function initBoxQuote() {
        CheckOSBrowser();             //check the Browser
        var allcache = new Array(SCOPE_SIZE);
        var pos = new Array(SCOPE_SIZE);
        initCache(allcache, pos);
        //box1 and box share the cache 'allcache'.
        newclass = new AutoCompleteBox("AutoCompleteBox", "AutoCompleteDropDown", 4, null, null, "quoteForm", allcache, pos, null, true, '');
        newclass.IdleDisplayMsg = 'Quotes';
    }



    function showFooterDropdown(event, obj) {
        var cla = document.getElementById("footerUL")
        if (obj != null && cla != null) {
            if (cla.style == null || cla.style.display == null || cla.style.display != "block") {
                cla.style.display = "block";
            }
            else {
                cla.style.display = "none";
            }
        }
    }
    function srchTermFooter(sSearchType) {
        if (sSearchType == "search") {
            document.searchFormFooter.SrchTerm.value = document.searchFormFooter.sSrchTerm.value;
            document.searchFormFooter.action = "http://search.morningstar.com/MstarSrch/MstarSrch2.aspx";
            document.searchFormFooter.submit();
        } else {
            if (document.quoteFormFooter.sSrchTerm.value == "") {
                document.quoteFormFooter.action = "http://quote.morningstar.com/TickerNotFound.html";
                document.quoteFormFooter.submit();
            }
            else {
                document.quoteFormFooter.action = "http://quote.morningstar.com/switch.html?ticker=" + document.quoteFormFooter.sSrchTerm.value;
                document.quoteFormFooter.submit();
            }
        }
    }

    function ClearSearchBoxFooter(sSearchType) {
        if (sSearchType == "quoteFooter") {
            var text = document.quoteFormFooter.sSrchTerm.value;
            if (text == "Quotes")
                document.quoteFormFooter.sSrchTerm.value = "";
        }
        else {
            var text = document.searchFormFooter.sSrchTerm.value;
            if (text == "Search")
                document.searchFormFooter.sSrchTerm.color = "#FFFFFF";
            document.searchFormFooter.sSrchTerm.value = "";
        }
    }
    var newclassF;
    function initFootBoxQuote() {
        CheckOSBrowser();             //check the Browser
        var allcache = new Array(SCOPE_SIZE);
        var pos = new Array(SCOPE_SIZE);
        initCache(allcache, pos);

        //box1 and box share the cache 'allcache'.
        newclassF = new AutoCompleteBox("AutoCompleteBoxFooter", "AutoCompleteDropDownFooter", 4, null, null, "quoteFormFooter", allcache, pos, null, true, '');
        newclassF.IdleDisplayMsg = 'Quotes';
    }

    var footXmlHttp;
    var mapId = "";
    if (window.XMLHttpRequest) {
        footXmlHttp = new XMLHttpRequest();

        if (footXmlHttp.overrideMimeType) {
            footXmlHttp.overrideMimeType("text/xml");
        }
    }
    else if (window.ActiveXObject) {
        footXmlHttp = new ActiveXObject("Microsoft.XMLHttp");
    }
    function getFooterMapHtml(name) {
        var url = StaticResource + "FooterMap/" + name + ".htm";
        mapId = name;
        footXmlHttp.open("Get", url, true);
        footXmlHttp.onreadystatechange = function() {
            if (footXmlHttp.readyState == 4) {
                var doc = document.getElementById(mapId);
                if (doc != null) doc.innerHTML = footXmlHttp.responseText;
            }
        };
        footXmlHttp.send(null);
    }

    function swapout(id, obj) {
        idlookup(id);
        activate(obj);
        getFooterMapHtml(id);
    }

    //swaps out link states-----------------------------------------------------------------------------------------------
    var linkIDs = new Array('nav1', 'nav2', 'nav3'); //array of links
    function turnofflinks(id) { document.getElementById(id).className = 'f_sdirtab'; } //changes links to off mode
    function offalllinks() { for (var i = 0; i < linkIDs.length; i++) { turnofflinks(linkIDs[i]); } }

    //turns on selected link
    //first it reverts the links to off mode
    //then sets the one pressed into on mode
    function activate(obj) { if (obj.className == 'f_sdirtab') { offalllinks(obj); obj.className = 'f_sdirtabOn'; } }
    //--------------------------------------------------------------------------------------------------------------------


    //clears all content/image boxes--------------------------------------------------------------------------------------
    var imageIDs = new Array('siteDirectoryContent', 'siteMapContent', 'productsContent'); //content boxes
    function idlookup(id) {
        if (document.getElementById(id).style.display != 'block')
            doton(id);
    }

    function turnoffimages(id) { document.getElementById(id).style.display = 'none'; } //changes content boxes to off mode
    function offallimages() { for (var i = 0; i < imageIDs.length; i++) { turnoffimages(imageIDs[i]); } } //function to set all content boxes to off mode

    function doton(id) {
        offallimages();
        document.getElementById(id).style.display = 'block';
        var opacityTween = new OpacityTween(document.getElementById(id), Tween.strongEaseInOut, 0, 100, .75);
        opacityTween.start();
    }
    //-------------------------------------------------------------------------------------------------------------------
    var StaticResource = "";
    var HeaderFooter = function() {
        var headerContainerObj = null;
        var ActiveIdx = -1;
        this.SetActiveIdx = function(idx) {
            if (idx >= 0) {
                ActiveIdx = idx;
                if (headerContainerObj != null) {
                    var navList = headerContainerObj.find("[vkey='nav'] a");
                    if (navList.length > idx) {
                        $(navList[idx]).attr("class", "h_tab1On");
                    }
                }
            }

        };

        this.InitHeader = function(headerContainer, cname, subHF) {
            this.headerContainerObj = $("#" + headerContainer);
            var thisObj = this;
            var link = StaticResource + "js/header.htm";
            if (subHF) {
                link = StaticResource + "js/" + subHF + "/header.htm";
            }
            $.get(link, function(data) {
                var container = $("#" + headerContainer);
                container.html(data);
                if (cname != "" && cname != null) {
                    container.find("[vkey='cname']").html(" " + cname);
                    container.find("[vkey='logIn']").each(function() {
                        $(this).css("display", "none");
                    });
                    container.find("[vkey='logOut']").each(function() {
                        $(this).css("display", "block");
                    });
                }
                if (!subHF) {
                    initBoxQuote();
                    headerContainerObj = container;
                    thisObj.SetActiveIdx(ActiveIdx);
                }
            });

        };
        this.InitFooter = function(footerContainer, cname, subHF) {
        var link = StaticResource + "js/footer.htm";
            if (subHF) {
                link = StaticResource + "js/" + subHF + "/footer.htm";
            }
            $.get(link, function(data) {
                var container = $("#" + footerContainer);
                container.html(data);
                var year = (new Date()).getFullYear();

                if (year > 2009) {
                    container.find("[vkey='year']").html(year);
                }
                if (!subHF) {
                    initFootBoxQuote();
                }
            });

        };
    };

