﻿function scrollBackground() {
    // v1.1 Disables background screen scrolling while viewing shadowbox popups

    // Copyright 2010 Peter Smith - The Science Registry
    // Usage: Allowed if copyright statement remains

    // add the following to the Shadowbox.init ({})
    // onOpen: scrollBackground, onClose: scrollBackground

    // Get a reference to the HTML element
    var objHTML = document.getElementsByTagName("html").item(0);

    // Hide/show scrollbar
    if (objHTML.style.overflow == "hidden") {
        objHTML.style.overflow = "auto";
        jQuery(window).scrollTop(_scrollTop);
    } else {
    _scrollTop = jQuery(window).scrollTop();
        objHTML.style.overflow = "hidden";
        // Hiding the vertical scrollbar and having the webpage centered makes the content jump across by the amount of the scrollbars width
        // this adjust that if html width is not set i.e. it only fires once.
        if (objHTML.style.width == "") objHTML.style.width = "" + parseInt(objHTML.offsetWidth - 17) + "px";
    }
}
