/* CROSS-BROWSER EVENT HANDLER */
function addEvent(obj, evType, fn){
     if (obj.addEventListener){
	     obj.addEventListener(evType, fn, true);
	     return true;
     } else if (obj.attachEvent){
	     var r = obj.attachEvent("on"+evType, fn);
     	return r;
     } else {
     	return false;
     }
}
/* END EVENT HANDLER */

function PageStretcher(pageContainerId, pageFooterBarId) {
    if(!document.getElementById || !document.getElementsByTagName) return;
    
    this.page = document.getElementById(pageContainerId);
    if(!this.page) return;
    
    this.div = document.getElementById(pageFooterBarId);
    if(!this.div) return;
    
    this.divStartPosition = this.div.style.position;
    this.timer = new Timer(this);
    this.stretch();
}
PageStretcher.prototype.getViewportHeight = function () {
    if (typeof(window.innerHeight) == "number") return window.innerHeight;
    else if (document.documentElement && document.documentElement.clientHeight) return document.documentElement.clientHeight;
    else if(document.body && document.body.clientHeight) return document.body.clientHeight;
}
PageStretcher.prototype.getPageHeight = function () {
    return document.getElementById("page").offsetHeight;
}
PageStretcher.prototype.stretch = function () {
    if(this.getPageHeight() < this.getViewportHeight()) {
        //this.div.style.cssText = "position: absolute; bottom: 0; left: 0; border: 1px solid red;";
        this.div.style.position = "absolute";
        this.div.style.left = "0";
        this.div.style.bottom = "0";
    } else {
        //this.div.style.cssText = "";
        this.div.style.position = this.divStartPosition;
    }
    this.timer.setTimeout("stretch", 200);
}

function keepFooterBarAtBottom() {
    pagestretcher = new PageStretcher("page", "extra2");
}
addEvent(window, "load", keepFooterBarAtBottom);