// JavaScript Document

var staticOffset;
function positionFooter() {
	
	//politely borrowed from Shaun Inman (http://www.shauninman.com)
	var d = document, w = window, dE = d.documentElement, dB = d.body;
	if (!d.getElementById || !d.body.offsetHeight) { return; };
	
    var footer 		   = d.getElementById('copyright');
    var contentH1	   = d.getElementById('container').offsetTop + d.getElementById('container').offsetHeight;
	var contentH2	   = d.getElementById('nav').offsetTop + d.getElementById('nav').offsetHeight;
	if(contentH1 > contentH2) var contentH = contentH1;
	if(contentH2 > contentH1) var contentH = contentH2;
	
	var windowH		= (typeof(w.innerHeight)=='number')?w.innerHeight:(dE&&dE.clientHeight)?dE.clientHeight:(dB&&dB.clientHeight)?dB.clientHeight:0;
	
	if( ( windowH - footer.offsetHeight ) - contentH > 0)
		footer.style.marginTop = ( ( windowH - staticOffset ) - footer.offsetHeight ) + "px";
	else
		footer.style.marginTop = ( contentH ) + "px";
	
}

function pickhint(){
	var hints = document.getElementById("hints");
	
	if(!hints) return;
	
	var hintLength = 0;
	for(var i=0; i<hints.childNodes.length; i++)
	{
		if(hints.childNodes[i].nodeName != "#text")
			hintLength++;
	}
	
	var pick = Math.floor(Math.random() * hintLength) + 1;
	hintLength = 0;
	for(var i=0; i<hints.childNodes.length; i++)
	{
		if(hints.childNodes[i].nodeName != "#text")
		{
			hintLength++;
			if(hintLength == pick)
			{
			}
			else
			{
				hints.childNodes[i].style.display = "none";
			}
		}
	}
	
	hints.className = "hints";
}

window.onload = function() {
	staticOffset = document.getElementById('copyright').offsetTop;
	pickhint();
	positionFooter();
}
window.onresize = function() {
	positionFooter();
}