///////////////////////////////////////////////////////////////////////////////////////////////
// Doc-O-Matic(R) 10 script file.
// Copyright (C) 2000-2019 by toolsfactory software inc.
// http://www.doc-o-matic.com
//
// Distribution permitted as part of browser-based
// Help systems generated by Doc-O-Matic(R).
///////////////////////////////////////////////////////////////////////////////////////////////

var lastEmbeddedFeatureContentFilename = "";
var PageContentSidebarSplitterOffset = 0;
var PageContentSidebarSplitterBackgroundColor = "";
var PageContentSidebarSplitterSpacing = -1;

// Header/Footer spacer sizing                          
function updateFixedAreaSpacer(areaName, spacerName)
{
    var areaDiv = $(areaName);

    if ((!(typeof(areaDiv) === "undefined")) && (areaDiv != null) && (areaDiv.length)) {
        var spacerDiv = $(spacerName);
        if ((!(typeof(spacerDiv) === "undefined")) && (spacerDiv != null) && (spacerDiv.length)) {
            spacerDiv.css("height", areaDiv.height() + "px");                          
        }
    }
}

function updateFixedHeaderSpacing() {
    updateFixedAreaSpacer("div.PageHeaderArea_fixedheader", "div.PageContentArea_fixedheader_spacer");
}

// set the fixed header/footer height 
function updateFixedFooterSpacing() {
    updateFixedAreaSpacer("div.PageFooterArea_fixedfooter", "div.PageContentArea_fixedfooter_spacer");
}               

// set the embedded Sidebar location and height 
function updateSidebarLocation() {
    var headerDiv = $("div.PageHeaderArea_fixedheader");
    var footerDiv = $("div.PageFooterArea_fixedfooter");
    var sidebarDiv = $("div.PageContentSidebar");
    var splitterDiv = $("div.PageContentSidebarSplitter");
    
    if ((typeof(headerDiv) === "undefined") ||
        (typeof(footerDiv) === "undefined") ||
        (typeof(sidebarDiv) === "undefined")) {
        return;
    }
    
    if (    (headerDiv != null) && (headerDiv.length) && 
            (footerDiv != null) && (footerDiv.length) &&
            (sidebarDiv != null) && (sidebarDiv.length)) {
       var headerHeight = headerDiv.height();
       var footerHeight = footerDiv.height();
       var totalHeight = headerDiv.height() + footerDiv.height();
       var windowHeight = $(window).height();
       var cssheight = (windowHeight - totalHeight) + "px"; 

       sidebarDiv.css("top", headerHeight);
       sidebarDiv.css("height", cssheight);
       
       if ((typeof(splitterDiv) != "undefined") && (splitterDiv != null) && (splitterDiv.length)) {
           var sidebarWidth = sidebarDiv.width() + "px";
           splitterDiv.css("left", sidebarWidth);
           splitterDiv.css("top", headerHeight);
           splitterDiv.css("height", cssheight);
       }
    }                                                                              
}

function updateFixedElements() {
    updateFixedHeaderSpacing();
    updateFixedFooterSpacing();
    updateSidebarLocation();
}

function isIE () {
    var myNav = navigator.userAgent.toLowerCase();
    var result = (myNav.indexOf('msie') != -1) ? parseInt(myNav.split('msie')[1]) : -1;
    if (result == -1) {
        result = (myNav.indexOf('trident/') != -1) ? 11 : -1;
    }
    return result;
}

function updateSidebarWidth(width, persist) {
    // IE has some serious bugs in connection to media rules which surface once
    // once we start modifying css properties declared in the media rules, so
    // we have no choice and prevent modification here.
    if (isIE() >= 0) 
        return;

    var sidebarDiv = $("div.PageContentSidebar");
    var splitterDiv = $("div.PageContentSidebarSplitter");
    var contentDiv = $("div.PageContentBodywithSidebar");
    
    if ((typeof(sidebarDiv) === "undefined") ||
        (typeof(splitterDiv) === "undefined") ||
        (typeof(contentDiv) === "undefined")) {
        return;
    }
    
    if (    (sidebarDiv != null) && (sidebarDiv.length) && 
            (splitterDiv != null) && (splitterDiv.length) && 
            (contentDiv != null) && (contentDiv.length)) {

        var minWidth = 200;
        var maxWidth = $(window).width() / 2;

        if (width < minWidth) {
            width = minWidth;
        }
        if (width > maxWidth) {
            width = maxWidth;
        }

        // calculate the original spacing
        if (PageContentSidebarSplitterSpacing == -1) {
            var ws = Math.round(parseInt(sidebarDiv.css("width")));
            var mc = Math.round(parseInt(contentDiv.css("margin-left")));
            
            PageContentSidebarSplitterSpacing = mc - ws;
        }
        
        var content_spacing = PageContentSidebarSplitterSpacing > 0 ? PageContentSidebarSplitterSpacing : 0;
        var sidebarWidth = width + "px";
        var marginLeft = width + content_spacing + "px";
        
        sidebarDiv.css("width", sidebarWidth); 
        splitterDiv.css("left", sidebarWidth);  
        contentDiv.css("margin-left", marginLeft);
        
        var topictitleDiv = $("div.TopicTitle.MovableWithSidebarSplitter");
        if (    (typeof(topictitleDiv) !== "undefined") &&
                (topictitleDiv != null) && (topictitleDiv.length)) {
            topictitleDiv.css("margin-left", marginLeft);
            // because changing the margin might change the 
            // header height, we may need to update the 
            // sidebar height
            updateSidebarLocation();
            updateFixedHeaderSpacing();
        }
        
        if (persist) {
            saveVariable("PageContentSidebarSplitterWidth", width);
        }
    }
}

function clearCustomCSSStylesForSelector(selector) {
    var jqe = $(selector);
    
    if ((typeof(jqe) !== "undefined") && (jqe != null) && (jqe.length)) {
        jqe.css("margin-left", "");
    }
}

function clearCustomCSSStylesForSidebar() {
    clearCustomCSSStylesForSelector("div.PageContentBodywithSidebar");
    clearCustomCSSStylesForSelector("div.TopicTitle.MovableWithSidebarSplitter");
}

function restoreSidebarWidth() {
    var width = loadVariable("PageContentSidebarSplitterWidth");
    
    if ((width != null) && (width != "")) {
        var w = parseInt(width);
        updateSidebarWidth(w, false);
    } else {
        // nothing is stored, we still need to synchronize the topic title
        var sidebarDiv = $("div.PageContentSidebar");
        var topictitleDiv = $("div.TopicTitle.MovableWithSidebarSplitter");
        if (    (typeof(sidebarDiv) !== "undefined") && (typeof(topictitleDiv) !== "undefined") &&
                (topictitleDiv != null) && (topictitleDiv.length) && 
                (sidebarDiv != null) && (sidebarDiv.length)) {
                
            width = Math.round(parseInt(sidebarDiv.css("width")));
            // something went wrong
            if (width <= 0)
                return;
            updateSidebarWidth(width, false);
            //alert("width: " + width);
        }
    }
}


// dictionary from comma separated list
function categoryDictionaryFromString(categoryIds) {
    var result = {};
    
    if (categoryIds != null) {
        var ids = categoryIds.split(",");

        var i;
        for (i = 0; i < ids.length; i++) {
            var id = trimString(ids[i]);
            if (id.length > 0) {
                result[id] = true;
            }
        }
    }
    
    return result;
}

// comma separated list from dictionary
function categoryListFromDictionary(dictionary) {
    var result = "";
    
    for (key in dictionary) {
        if (dictionary[key]) {
            if (result != "") {
                result += ",";
            }
            result += key;
        }
    }
    
    return result;
}

// returns true if any key in rowCategoriesDict is contained in filteredCategoriesDict 
function containsAnyCategory(filteredCategoriesDict, rowCategoriesDict) {
    var result = false;
    
    for (cat in rowCategoriesDict) {
        var val = filteredCategoriesDict[cat];
        if ((val != null) && (val === true)) {
            result = true;
        }
    }
    
    return result;
}

// sets checked state of a category checkbox
function setCategoryCheckboxState(categoryId, checked) {
    $("input[type='checkbox'][value='" + categoryId +"']").each( function() {
        $(this).prop("checked", checked);
    });
}

// updates the category table's visibility based in whether it has visible rows
function updateCategoryTableVisibility() {
    $("div.NavigationTable > div > table").each( function () {
        // we can't check :visible directly because this doesn't
        // work if the containing table is currently hidden.
        var allRowsHidden = true;
        
        var visibleRows = $(this).children("tbody").children("tr").each (function () {
            if ($(this).css("display") !== "none") {
                allRowsHidden = false;
                return false;
            }
        });
        
        var placeholder = $(this).closest("div.NavigationTable").siblings("div.TableCategories").children("div.TableCategoriesTableEmpty"); 
        
        if (allRowsHidden) {
            $(this).hide();        
            placeholder.show();
        } else {
            $(this).show();        
            placeholder.hide();
        }                                  
    });
}


// Set adds or removes a category from the filtered list
// If categoryId = null, restores the current setup
function setCategoryVisibility(categoryId, visible) {

    var categories = loadVariable(filteredCategoriesStoreName);
    var theFilteredCategories = categoryDictionaryFromString(categories);

    if (categoryId != null) {
        theFilteredCategories[categoryId] = !visible;
    }
    
    if ((categoryId != null) || (!(jQuery.isEmptyObject(theFilteredCategories)))) {
        $("tr[data-category-ids]").each( function() {
            var idlist = $(this).attr("data-category-ids");
            
            var rowCategories = categoryDictionaryFromString(idlist);
            
            if (containsAnyCategory(theFilteredCategories, rowCategories)) {
                $(this).hide();
            } else {
                $(this).show();
            } 
        });
    }
    
    if (categoryId != null) {
        setCategoryCheckboxState(categoryId, visible);
   
        categories = categoryListFromDictionary(theFilteredCategories);
        saveVariable(filteredCategoriesStoreName, categories);
    } else {
        if (!(jQuery.isEmptyObject(theFilteredCategories))) {
            for (cat in theFilteredCategories) {
                setCategoryCheckboxState(cat, false);
            }
        }
    }
    
    updateCategoryTableVisibility();
}

// service function
function getCSSPixelProperty(jqobj, name) {
    return parseInt(jqobj.css(name).replace(/[^-\d\.]/g, ""));
}

// fits the topic path entries into the available space 
// by hiding entries starting at the left-hand side 
function fitTopicPath() {
    var path = $("div.PageHeaderTopicPaths").first();
    
    if (!path.length) 
        return;
        
    var entries = path.find("span.TopicPathEntry");
    
    entries.show();
    path.find("span.TopicPathSeparator").show();
    
    var pathElement = path[0];
    var availableWidth = pathElement.offsetWidth;
    var current = pathElement.scrollWidth;

    if (current > availableWidth) {
        var numberOfEntries = entries.length;
        entries.each( function(idx) {
            // don't hide the last entry, even if it doesn't fit
            if (idx < (numberOfEntries-1)) { 
                $(this).hide();
                $(this).nextAll("span.TopicPathSeparator").first().hide();
        
                current = pathElement.scrollWidth;            
                return (availableWidth < current);
            }
        });
    }        
}

function fadeInWelcomeControls() {
    setTimeout(function() {
	    $(".PageHeaderGlobalLinks > span.PageLink").animate({opacity: '1'}, 1000);
    }, 1000);
    setTimeout(function() {
	    $("div.madewith_dom").animate({opacity: '1'}, 1000);
    }, 2000);
}

function loadSidebarContent() {
    var container = $("div.PageContentSidebar");
    if (container.length) { 
        var featureContentId = container.attr("data-content-id");
        var featureContentUrl = container.attr("data-content-url");

        if ((typeof(featureContentId) === "undefined") ||
            (typeof(featureContentUrl) === "undefined")) {
            return;
        }
        
        if ((featureContentId != null) && (featureContentUrl != null)) {
            container.html("");
    
            $.ajax({
                url: featureContentUrl,
                dataType: "html",
                error: function(jqXHR, textStatus, errorThrown) {
                    container.html("Error loading " + featureContentUrl + " (" + jqXHR.status + "): " + textStatus + " " + jqXHR.responseText + " (" + errorThrown + ")");
                },
                success: function(html) {
                    var data = $("#" + featureContentId, $(html));
                    container.html(data);
    
                    var element = doSynchTOCInFrame(document.location.pathname.match(/[^\/]+$/)[0], window);
                    if (element != null) {
                        var scrollTop = $(element).offset().top - container.height() / 2; 
                        container.scrollTop(scrollTop);

                        var scrollLeft = $(element).offset().left - 20;
                        if (scrollLeft > 0) {
                            var maxX = $(element).offset().left + $(element).width();
                            var visibleX = container.width();
                            if (maxX > visibleX) {
                                var scrollX = maxX - visibleX;
                                if (scrollX > scrollLeft) {
                                    scrollX = scrollLeft;
                                }
                                container.scrollLeft(scrollLeft);
                            }  
                        }
                    }
                }
            });
        }
    }
}


// Installs a change event listener for your media query rule which handles hiding
// the sidebar on small screens. 
// Returns true if the media query rule is in effect at the time of installing
// the handler and false in all other cases.
function installSidebarMediaQueryListener() {
    var result = false;
    
    // IE older than 10 does not support this kind of stuff
    // Help Viewer and HTML Help are using IE 8
    var ie = isIE();
    if ((ie >= 0) && (ie < 10)) 
        return result;
        

    var styleSheet = document.styleSheets[0];
    var rules = styleSheet.cssRules || styleSheet.rules; // IE <= 8 use "rules" property

    var i;
    var mediaRule = null;

    // Step 1: Search the right media rule for .PageContentBodywithSidebar
    for (i = rules.length-1; i >= 0; i--) {
        var rule = rules[i];
        if (rule instanceof CSSMediaRule) {
            var s;
            for (s = 0; s < rule.cssRules.length; s++) {
                var styleRule = rule.cssRules[s];
                if (styleRule.selectorText == ".PageContentBodywithSidebar") {
                    mediaRule = rule;
                    break;
                }
            }
        }
        
        if (mediaRule != null) {
            break;
        }
    }
    
    // Step 2: Install a listener for this rule
    if (mediaRule != null) {
        var mediaQueryList = window.matchMedia(mediaRule.conditionText);
        if (mediaQueryList != null) {
            mediaQueryList.addListener(function (mqle) {
                // if the event matches it means that the sidebar is being removed
                if (mqle.matches) {
                    // in order for the fixed rule-based margin to be applied, we need to
                    // clear the style attribute, which is set when altering CSS programmatically
                    clearCustomCSSStylesForSidebar();
                } else {
                    // the sidebar is being shown again, so lets restore the arrangement as
                    // it was before.
                    restoreSidebarWidth();
                }
            });
            
            result = mediaQueryList.matches;
        }
    }    
    
    return result;
}



// Begin: Mouse capture JQuery plugin
// Source: https://github.com/benanne/jquery-mouse-capture-plugin/blob/master/lib/jquery.mousecapture.js
(function($) {

    $.fn.mousecapture = function(params) {
        var $doc = $(document);
        
        this.each(function() {
            var $this = $(this);
            var sharedData = {};
            
            $this.mousedown(function(e) {                
                // mousemove
                var moveHandler;
                
                if (params.move) {
                    moveHandler = function(e) {
                        params.move.call($this, e, sharedData);
                    };
                    
                   $doc.mousemove(moveHandler);
                }
                
                // mouseup                
                var upHandler;
                
                var unbind = function() {
                    if (params.move) $doc.unbind("mousemove", moveHandler);
                    $doc.unbind("mouseup", upHandler);
                };
                
                if (params.up) {
                    upHandler = function(e) {
                        unbind();
                        return params.up.call($this, e, sharedData);
                    };
                } else {
                    upHandler = unbind;
                }
                $doc.mouseup(upHandler);
                // mousedown
                return params.down.call($this, e, sharedData);
            });
        });
        return this;
    };
})(jQuery);
// End: Mouse capture JQuery plugin

// All dynamic initialization that needs to happen
// as early as possible goes here
function initializeDynamicPageContents() {
    updateFixedElements();
    loadCollapseStates();
    restoreTabbedSectionStates();
    setCategoryVisibility(null, true);
    fitTopicPath();
    IndexRestoreOptions();

    // no splitter bar support on IE due to insufficient conformance 
    // with media rules change events
    if (isIE() == -1) {
        // if the sidebar media query rule is in effect we dont restore the sidebar 
        if (!installSidebarMediaQueryListener()) {
            restoreSidebarWidth();
        }
    } else {
        $("div.PageContentSidebarSplitter").hide();
    }
}


$(function() {
    // we do this here instead of window.load() as it's called earlier
    // and avoids visual glitches due to changing the topic sidebar width, 
    // title margin, header height.
    initializeDynamicPageContents();

    // tears down any open popup and background 
    function closeEmbeddedFeature() {
        if ($("div.EmbeddedFeatureBackground").is(':visible')) {
            $("div.EmbeddedFeatureBackground").hide();
            $("div.EmbeddedFeature").hide();
            $("div.Popup_Block").hide();
            $("div.TopicPathPopup_Block").hide();
        } 
    }
    
    // we need to update the fixed header and topic path when the window is resized
    $(window).on("resize", function() {
        updateFixedElements();
        closeEmbeddedFeature();
        fitTopicPath();
    });

    // toggles a section
    $("div.SectionHeading").click(function() {
        toggleVisibility($(this).attr("id"), true);
    });

    // toggles a TOC folder in response to the expand/collapse image being clicked
    $(document).on("click", "div.ContentLevel > div.ContentFolder > img", function () {
        toggleVisibility($(this).closest("div").attr("id"), false);
    });

    // toggles a TOC group in response to the expand/collapse image being clicked
    $(document).on("click", "div.ContentLevel > div.ContentGroup > img", function () {
        toggleVisibility($(this).closest("div").attr("id"), false);
    });
    
    // toggles all expandable sections
    $("div.CollapseExpandLink > span").click(function() {
        var showSections = ($(this).hasClass("expandAll"));
        
        $("div.CollapseExpandLink > span").show();
        $(this).hide();
        
        $("div.SectionHeading.expandable").each(function() {
            var sectionId = $(this).attr("id");
            setSectionVisibility(sectionId, showSections);
        });
         
    });
    
    
    // places a popup feature (embedded feature, section popup or topic path popup)
    function placePopupFeature(feature, relativeTo, center, paddingElement) {
        var screenpos = relativeTo.offset();
        var padding = getCSSPixelProperty(feature, "padding-top");
        var scrlTop = $(window).scrollTop(); 
        var scrlLeft = $(window).scrollLeft();
        var windowWidth = $(window).width();
        var featureWidth = feature.outerWidth(); 
        
        screenpos.top = Math.round(screenpos.top - padding - scrlTop);
        if (center) {
            screenpos.left = Math.round(screenpos.left - ((feature.width() - relativeTo.width()) / 2) - scrlLeft);
        } else {
            screenpos.left = Math.round(screenpos.left - scrlLeft);
        }                     
        
        if ((paddingElement != null) && (paddingElement.length)) {
            var padLeft = getCSSPixelProperty(paddingElement, "padding-left") + 
                          getCSSPixelProperty(paddingElement, "border-left-width") + 
                          getCSSPixelProperty(feature, "border-left-width");
            var padTop =  getCSSPixelProperty(paddingElement, "padding-top") + 
                          padding + 
                          getCSSPixelProperty(feature, "border-top-width");
            screenpos.left -= padLeft;
            screenpos.top -= padTop;
        }
                                                                                             
        if (screenpos.left < 0) {
            screenpos.left = 0;
        } else if ((screenpos.left + featureWidth) > windowWidth) {
            screenpos.left = windowWidth - featureWidth; 
        }
        
        feature.css("left", screenpos.left);
        feature.css("top", screenpos.top);
    }
    
    // opens an embedded popup window for the TOC or index    
    $("div.PageHeaderGlobalLinks > span.PageLink").click(function (e) {
        var featureId = $(this).attr("id");
        var featureContentId = $(this).attr("data-content-id");
        var featureFile = $(this).find("a").attr("href");

        if ((typeof(featureId) === "undefined") ||
            (typeof(featureContentId) === "undefined") ||
            (typeof(featureFile) === "undefined")) {
            return;
        }

        var feature = $("div.EmbeddedFeature"); 
        var container = $("div.EmbeddedFeature > div.EmbeddedFeatureContent > div.EmbeddedFeatureContentContainer");
        
        if (!(feature.length || container.length)) {
           return;
        }

        if ((featureFile != "") && (featureContentId != "")) {
            e.preventDefault();
            
            var background = $("div.EmbeddedFeatureBackground");
            var title = $("div.EmbeddedFeature > div.EmbeddedFeatureTitle");
            
            placePopupFeature(feature, $(this), true, null);
            title.html($(this).attr("title"));
    
            feature.show();
            background.show();
            
            if ((featureFile != "") && (lastEmbeddedFeatureContentFilename != featureFile)) {
                container.html("");
    
                $.ajax({
                    url: featureFile,
                    dataType: "html",
                    error: function(jqXHR, textStatus, errorThrown) {
                        container.html("Error loading " + featureFile + " (" + jqXHR.status + "): " + textStatus + " " + jqXHR.responseText + " (" + errorThrown + ")");
                        // if the load fails (most likely due to security
                        // restrictions some browsers impose), we load the
                        // featureFile into the browser normally.
                        document.location = featureFile; 
                    },
                    success: function(html) {
                        lastEmbeddedFeatureContentFilename = featureFile;
                        var data = $("#" + featureContentId, $(html));
                        container.html(data);
        
                        if (featureId == "PageLinkContent") {
                            var element = doSynchTOCInFrame(document.location.pathname.match(/[^\/]+$/)[0], window);
                            if (element != null) {
                                var scrollpos = $(element).offset().top - container.height() / 2; 
                                feature.scrollTop(scrollpos);
                            }
                        } else if (featureId == "PageLinkIndex") {
                            IndexRestoreOptions();
                            $("#indexSearchNameField").focus();
                        }
                    }
                });
            }
        }
    });
    
    // Close the popup feature in response to the close button being clicked 
    $("div.EmbeddedFeature > div.EmbeddedFeatureClose").click(function () {
        closeEmbeddedFeature();
    });
    
    // Close the popup feature in response to the background being clicked 
    $("div.EmbeddedFeatureBackground").click(function () {
        closeEmbeddedFeature();
    });
    
    // Switchs selected section tabs 
    $("div.TabbedSectionContainer > div.SectionTabs > div").click(function () {
        var tabs = $(this).closest("div.SectionTabs");
        var container = $(this).closest("div.TabbedSectionContainer");
        var allSections = container.find(".TabbedSectionContent");

        var tabsetid = tabs.attr("id");
        var tabidx = $(this).index();
        var tabcount = allSections.length;  
        
        switchTabs(tabsetid, tabidx, tabcount);
    });

    // Toggles navigation section categories in response to checkbox selection/deselection 
    $("div.TableCategories > label.TableCategory > input").click(function () {
        var id = $(this).attr("value");
        var checked = $(this).prop("checked");
        
        setCategoryVisibility(id, checked);
    });

    // Close any popup when the user presses the ESC key
    $(document).keyup(function(e) {
        if (e.keyCode == 27) { 
            closeEmbeddedFeature();
        }
    });
    
    
    // Shows a section popup 
    $("span[data-content-id].PopupLink").click(function() {
        var featureContentId = $(this).attr("data-content-id");
        var feature = $("div#" + featureContentId);
        var background = $("div.EmbeddedFeatureBackground");
        
        placePopupFeature(feature, $(this), false, null);
        
        feature.show();
        background.show();
    });
    
    // Shows a topic path item's popup 
    $("span[data-content-id].TopicPathEntry").on('click', function(e) {
        e.preventDefault();
                                                              
        var featureContentId = $(this).attr("data-content-id");
        var feature = $("div#" + featureContentId);
        var background = $("div.EmbeddedFeatureBackground");

        var itemsContainer = feature.children("div.TopicPathPopup");
        var firstItem = itemsContainer.children("div").first();
        var selectedItem = itemsContainer.children("div.TopicPathPopupItemOnPath");
        
        placePopupFeature(feature, $(this), false, firstItem);

        feature.show();
        background.show();

        // scroll the highlighted item into view
        var featureHeight = feature.height();
        var scrollpos = Math.round(feature.scrollTop() + selectedItem.position().top - (featureHeight - selectedItem.height()) * 0.5);
        if (scrollpos > featureHeight) { 
            feature.scrollTop(scrollpos);
        }

    });
    
    // Browse to https://www.doc-o-matic.com  
    $("div.madewith_dom > img").click( function () {
        window.open("https://www.doc-o-matic.com/en");
    });


    // Splitter bar implementation for sidebar layout
    $("div.PageContentSidebarSplitter").mousecapture(
    {
        "down": function(e, s) {
            var splitterLeft = $(this).position().left;
            PageContentSidebarSplitterOffset = splitterLeft - e.pageX;
            PageContentSidebarSplitterBackgroundColor = $(this).css("background-color"); 
            
            $(this).css("background-color", "#aaa");
            e.preventDefault(); // disable text selection while we capture the mouse
        },
        "move": function(e, s) {
            var dX = e.pageX;            
            updateSidebarWidth(dX + PageContentSidebarSplitterOffset, true);
        },
        "up": function(e, s) {
            $(this).css("background-color", PageContentSidebarSplitterBackgroundColor);
        }
    });
    
});

$( window ).on('load', function() {

    if ($("body.WelcomeBody").length) {    
       fadeInWelcomeControls();
    }

    // delay load the sidebar content
    if ($("div.PageContentSidebar").length) {
        setTimeout(function() {
            loadSidebarContent();
        }, 50);
    }    
});
