/*
Utilisation :
	<html>
		<head>
			<sytle>#trailimageid { position: absolute; visibility: hidden; left: 0px; top: 0px; height: 1px; z-index: 5000; }</style>
		</head>
		<body>
			<div id="trailimageid"></div>
			<!-- showtrail(imagename,title,description,showthumb,height,newItemWidth) -->
			<img src="petiteimage.jpg" border="0" OnMouseOver="showtrail('grandeimage.jpg','','','1',5,450);" OnMouseOut="hidetrail();">
</body>
	</html>
*/
var itemWidth = 250;				//Taille de la grande image par défaut
var offsetfrommouse = [5,5];		//Offsets x,y de l'image pour la position du curseur en pixels ([0,0] : sans offset)
var currentimageheight = 270;		//Taille maximum de l'image

function followmouse(e)
{
	var xcoord = offsetfrommouse[0];
	var ycoord = offsetfrommouse[1];
	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 - e.pageX < itemWidth + 50)
		{
			xcoord = e.pageX - xcoord - itemWidth;
		}
		else
		{
			xcoord += e.pageX;
		}
		if ((docheight - e.pageY) < (currentimageheight + 110))
		{
			ycoord += e.pageY - Math.max(0,(110 + currentimageheight + e.pageY - docheight - truebody().scrollTop));
		}
		else
		{
			ycoord += e.pageY;
		}
	}
	else if (typeof window.event != "undefined")
	{
		if (docwidth - event.clientX < itemWidth + 50)
		{
			xcoord = event.clientX + truebody().scrollLeft - xcoord - itemWidth;
		}
		else
		{
			xcoord += truebody().scrollLeft + event.clientX;
		}
		if (docheight - event.clientY < (currentimageheight + 110))
		{
			ycoord += event.clientY + truebody().scrollTop - Math.max(0,(110 + currentimageheight + event.clientY - docheight));
		}
		else
		{
			ycoord += truebody().scrollTop + event.clientY;
		}
	}
	gettrailobj().left = xcoord + "px";
	gettrailobj().top = ycoord + "px";
}

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

function gettrailobjnostyle()
{
	if (document.getElementById)
	{
		return document.getElementById("trailimageid");
	}
	else if (document.all)
	{
		return document.all.trailimagid;
	}
}

function hidetrail()
{
	gettrailobj().visibility = "hidden";
	document.onmousemove = "";
	gettrailobj().left = "-500px";
}

function showtrail(imagename,title,description,showthumb,height,newItemWidth)
{
	if (newItemWidth != false) itemWidth = newItemWidth;
	if (height > 0) currentimageheight = height;
	document.onmousemove = followmouse;
	cameraHTML = '';
	//newHTML = '<div style="background-color: #b30000; font-family: Verdana; font-size: 12px; color: #ffffff;"><span>' + title + '</span>';
	if (showthumb > 0)
	{
		newHTML = '<div style="background-color: #b30000; font-family: Verdana; font-size: 12px; color: #ffffff;"><span>' + title + '</span>';
		newHTML = newHTML + '<div style="border: 1px solid #000000;" align="center"><img src="' + imagename + '" border="0"></div>';
	}
	else
	{
		newHTML = '<div style="background-color: #ffffff; font-family: Verdana; font-size: 11px; color: #000000; border: solid 1px #b30000; padding: 10px;"><span>' + title + '</span>';
	}
	if (description != "") newHTML = newHTML + '<div style="background-color: #ffffff; font-family: Verdana; font-size: 11px; color: #000000;"><span>' + description + '</span></div>';
	newHTML = newHTML + '</div>';
	gettrailobjnostyle().innerHTML = newHTML;
	gettrailobj().visibility = "visible";
}

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