// The minimum top offset of the content, relative to the view port.
var MIN_OFFSET = 5;

// The content container DIV ID.
var CONTAINER_ID = "all";

window.onresize = align; // Re-align on window resize.

function align() {
    // Get the height of the view port.
    var viewPortHeight;
    if (document.all) { // IE.
        viewPortHeight = document.body.clientHeight;
    } else { // Gecko.
        viewPortHeight = window.innerHeight;
    }

    // Get the height of the page content.
    var content = document.getElementById(CONTAINER_ID);
    var contentHeight = content.clientHeight

    // Set the content's top offset relative to the view port.
    if (contentHeight >= viewPortHeight) {
        content.style.top = MIN_OFFSET + "px";
    } else {
        content.style.top = ((viewPortHeight - contentHeight) / 2) + "px";
    }
}

