var windowHeight = 0;
var windowWidth = 0;
var imageIsVisible = false;

//window.onload=getWindowSpecs;
//window.onresize=getWindowSpecs;

function getWindowSpecs() {
	if (document.all) {
		if (!document.documentElement.offsetWidth) {
			windowWidth = document.body.clientWidth;
			windowHeight = document.body.clientHeight;
		} else {
			windowWidth = document.documentElement.offsetWidth;
			windowHeight = document.documentElement.offsetHeight;
		}
	} else {
		windowWidth = window.innerWidth;
		windowHeight = window.innerHeight;
	}
	
	if (imageIsVisible) centerImage();
}

function showImage(imgURL) {
	getWindowSpecs();
	var imgViewer = document.getElementById('imgViewer');
	imgViewer.src = imgURL;
}

function centerImage() {
	var scrollY = 0;
	if (document.all) {
		if (!document.documentElement.scrollTop)
			scrollY = document.body.scrollTop;
		else
			scrollY = document.documentElement.scrollTop;
	} else {
		scrollY = window.pageYOffset
	}
	var imgViewer = document.getElementById('imgViewer');
	var divViewer = document.getElementById('imageViewer').style;
	
	divViewer.left = Math.round((windowWidth-imgViewer.width)/2) + 'px';
	divViewer.top = (Math.round((windowHeight-imgViewer.height)/2)+scrollY) + 'px';
	divViewer.visibility = 'visible';
	imageIsVisible = true;
}

function hideImage() {
	var divViewer = document.getElementById('imageViewer').style;
	divViewer.visibility = 'hidden';
	imageIsVisible = false;
}

