/****************************************************************
	Simple Image Trail script - By JavaScriptKit.com
	Visit http://www.javascriptkit.com for this script and more
	This notice must stay intact
 ****************************************************************/
/* Le script original a ete modifie pour les besoins de ce site
 ****************************************************************/
 
var divw=0;
var divh=0;
if (document.getElementById || document.all)
	document.write('<div id="imgtrailer" style="position:absolute;display:none;z-index:900"></div>');

function gettrailobject() 	{
	if (document.getElementById)
		return document.getElementById("imgtrailer")
	else if (document.all)
		return document.all.trailimagid
}

function gettrailobj() 	{
	if (document.getElementById) 
		return document.getElementById("imgtrailer").style; 
	else if (document.all)
		return document.all.trailimagid.style
}

function truebody() 	{
	return (!window.opera && document.compatMode && document.compatMode!="BackCompat")? document.documentElement : document.body
}

function trailOff() {
	
	document.onmousemove=null;
	gettrailobj().display="none";
	
}

function trailOn(thumbimg,thw,thh,direction){
			gettrailobj().left="-500px";
			smthw = parseInt(thw) + 2;			
			smthh = parseInt(thh) + 2;	
			gettrailobject().innerHTML = '<img src="'+thumbimg+'">';
			gettrailobj().display="block";
			gettrailobj().left=-9000+'px';
			if (direction == "droite")
				document.onmousemove=followmouse;
			else
				document.onmousemove=followmouseGa;
}
//	alert('Message ' +docwidth + " - " +docheight);

function followmouse(e) {
	var docwidth=document.all? truebody().scrollLeft+truebody().clientWidth : pageXOffset+window.innerWidth-15;
	var docheight=document.all? Math.min(truebody().scrollHeight, truebody().clientHeight) : Math.min(document.body.offsetHeight, window.innerHeight);
	if (typeof e != "undefined") { 
		if (docwidth < 15+e.pageX+divw)
			xcoord = e.pageX-divw-5;
		else
			xcoord = 15+e.pageX;
		if (docheight < 15+e.pageY+divh)
			ycoord = -100+e.pageY-Math.max(0,(divh + e.pageY - docheight - truebody().scrollTop - 30));
		else
			ycoord = -100+e.pageY;
	}
	else if (typeof window.event != "undefined") { 
		if(docwidth < 15+truebody().scrollLeft+event.clientX+divw)
			xcoord = truebody().scrollLeft-5+event.clientX-divw;
		else
			xcoord = truebody().scrollLeft+15+event.clientX;
	
		if(docheight < 15+truebody().scrollTop+event.clientY+divh)
			ycoord = -100+truebody().scrollTop+event.clientY-Math.max(0,(divh + event.clientY - docheight - 30));
		else
			ycoord = truebody().scrollTop-100+event.clientY;
	}
	gettrailobj().left=xcoord+"px"
	gettrailobj().top=ycoord+"px"
}
function followmouseGa(e) {
	var docwidth=document.all? truebody().scrollLeft+truebody().clientWidth : pageXOffset+window.innerWidth-15;
	var docheight=document.all? Math.min(truebody().scrollHeight, truebody().clientHeight) : Math.min(document.body.offsetHeight, window.innerHeight);
	var	xImgOffset=gettrailobject().getElementsByTagName("IMG")[0].width + 30;
	if (typeof e != "undefined") {
		if (docwidth < 15+e.pageX+divw)
			xcoord = -xImgOffset+e.pageX-divw-5;
		else
			xcoord = -xImgOffset+15+e.pageX;
		if (docheight < 15+e.pageY+divh)
			ycoord = -100+e.pageY-Math.max(0,(divh + e.pageY - docheight - truebody().scrollTop - 30));
		else
			ycoord = -100+e.pageY;
	}
	else if (typeof window.event != "undefined") { 
		if(docwidth < 15+truebody().scrollLeft+event.clientX+divw)
			xcoord = -xImgOffset+truebody().scrollLeft-5+event.clientX-divw;
		else
			xcoord = -xImgOffset+truebody().scrollLeft+15+event.clientX;
	
		if(docheight < 15+truebody().scrollTop+event.clientY+divh)
			ycoord = -100+truebody().scrollTop+event.clientY-Math.max(0,(divh + event.clientY - docheight - 30));
		else
			ycoord = truebody().scrollTop-100+event.clientY;
	}
	gettrailobj().left=xcoord+"px"
	gettrailobj().top=ycoord+"px"
}

