function showJSContent() {
	document.getElementById("jscontent").style.display = "block";
	document.getElementById("nojs").style.display = "none";
}

function viewEnlargedImage(sender)
{
	var cloak = document.getElementById("cloak");
	var enlarged = document.getElementById("enlarged");
	
	cloak.style.display = "block";
	cloak.style.top = getScrollPosition() + "px";
	
	enlarged.src = sender.childNodes[0].src.replace("thumbs/","");
	enlarged.style.visibility = "hidden";
	enlarged.style.display = "block";
		
	setTimeout("setImagePosition()", 100);
}

function setImagePosition()
{
	var enlarged = document.getElementById("enlarged")
	enlarged.style.left = (getWindowSize()[0] / 2  - enlarged.width / 2) + "px";
	enlarged.style.top = (getScrollPosition() + getWindowSize()[1] / 2 - enlarged.height / 2) + "px";
	enlarged.style.visibility = "visible";
}

/* http://www.howtocreate.co.uk/tutorials/javascript/browserwindow */
function getWindowSize()
{
	var winW = 0, winH = 0;
	if (typeof(window.innerWidth) == 'number'){
		//Non-IE
		winW = window.innerWidth;
		winH = window.innerHeight;
	}else if (document.documentElement && (document.documentElement.clientWidth || document.documentElement.clientHeight)) {
		//IE 6+ in 'standards compliant mode'
		winW = document.documentElement.clientWidth;
		winH = document.documentElement.clientHeight;
	}else if (document.body && (document.body.clientWidth || document.body.clientHeight)) {
		//IE 4 compatible
		winW = document.body.clientWidth;
		winH = document.body.clientHeight;
	}

	return new Array(winW, winH)
}

function hideOverlay() {
	document.getElementById("cloak").style.display = "none";
	document.getElementById("enlarged").style.display = "none";
}

function getScrollPosition()
{
	var scrollPosition = document.body.scrollTop;
	if (scrollPosition == 0)
	{
		if (window.pageYOffset)
			scrollPosition = window.pageYOffset;
		else
			scrollPosition = (document.body.parentElement) ? document.body.parentElement.scrollTop : 0;
	}

	return scrollPosition;
}

window.onscroll = hideOverlay;
window.onresize = setImagePosition;