$(document).ready(function(){
	$("body").append('<div id="details"></div>');
	$("a.img").click(function(){
		TB_load_position();
		
			$("#details").html('<img src="'+$(this).attr('href')+'">');
			$("#details img").click(function(){
				$("#details").fadeOut(500);
			});
			
		return false;
	});
	
	
	
	
	
	
	
	
	
	
	
	
	
	//centrer la boite de détails
function TB_load_position() {
	var pagesize = TB_getPageSize();
	var arrayPageScroll = TB_getPageScrollTop();
	//top_ = Math.max(0,(arrayPageScroll[1] + ((pagesize[1]-720)/2)));
	top_ = Math.max(0,(arrayPageScroll[1] + ((pagesize[1]-300)/2)));
	
	$("#details")
	.css({left: (arrayPageScroll[0] + (pagesize[0] - 500)/2)+"px", top: (top_)+"px" })
	.css({display:"block"});
	/*$("#fond").css({top: (arrayPageScroll[1])+"px"});
	$("#fond").css({display: "block"});*/
	
	
}

function TB_getPageScrollTop(){
	var yScrolltop;
	var xScrollleft;

	if (self.pageYOffset || self.pageXOffset) {
		yScrolltop = self.pageYOffset;
		xScrollleft = self.pageXOffset;
	
	} else if (document.documentElement && document.documentElement.scrollTop || document.documentElement.scrollLeft ){// Explorer 6 Strict
		yScrolltop = document.documentElement.scrollTop;
		xScrollleft = document.documentElement.scrollLeft;
	
	} else if (document.body) {// all other Explorers
		yScrolltop = document.body.scrollTop;
		xScrollleft = document.body.scrollLeft;
	}
	arrayPageScroll = new Array(xScrollleft,yScrolltop) 
	return arrayPageScroll;
}

function TB_getPageSize(){
	var de = document.documentElement;
	var w = window.innerWidth || self.innerWidth || (de&&de.clientWidth) || document.body.clientWidth;
	var h = window.innerHeight || self.innerHeight || (de&&de.clientHeight) || document.body.clientHeight
	arrayPageSize = new Array(w,h) 
	return arrayPageSize;
}
});