﻿var installedVer = null;

function getQueryString(name) {
    var result = "";
    if (typeof (window.location.search) != "undefined") {
        var query = window.location.search.substring(1);
        var vars = query.split("&");
        for (var i = 0; i < vars.length; i++) {
            var pair = vars[i].split("=");
            if (pair[0] == name) {
                result = pair[1];
                break;
            }
        }
    }
    return result;
}

findElementByClass = function(tag, className) {
    var result = null;
    var tags = document.getElementsByTagName(tag);
    className = className.toLowerCase();
    for (var i = 0; i < tags.length; i++) {
        var classes = tags[i].className.toLowerCase().split(' ');
        for (var c = 0; c < classes.length; c++) {
            if (classes[c] == className) {
                result = tags[i];
                break;
            }
        }
    }
    return result;
}

showDropdownMenu = function() {
    var nav = findElementByClass("DIV", "SecondaryNav");
    if (nav != null) {
        var anchors = nav.getElementsByTagName("A");
        var spans = nav.getElementsByTagName("SPAN");
        for (var a = 0; a < anchors.length; a++) {
            var element = anchors[a];
            if (element.className.length == 0) {
                element.className = "DropdownMenuVisible";
            }
            else {
                element.className += " DropdownMenuVisible";
            }
        }
        for (var s = 0; s < spans.length; s++) {
            var element = spans[s];
            if (element.className.length == 0) {
                element.className = "DropdownMenuVisible";
            }
            else {
                element.className += " DropdownMenuVisible";
            }
        }
    }

    nav = findElementByClass("DIV", "PrimaryNav");
    if (nav != null) {
        nav.className += " DropdownMenuVisible";
    }
}

hideDropdownMenu = function() {
    var nav = findElementByClass("DIV", "SecondaryNav");
    if (nav != null) {
        var anchors = nav.getElementsByTagName("A");
        var spans = nav.getElementsByTagName("SPAN");
        for (var a = 0; a < anchors.length; a++) {
            var element = anchors[a];
            var start = element.className.indexOf(" DropdownMenuVisible");
            if (start > -1) {
                element.className = element.className.substring(0, start);
            }
            else {
                element.className = "";
            }
        }
        for (var s = 0; s < spans.length; s++) {
            var element = spans[s];
            var start = element.className.indexOf(" DropdownMenuVisible");
            if (start > -1) {
                element.className = element.className.substring(0, start);
            }
            else {
                element.className = "";
            }
        }
    }

    nav = findElementByClass("DIV", "PrimaryNav");
    if (nav != null) {
        nav.className = "PrimaryNav";
    }
}

hookUpNavEvents = function() {
    //    var primaryNav = findElementByClass("DIV", "PrimaryNav");
    //    if (primaryNav != null)
    //    {
    //        var dropdownMenus = primaryNav.getElementsByTagName("UL");
    //        for (var l=0; l<dropdownMenus.length; l++)
    //        {
    //             // We only want the submenus, not the first level of the menu.
    //             // Also, we don't want to do anything with the selected submenu since
    //             // it will already be showing in the SecondaryNav and we won't show
    //             // its corresponding dropdown.
    //            if (dropdownMenus[l].className.toLowerCase() != "aspnet-menu")
    //            {
    //                dropdownMenuParent = dropdownMenus[l].parentNode; // This should be an "LI" tag in the UL that is the top-level menu
    //                if ((dropdownMenuParent.className.toLowerCase().indexOf("aspnet-menu-selected") == -1) &&
    //                    (dropdownMenuParent.className.toLowerCase().indexOf("aspnet-menu-childselected") == -1))
    //                {
    //                    dropdownMenuParent.onmouseover = showDropdownMenu;
    //                    dropdownMenuParent.onmouseout = hideDropdownMenu;
    //                    
    //                    if ((typeof(window.addEventListener) != "undefined") && (window.addEventListener != null)) 
    //                    {
    //                        window.addEventListener('onmouseover', showDropdownMenu , false);
    //                        window.addEventListener('onmouseover', hideDropdownMenu , false);
    //                    }
    //                    else 
    //                    {
    //                        window.attachEvent('onmouseover', showDropdownMenu);
    //                        window.attachEvent('onmouseover', hideDropdownMenu);
    //                    }
    //                }
    //            }
    //        }
    //    }
}

adjustWidthsForLocStrings = function() {
    var dashboardContainer = document.getElementById("dashboard-container");
    var dashboard = document.getElementById("dashboard");
    var dashboardBackground1 = document.getElementById("dashboard-background-1");
    var dashboardBackground2 = document.getElementById("dashboard-background-2");

    var divs = document.getElementsByTagName("DIV");
    var primaryNav = findElementByClass("DIV", "PrimaryNav");
    var secondaryNav = findElementByClass("DIV", "SecondaryNav");
    var primaryLists = null;
    var primaryTopList = null;
    if (primaryNav != null) {
        primaryLists = primaryNav.getElementsByTagName("UL");
        for (var l = 0; l < primaryLists.length; l++) {
            if (primaryLists[l].className.toLowerCase() == "aspnet-menu") {
                primaryTopList = primaryLists[l];
                break;
            }
        }
    }

    if ((dashboardContainer != null) && (dashboard != null) && (dashboardBackground1 != null) && (dashboardBackground2 != null) && (primaryNav != null) && (primaryTopList != null) && (secondaryNav != null)) {
        secondaryNav.style.right = "auto";
        secondaryNav.style.whiteSpace = "nowrap";

        var items = primaryNav.getElementsByTagName("LI");

        var primaryNavRequiredWidth = 0;
        var bFoundSelectedItem = false;
        var primaryNavRequiredWidthBeforeSelectedItem = 0;
        for (var k = 0; k < items.length; k++) {
            // The primary level of the menu can have submenu (dropdowns). We are only interested (here)
            // in the LI tags within the main primary level, not its submenu items. So we only look at
            // LI tags whose parent is the primary level's top UL element (primaryTopList).
            if (items[k].parentNode == primaryTopList) {
                primaryNavRequiredWidth += items[k].offsetWidth;
                if (items[k].className.toLowerCase().indexOf("aspnet-menu-selected") > -1) {
                    // Indent by about a third the width of selected primary nav item
                    primaryNavRequiredWidthBeforeSelectedItem += (items[k].offsetWidth / 3);
                    bFoundSelectedItem = true;
                }
                if (!bFoundSelectedItem) {
                    primaryNavRequiredWidthBeforeSelectedItem += items[k].offsetWidth;
                }
            }
        }
        primaryNavRequiredWidthBeforeSelectedItem += 1; // fudge

        items = secondaryNav.getElementsByTagName("LI");
        var secondaryNavRequiredWidth = 0;
        for (var k = 0; k < items.length; k++) {
            secondaryNavRequiredWidth += items[k].offsetWidth;
        }
        secondaryNavRequiredWidth += 1; // fudge

        var totalRequiredWidth = Math.max(primaryNavRequiredWidth, secondaryNavRequiredWidth) + primaryNav.offsetLeft;
        totalRequiredWidth += 5; // fudge
        totalRequiredWidth = Math.max(450, totalRequiredWidth);

        dashboard.style.width = totalRequiredWidth + "px";
        dashboardBackground1.style.width = totalRequiredWidth + "px";
        dashboardBackground2.style.width = totalRequiredWidth + "px";

        if ((primaryNavRequiredWidthBeforeSelectedItem + secondaryNavRequiredWidth) < totalRequiredWidth) {
            secondaryNav.style.left = Math.floor(primaryNavRequiredWidthBeforeSelectedItem).toString() + "px";
        }
        else {
            secondaryNav.style.left = Math.floor(totalRequiredWidth - secondaryNavRequiredWidth).toString() + "px";
        }

        // Adjust the widths and positions of the dropdown menus. These are the menus that appear when you
        // hover your mouse over a primary menu item that has a submenu (dropdown menu). We want these
        // dropdown menus to appear, if possible, with their left edge coincident with the left edge of the
        // menu item that you are hovering over. However, we want (even more) for the right edge of the dropdown
        // menu to go no further to the right then the right edge of the dashboard. Also, we need to set the
        // overall width of the dropdown to equal (or slightly exceed) the sum of the widths of its
        // items (which line up horizontally).

        for (var d = 0; d < primaryLists.length; d++) {
            if (primaryLists[d].className.toLowerCase() != "aspnet-menu") // skip the topmost UL so we only consider the submenus
            {
                var dropdown = primaryLists[d];
                var items = dropdown.getElementsByTagName("LI");
                var dropdownRequiredWidth = 0;
                for (var j = 0; j < items.length; j++) {
                    dropdownRequiredWidth += items[j].offsetWidth;
                }
                dropdownRequiredWidth += 1; // fudge
                dropdown.style.width = dropdownRequiredWidth + "px";

                if ((typeof (dropdown.offsetParent) != "undefined") && (dropdown.offsetParent != null) &&
                    (typeof (dropdown.offsetParent.offsetLeft) != "undefined") && (dropdown.offsetParent.offsetLeft != null) &&
                    (typeof (dropdown.offsetParent.offsetParent) != "undefined") && (dropdown.offsetParent.offsetParent != null) &&
                    (typeof (dropdown.offsetParent.offsetParent.offsetWidth) != "undefined") && (dropdown.offsetParent.offsetParent.offsetWidth != null) &&
                    ((dropdown.offsetParent.offsetLeft + dropdownRequiredWidth) > dropdown.offsetParent.offsetParent.offsetWidth)) {
                    dropdown.style.left = (dropdown.offsetParent.offsetParent.offsetWidth - (dropdown.offsetParent.offsetLeft + dropdownRequiredWidth)) + "px";
                }
            }
        }
    }
}

getTheIFrameDocument = function() {
    var doc = null;
    var iframe = document.getElementById("the-iframe");
    if (iframe != null) {
        if (iframe.contentDocument) {
            // Firefox, Opera   
            doc = iframe.contentDocument;
        }
        else if (iframe.contentWindow) {
            // Internet Explorer   
            doc = iframe.contentWindow.document;
        }
        else if (iframe.document) {
            // Others
            doc = iframe.document;
        }
    }
    return doc;
}

initFramedContent = function() {
    var iframe = document.getElementById("the-iframe");
    var doc = getTheIFrameDocument();
    if ((iframe != null) && (doc != null)) {
        if ((doc != null) && (typeof (doc.body) != "undefined") && (doc.body != null)) {
            doc.body.style.backgroundColor = "white";
            doc.body.style.width = "95%";
            var heightValue = (doc.body.scrollHeight + 100).toString() + "px";
            iframe.style.height = heightValue;
            iframe.parentNode.style.height = heightValue;
        }

        if (doc != null) {
            var docHref = doc.location.href.toLowerCase();
            var docHrefLen = docHref.length;
            var anchors = doc.getElementsByTagName("A");
            for (var i = 0; i < anchors.length; i++) {
                var anchorHref = anchors[i].href;
                if ((typeof (anchorHref) != "undefined") &&
                    (anchorHref.length > docHrefLen) &&
                    (anchorHref.substr(0, docHrefLen).toLowerCase() == docHref) &&
                    (anchorHref.substr(docHrefLen, 1) == '#')) {
                    ; /* internal bookmark... do nothing */
                }
                else if (typeof (anchors[i].target) != "undefined") {
                    anchors[i].target = "_top";
                }
            }
        }
    }
}

printTheIFrameDocument = function() {
    var iframe = document.getElementById("the-iframe");
    if (iframe != null) {
        var printableElement = (typeof (iframe.contentWindow) != "undefined") && (iframe.contentWindow != null) ? iframe.contentWindow : iframe;
        if ((typeof (printableElement.focus) != "undefined") && (printableElement.focus != null) &&
            (typeof (printableElement.print) != "undefined") && (printableElement.print != null)) {
            printableElement.focus();
            printableElement.print();
        }
    }
}

toggleVisibility = function(id, visibleStyle) {
    var element = document.getElementById(id);
    if ((typeof (element) != "undefined") && (element != null) && (typeof (element.style) != "undefined") && (element.style != null)) {
        if ((typeof (element.style.display) == "undefined") || (element.style.display == null) || (element.style.display != "none")) {
            element.style.display = "none";
        }
        else if ((typeof (visibleStyle) != "undefined") || (visibleStyle != null)) {
            element.style.display = visibleStyle;
        }
        else {
            element.style.display = "block";
        }
    }
}

useSilverlight = function() {
    var cookie_name = 'ag';
    var cookie_value = getCookie(cookie_name);
    if ((typeof (cookie_value) == 'undefined') || (cookie_value == null)) {
        cookie_value = 'true';
    }
    else {
        cookie_value = cookie_value.toLowerCase();
    }
    return (cookie_value != 'false');
}

getLanguagePreference = function() {
    var ret = "";
    var cookieName = "LanguagePreference=";
    var cookies = document.cookie.split(';');
    for (var i = 0; i < cookies.length; i++) {
        var c = cookies[i];
        while (c.charAt(0) == ' ') {
            c = c.substring(1, c.length);
        }
        if (c.indexOf(cookieName) == 0) {
            cookieValue = c.substring(cookieName.length, c.length).toLowerCase();
            if (cookieValue.length > 0) {
                ret = cookieValue;
            }
        }
    }
    return ret;
}

navigateToSupport = function() {
    var url = "http://support.microsoft.com/common/international.aspx?rdpath=1&gprid=";
    if (isMac()) {
        url += "12940";
    }
    else {
        url += "12929";
    }
    window.open(url, '_blank', '');
}

isMac = function() {
    // There isn't a great or perfect way to determine for certain if the client is using Windows or Mac or
    // another platform. Here's a pretty good attempt...
    return (navigator.userAgent.toLowerCase().indexOf('windows') == -1) && (navigator.userAgent.toLowerCase().indexOf('mac') != -1);
}

var gDomain = "m.webtrends.com";
var gDcsId = "dcsjwb9vb00000c932fd0rjc7_5p3t";
var gFpc = "WT_FPC";
var gTrackEvents = "1";
initWebTrends = function() {
    if (document.cookie.indexOf(gFpc + "=") == -1) {
        document.write("<SCR" + "IPT TYPE='text/javascript' SRC='" + "http" + (window.location.protocol.indexOf('https:') == 0 ? 's' : '') + "://" + gDomain + "/" + gDcsId + "/wtid.js" + "'><\/SCR" + "IPT>");
    }
}


adjustPositionsForMenuOffsets = function() {

    var el = document.getElementsByTagName("ul");
    var classType = "child-menu";
    var total = 0; //need to add width offsets to this so we can go left the right amount
    var ctr = 0;

    for (i = 0; i < el.length; i++) {
        var classes = el[i].className.toLowerCase().split(' ');
        for (var c = 0; c < classes.length; c++) {
            if (classes[c] == classType) {
                var w;
                if (ctr == 0) {
                    w = el[i].parentNode.offsetLeft;
                }
                if (!isIe7()) {
                    el[i].style.position = "absolute";
                    el[i].style.left = ((el[i].parentNode.offsetLeft - 0) * -1) + "px";
                }
                else {
                    el[i].style.position = "absolute";
                    el[i].style.left = ((el[i].parentNode.offsetLeft + 41) * -1) + "px";
                }
                ctr++;
            }
        }
    }
    adjustMenuWidths();
}


function contains(node1, node2) {
    // In case we are passed junk...
    if (typeof (node1) == "undefined") { return false; }
    if (typeof (node2) == "undefined") { return false; }

    if (node2 == node1) { return true; }
    if (node2 == null) { return false; }
    else { return contains(node1, node2.parentNode); }
}


function loc_mouseover() {
    var el = document.getElementById("locales");
    if (el != null) {
        el.className = "locales-selected";

        var eln = document.getElementById("lang-table");
        var i = eln.childNodes[0].childNodes.length;
        if ((i * 21) > 200) {
            el.style.height = '200px';
            el.style.overflow = 'scroll';
            el.style.overflowX = 'hidden';
        }
        else {
            el.style.height = (i * 21) + "px";
            el.style.overflow = '';
        }
    }
}


function loc_mouseout() {
    var localesContainerElement = document.getElementById("loc-container");
    var localesElement = document.getElementById("locales");
    if ((localesContainerElement != null) && (localesElement != null)) {
        var isActuallyOutside = true; 
        if ((typeof(event) != "undefined") && (typeof(event.toElement) != "undefined") && (event != null)) {
            isActuallyOutside = !contains(localesContainerElement, event.toElement);
        }
        if (isActuallyOutside) {
            //Mouse has left the container element
            localesElement.className = "locales";
            localesElement.style.overflow = '';
        }
    }
}


function highlightImage(obj, tf) {
    if (tf) {
        document.getElementById(obj).className = 'pic-picker-visible';
    }
    else {
        document.getElementById(obj).className = 'pic-picker';
    }
}


/*adds on load scripts to onload tag*/


function windowOnload() {
    pageLoadFinished = true;
    RunOnLoadScripts();
}

var OnLoadScripts = [];
var scriptCount = 0;

window.onload = windowOnload;
var pageLoadFinished = false;

function RunOnLoadScripts() {
    for (var i = 0; i < OnLoadScripts.length; i++) {
        eval(OnLoadScripts[i]);
    }
}

function AddOnloadScript(s, first) {
    if (first)
        OnLoadScripts.unshift(s);
    else
        OnLoadScripts.push(s);
}

/*end of add onload stuffs */

function tabsSelect(obj, v) {
    var x = obj.parentNode;
    for (var i = 0; i < x.childNodes.length; i++) {
        if (x.childNodes[i].tagName == "LI") {
            x.childNodes[i].className = "";
        }
    }
    obj.className = "selected";

    var q = document.getElementById("body-container");
    for (var i = 0; i < q.childNodes.length; i++) {
        if (q.childNodes[i].id == v) {
            q.childNodes[i].className = "tabbed-one-col-body-selected";
        } else {
            q.childNodes[i].className = "tabbed-one-col-body";
        }
    }
}

function tabsTwoColSelect(obj, v) {
    var x = obj.parentNode;
    for (var i = 0; i < x.childNodes.length; i++) {
        if (x.childNodes[i].tagName == "LI") {
            x.childNodes[i].className = "";
        }
    }
    obj.className = "selected";

    var q = document.getElementById("two-col-body-container");
    for (var i = 0; i < q.childNodes.length; i++) {
        if (q.childNodes[i].id == v) {
            q.childNodes[i].className = "tabbed-two-col-body-selected";
        } else {
            q.childNodes[i].className = "tabbed-two-col-body";
        }
    }
}


function FindOffset() {
    var wherearewe = location.href.split("/");
    var trip = 0;
    var additup = "";
    for (var x = 0; x < wherearewe.length; x++) {
        if (trip == 1) {
            additup += "../";
        }
        if (wherearewe[x].toLowerCase().indexOf("silverlight") != -1) {
            trip = 1;
        }
    }

    return additup.substr(3);
}

function link_hover(obj, tf, id) {
    var handle = document.getElementById(id);
    if (handle != null && obj != null) {
        if (tf) {
            obj.src = FindOffset() + 'images/rev/arrow-hz-sm-on.gif';
            handle.style.color = "#FF3300";
        }
        else {
            handle.style.color = "#000000";
            obj.src = FindOffset() + 'images/rev/arrow-hz-sm-off.gif';
        }
    }
}

function img_hover(obj, tf) {
    if (obj != null) {
        if (tf) {
            obj.src = FindOffset() + 'images/rev/arrow-hz-sm-on.gif';

        }
        else {

            obj.src = FindOffset() + 'images/rev/arrow-hz-sm-off.gif';
        }
    }
}

function text_hover(obj, tf, id) {
        var handle = document.getElementById(id);
        var ht = document.getElementById(obj);
        if (ht != null && handle != null) {
            if (tf) {

                ht.style.color = "#FF3300";
                handle.src = FindOffset() + 'images/rev/arrow-hz-sm-on.gif';

            }
            else {
                ht.style.color = "#000000";
                handle.src = FindOffset() + 'images/rev/arrow-hz-sm-off.gif';
            }
        }
}



/*nate menu*/
function startList() {
    if (document.all && document.getElementById) {
        navRoot = document.getElementById("nav");
        for (i = 0; i < navRoot.childNodes.length; i++) {
            node = navRoot.childNodes[i];
            if (node.nodeName == "LI") {
                //			    node.onmouseover = function() {
                //			        hideSelectedChild();
                //			        this.className += " over";
                //			    }
                //				node.onmouseout=function() {
                //					this.className=this.className.replace(" over", "");
                //					showSelectedChild();
                //				}
            }
        }
    }
}

function adjustMenuWidths()
{
    var i, j, k;
    if (document.getElementById) 
    {
        navRoot = document.getElementById("nav");
        secondaryNavRoot = null;
        var primaryNavRequiredWidth = 0;
        var secondaryNavRequiredWidth = 0;
        for (i = 0; i < navRoot.childNodes.length; i++)
        {
            node = navRoot.childNodes[i];
            if (node.nodeName == "LI")
            {
                primaryNavRequiredWidth += node.offsetWidth;
                
                secondaryMenus = node.getElementsByTagName("UL");
                for (k = 0; k < secondaryMenus.length; k++)
                {
                    var secondaryMenu = secondaryMenus[k];
                    if (secondaryMenu.className.indexOf("child-menu-selected") > -1)
                    {
                        secondaryNavRoot = secondaryMenu;
                        for (j = 0; j < secondaryNavRoot.childNodes.length; j++) 
                        {
                            node2 = secondaryNavRoot.childNodes[j];
                            if (node2.nodeName == "LI") 
                            {
                                secondaryNavRequiredWidth += node2.offsetWidth;
                            }
                        }
                    }
                }
            }
        }

        primaryNavRequiredWidth += 1; // fudge
        secondaryNavRequiredWidth += 1; // fudge

        var totalRequiredWidth = Math.max(primaryNavRequiredWidth, secondaryNavRequiredWidth);
        totalRequiredWidth += 5; // fudge

        if ((navRoot != null) && (secondaryNavRoot != null))
        {
            navRoot.style.width = totalRequiredWidth + "px";
            secondaryNavRoot.style.width = totalRequiredWidth + "px";
            
            if ((secondaryNavRoot.parentNode.offsetLeft + secondaryNavRequiredWidth) > totalRequiredWidth)
            {
                secondaryNavRoot.style.left = -((secondaryNavRoot.parentNode.offsetLeft + secondaryNavRequiredWidth) - totalRequiredWidth);
            }
        }
    }
}

isMoused = false;
function hideSelectedChild(obj) {
    isMoused = true;
    try {
        var eln = findElementByClassEx("LI", "over");
        if (eln != null) {
            eln.className = eln.className.replace(' over', '');
        }


        var el = findElementByClassEx("ul", "child-menu-selected");
        if (el != null) {
            el.className = "child-menu-selected-invisible";
        }
    }
    catch (e) {
    }
    if (obj != null) {
        obj.className += ' over';
    }
}

function showSelectedChild(obj) {

    if (obj != null && !isIe7()) {
        obj.className = obj.className.replace(' over', '');
    }
    if (obj != null && isIe6()) {
        isMoused = false;
        setTimeout(function() { closeForIe7(obj) }, 600);
    }
    else {
        var home = document.getElementById("home-page-element");
        if (home != null) {
            isMoused = false;
            setTimeout(function() { closeForIe7(obj) }, 600);
        } else {
            obj.className = obj.className.replace(' over', '');
        }
    }
    try {
        var el = findElementByClassEx("ul", "child-menu-selected-invisible");
        if (el != null) {
            el.className = "child-menu-selected";
        }
    }
    catch (e) {
    }
}

function closeForIe7(eln) {
    if (eln != null & !isMoused) {
        eln.className = eln.className.replace(' over', '');
    }
}

function isIe7() {
    var s = navigator.userAgent;
    if (s.indexOf("MSIE 7.0") > -1) {
        return true;
    }
    else {
        return false;
    }
}

function isIe6() {
    var s = navigator.userAgent;
    if (s.indexOf("MSIE 6.0") > -1) {
        return true;
    }
    else {
        return false;
    }
}

function mouseOutHandler() {
    event.cancelBubble = true;
}

function findElementByClassEx(tag, className) {
    var result = null;
    var tags = document.getElementsByTagName(tag);
    className = className.toLowerCase();
    for (var i = 0; i < tags.length; i++) {
        var classes = tags[i].className.toLowerCase().split(' ');
        for (var c = 0; c < classes.length; c++) {
            if (classes[c] == className) {
                result = tags[i];
                break;
            }
        }
    }
    return result;
}

function deepLink() {
    var selected = "-selected";
    if (window.location.hash) {
        var h = window.location.hash;
        h = h.substr(h.indexOf("#") + 1);
        if (h == 'sysreq') {
            h = 'sysreq-tab';
        }
        
        var part = document.getElementById(h);
        if (part != null) {
            if (part.className == "zbox") {
                zBox_GetBox(h).Show();
            }
            else {
                var hide = findElementByClass("div", part.className + selected);
                if (hide != null) {
                    hide.className = hide.className.replace(selected, "");
                }
                part.className = part.className + selected;

                var badTab = findElementByClass("li", "selected");
                if (badTab != null) {
                    badTab.className = "";
                }
                
                var c = document.getElementById("tab-" + h);
                if (c != null) {
                    document.getElementById("tab-" + h).className = "selected";
                }
            }
        }
    }
}

function checkSilverlight() {
    if (Silverlight.isInstalled("3.0")) {
        installedVer = 3;
    }
    else if (Silverlight.isInstalled("2.0")) {
        installedVer = 2;
    }
    else if (Silverlight.isInstalled("1.1")) {
        installedVer = 1.1;
    }
    else if (Silverlight.isInstalled("1.0")) {
        installedVer = 1;
    }
    else if (Silverlight.isInstalled("0")) {
        installedVer = 0;
    } else {
        installedVer = 0;
    }
}

function fixUpdate() {
    if (installedVer < 3) {
        var rev = document.getElementById("nosl-container").innerHTML;
        document.getElementById("silverlightControlHost").innerHTML = rev;
        //try clear it out
        try {
            document.getElementById("nosl-container").innerHTML = "";
        } catch (e) {/*no biggie*/ }
    }
    if (installedVer > 0 && installedVer < 3) {
        var d = document.getElementById("clicktoinst");
        //d.innerHTML = "Experience this in the latest version of Silverlight Please upgrade the free plug-in now&nbsp;&nbsp;<img src='images/rev/icon-arrow-white-sm.gif' class='non-sl-arrow' style='margin-left:285px;' />";
        d.innerHTML = "<img src='images/rev/upgrade_cta.png' style='background-color:transparent;' onmouseover=\"this.src='images/rev/upgrade_cta-over.png';\" onmouseout=\"this.src='images/rev/upgrade_cta.png';\" />";
        d.style.backgroundColor = 'transparent';
        d.style.display = 'block';
        d.style.margin = '85px 0px 0px 335px';
        d.style.width = '315px';

        document.getElementById("carstudy").style.display = 'none';
        document.getElementById("carstudy_text").style.display = 'none';
        document.getElementById("olympics").style.display = 'none';
        document.getElementById("olympics_text").style.display = 'none';
        document.getElementById("festival").style.display = 'none';
        document.getElementById("festival_text").style.display = 'none';

        var f = findElementByClass("div", "click2InstallWrapper");
        if (f != null) {
            f.className = 'click2InstallWrapperUpgrade';
        }
    }

}