/*
 * Makes two DIVs the same height by extending the shorter one to match the taller one.
 */
function equalizeHeight( div1, div2 ) {
	var d1 = document.getElementById( div1 );
	var d2 = document.getElementById( div2 );
	
	if (d1.offsetHeight < d2.offsetHeight)
		d1.style.height = d2.offsetHeight + "px";
	else
		d2.style.height = d1.offsetHeight + "px";
}

/*
 * Returns the height of the client area of the browser window.
 */
function windowHeight() {
	var height = 0;
	
	if (typeof(window.innerWidth) == 'number') {
		// non-IE
		height = window.innerHeight;
	}
	else if (document.documentElement && document.documentElement.clientHeight) {
		// IE 6+ in 'standards compliant mode'
		height = document.documentElement.clientHeight;
	}
	else if (document.body && document.body.clientHeight) {
		// IE 4 compatible
		height = document.body.clientHeight;
	}
	return height;
}

/*
 * Conditionally renders a "Back to Top" link at the end of the content area based on
 * its height. If the banner links and the footer links cannot be visible in the browser
 * window at the same time, then the link is rendered. 
 */
function renderBackToTopLink() {
	// Determine the threshold beyond which the link is needed.
	var threshold = windowHeight() - 90;
	
	if (document.getElementById("content-right").offsetHeight > threshold) {
		document.write("<p style='margin: 10px 0 0 0; font-size: 11px'>");
		document.write("<a href='#'>Back to Top</a></p>");
	}
}
