window.__smartNav.loadNewContent = function()

in Hands-on lab/lab-files/BigDataTravel/BigDataTravel/Scripts/WebForms/SmartNav.js [50:144]


	window.__smartNav.loadNewContent = function()
	{
		var sn = window.__smartNav;
		var fd;
		try { fd = frames["__hifSmartNav"].document; } catch (e) {return;}
        if ((typeof(sn.sHif) != "undefined") && (sn.sHif != null))
        {
            sn.sHif.removeNode(true);
            sn.sHif = null;
        }
        var hdm = document.getElementsByTagName("head")[0];
        var hk = hdm.childNodes;
        var tt = null;
        var i;
        for (i = hk.length - 1; i>= 0; i--)
        {
            if (hk[i].tagName == "TITLE")
            {
                tt = hk[i].outerHTML;
                continue;
            }
            if (hk[i].tagName != "BASEFONT" || hk[i].innerHTML.length == 0)
                hdm.removeChild(hdm.childNodes[i]);
        }
        var kids = fd.getElementsByTagName("head")[0].childNodes;
        for (i = 0; i < kids.length; i++)
        {
            var tn = kids[i].tagName;
            var k = document.createElement(tn);
            k.id = kids[i].id;
            k.mergeAttributes(kids[i]);
            switch(tn)
            {
            case "TITLE":
                if (tt == kids[i].outerHTML)
                    continue;
                k.innerText = kids[i].text;
                hdm.insertAdjacentElement("afterbegin", k);
                continue;
            case "BASEFONT" :
                if (kids[i].innerHTML.length > 0)
                    continue;
                break;
            default:
                var o = document.createElement("BODY");
                o.innerHTML = "<BODY>" + kids[i].outerHTML + "</BODY>";
                k = o.firstChild;
                break;
            }
            if((typeof(k) != "undefined") && (k != null))
                hdm.appendChild(k);
        }
        document.body.clearAttributes();
        document.body.id = fd.body.id;
        document.body.mergeAttributes(fd.body);
        var newBodyLoad = fd.body.onload;
        if ((typeof(newBodyLoad) != "undefined") && (newBodyLoad != null))
            document.body.onload = newBodyLoad;
        else
            document.body.onload = sn._savedOnLoad;
        var s = "<BODY>" + fd.body.innerHTML + "</BODY>";
        if ((typeof(sn.hif) != "undefined") && (sn.hif != null))
        {
            var hifP = sn.hif.parentElement;
            if ((typeof(hifP) != "undefined") && (hifP != null))
                sn.sHif=hifP.removeChild(sn.hif);
        }
        document.body.innerHTML = s;
        var sc = document.scripts;
        for (i = 0; i < sc.length; i++)
        {
            sc[i].text = sc[i].text;
        }
        sn.hif = document.all("__hifSmartNav");
        if ((typeof(sn.hif) != "undefined") && (sn.hif != null))
        {
            var hif = sn.hif;
            sn.hifName = "__hifSmartNav" + (new Date()).getTime();
            frames["__hifSmartNav"].name = sn.hifName;
            sn.hifDoc = hif.contentWindow.document;
            if (sn.ie5)
                hif.parentElement.removeChild(hif);
            window.setTimeout(sn.restoreFocus,0);
        }
        if (typeof(window.onload) == "string")
        {
            try { eval(window.onload) } catch (e) {};
        }
        else if ((typeof(window.onload) != "undefined") && (window.onload != null))
        {
            try { window.onload() } catch (e) {};
        }
        sn._savedOnLoad = null;
        sn.attachForm();
    };