﻿//set top padding of the workspace to the height of the ribbon
function setTopPadding() {
    var wrkElem = document.getElementById('s4-workspace');
    var ribHeight = document.getElementById('s4-ribbonrow').offsetHeight;
    if (window.location.search.match("[?&]IsDlg=1")) {
        //margin works better for dialogs b/c of scrollbars
        wrkElem.style.marginTop = ribHeight + 'px';
        wrkElem.style.paddingTop = '0px';
    }
    else {
        //padding works better for the main window
        wrkElem.style.paddingTop = ribHeight + 'px';
    }
}

// bind top padding reset to ribbon resize event so that the page always lays out correctly.
ExecuteOrDelayUntilScriptLoaded(function () { SP.UI.Workspace.add_resized(setTopPadding); }, "init.js");
