var image;

function showPhoto(filename, title) {
	hidePhotoDiv();
	image = new Image();
	image.src = "gfx/layout/px.gif";
	image.width = "200px";
	showPhotoDiv("Bezig met laden...");
	image = new Image();
//	image.src = "http://vanglabbeek.net/dalbum/pictures/vakantie_2003/01_05.jpg"; // filename;
	image.src = filename;
	showPhotoDiv(title);
}

function showPhotoDiv(title) {
	if (image.complete != true) {
		setTimeout("showPhotoDiv(\"" + title+ "\")",200); 
		return 0;
	}
	
	popupphotoDiv = document.getElementById("popupphoto");
	popupphotoImg = document.getElementById("popupphotoimg");
	popupphotoTitle = document.getElementById("popupphototitle");
	
	popupphotoDiv.style.display = "none";

	width = image.width;
	height = image.height;

	if (title=="Bezig met laden...") width = 100;
	popupphotoDiv.style.width = (width) + "px";
	popupphotoDiv.style.height = "auto"; //(height + 60) + "px";

	popupphotoTitle.innerHTML = title;
	centerPhotoDivs(width, height);

	popupphotoImg.src = image.src;
	popupphotoDiv.onclick = hidePhotoDiv;
	
	popupphotoDiv.style.display = "block";
}

function hidePhotoDiv() {
	
	popupphotoDiv = document.getElementById("popupphoto");
	popupphotoImg = document.getElementById("popupphotoimg");
	popupphotoTitle = document.getElementById("popupphototitle");

	popupphotoDiv.style.display = "none";
}

function centerPhotoDivs(width, height) {
	screenWidth = document.body.clientWidth;
	screenHeight = self.innerHeight;
	if (screenHeight == null) { 
		screenHeight = document.documentElement.clientHeight;
	}
	if (screenHeight == 0) {
		screenHeight = document.body.clientHeight;
	}
	
	verticalScroll = document.documentElement.scrollTop;
	if (verticalScroll == 0) verticalScroll = document.body.scrollTop;
	

	popupphotoRight = (screenWidth / 2) - ((width + 20) / 2);

	popupphotoTop = (screenHeight / 2) - ((height + 60) / 2) + verticalScroll;
	if (popupphotoTop < 0) popupphotoTop = 0;

	popupphotoDiv.style.right = popupphotoRight + "px";

	popupphotoDiv.style.top = popupphotoTop + "px";
}

