/* requires prototype.js */

// this one ripped off of del.icio.us
function getY(o){ 
    var y = 0
    if (o.offsetParent) while (o.offsetParent) { 
	y += o.offsetTop; 
	o = o.offsetParent;
    }
    return y;
}

function choose_one( arr ) {
    var n = ( Math.random() * (arr.length-1) ).round();
    return arr[n];
}

function format_page() {
    $("footer").insert({ top: new Element("hr") });
 
    drop_footer();
}
    
function drop_footer() {
    var footer = $("footer");

    var fy = getY(footer),
	h = document.body.clientHeight || document.body.offsetHeight, 
	fh = footer.clientHeigh || footer.offsetHeight;

    // this should really be in EMs rather than pixels, but anywho,
    // 64px is somehow the magic number of unaccounted padding/margins,
    // as determined by a stylesheet somewhere.
    var emptySpace = (h - fh - fy)-64;

    footer.style.marginTop = (emptySpace > 0) ? (emptySpace + 'px') : 0;
}
