/**
 * Vertical page alignment.
 *
 * The use of this script is strictly forbidden without prior written
 * consent. You must obtain permission before copying, modifying, 
 * redistributing, deriving or selling any part of this program.
 *
 * Copyright © 2006 HYPERZOID
 * All Rights Reserved
 */

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

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


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";
    }
}

