function showBox(){
	document.getElementById('overlay').style.height = document.body.offsetHeight + 'px';
	document.getElementById('overlay').style.display = 'block';

	document.getElementById('box').style.visibility = 'hidden';
	document.getElementById('box').style.display = 'block';

	var intWindowWidth=0,intWindowHeight=0;

	intWindowWidth = window.innerWidth?window.innerWidth:document.documentElement.clientWidth;
	intWindowHeight = window.innerHeight?window.innerHeight:document.documentElement.clientHeight;

	var intScrollX=0,intScrollY=0;

	intScrollX = window.pageXOffset?window.pageXOffset:document.documentElement.scrollLeft;
	intScrollY = window.pageYOffset?window.pageYOffset:document.documentElement.scrollTop;

	document.getElementById('box').style.top = document.getElementById('box').offsetHeight>intWindowHeight?(intScrollY+10)+'px':(intScrollY + ((intWindowHeight - document.getElementById('box').offsetHeight) / 2))+'px';
	document.getElementById('box').style.left = document.getElementById('box').offsetWidth>intWindowWidth?(intScrollX+10)+'px':(intScrollX + ((intWindowWidth - document.getElementById('box').offsetWidth) / 2))+'px';
	document.getElementById('box').style.visibility = 'visible';
	document.getElementById('box').style.width = (parseInt(document.getElementById('boxContent').offsetWidth) + 10) + 'px';

	if(parseInt(document.getElementById('overlay').style.height) < parseInt(document.getElementById('box').style.top) + document.getElementById('box').offsetHeight + 10){
		document.getElementById('overlay').style.height = (parseInt(document.getElementById('box').style.top) + document.getElementById('box').offsetHeight + 10) + 'px';
	}
}
function hideBox(){
	document.getElementById('overlay').style.display = 'none';
	document.getElementById('box').style.display = 'none';
	document.getElementById('box').style.width = null;
}
function initLightbox(){
	document.body.innerHTML += '<div id="overlay"></div><div id="box">Cliquez sur la photo pour fermer la fenêtre<br /><img id="boxContent" onclick="hideBox();" /></div>';
	var images = document.getElementsByTagName("img");
	var intImages = images.length;
	for(var i=0;i<intImages;i++){
		var image = images[i];
		if(image.getAttribute("rel") == "box" || image.getAttribute("alt") == "box"){
			image.setAttribute("alt", "");
			image.onmouseover = function (){
				this.style.cursor = "pointer";
			}
			image.onclick = function (){
				document.getElementById('boxContent').src = this.src;
				showBox();
			}
		}
	}
}
window.onload = function(){
	initLightbox();
}