
var offsetfrommouse=[5,5]; //image x,y offsets from cursor position in pixels. Enter 0,0 for no offset
var displayduration=0; //duration in seconds image should remain visible. 0 for always.
var currentimageheight = 200;	// maximum image size.
var currentimagewidth = 280;	// maximum image size.

if (document.getElementById || document.all){
	document.write('<div id="trailimageid">');
	document.write('</div>');
}

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 truebody(){
return (!window.opera && document.compatMode && document.compatMode!="BackCompat")? document.documentElement : document.body
}

function showtrail(titre, image, description){

	document.onmousemove=followmouse;

	newHTML = '<div style="padding: 5px; z-index=9999">';

	newHTML += '<table id="fiche" width="272" height="200" border="0" cellpadding="0" cellspacing="0">';
	newHTML += '<tr>';
	newHTML += '	<td>';
	newHTML += '		<img src="images/cadretransp_10.gif" width="18" height="22" alt=""></td>';
	newHTML += '	<td background="images/cadretransp_top.gif" width="236" height="22">&nbsp;</td>';
	newHTML += '	<td>';
	newHTML += '		<img src="images/cadretransp_12.gif" width="18" height="22" alt=""></td>';
	newHTML += '</tr>';
	newHTML += '<tr>';
	newHTML += '	<td background="images/cadretransp_left.gif" width="18" height="162">&nbsp;</td>';
	newHTML += '	<td bgcolor="#E4E5E7" width="236" height="162" valign=top>';
	newHTML += '		<table width=236 cellspacing="5"><tr><td></td></tr>';
	newHTML += '<tr><td align="center"><b>' + titre + '</b></td></tr><tr><td align="center"><img src="images/' + image +  '"></td></tr><tr><td align="center">' + description + '</td></tr>' ;
	newHTML += '<tr><td></td></tr></table>' ;
	newHTML += '		</td>';
	newHTML += '	<td background="images/cadretransp_right.gif" width="18" height="162">&nbsp;</td>';
	newHTML += '</tr>';
	newHTML += '<tr>';
	newHTML += '	<td>';
	newHTML += '		<img src="images/cadretransp_20.gif" width="18" height="16" alt=""></td>';
	newHTML += '	<td background="images/cadretransp_bot.gif" width="236" height="16"></td>';
	newHTML += '	<td>';
	newHTML += '		<img src="images/cadretransp_22.gif" width="18" height="16" alt=""></td>';
	newHTML += '</tr>';
	newHTML += '</table>';

	gettrailobjnostyle().innerHTML = newHTML;
	gettrailobj().position="absolute";
	gettrailobj().display="inline";
	gettrailobj().zIndex="999";
	
}

function hidetrail(){
	gettrailobj().innerHTML = " ";
	gettrailobj().display="none"
	document.onmousemove=""
	gettrailobj().left="-500px"

}

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(window.innerHeight)

	if (typeof e != "undefined"){
		if (docwidth - e.pageX < currentimagewidth-20){
			xcoord = e.pageX - xcoord - currentimagewidth; // Move to the left side of the cursor
		} else {
			xcoord += e.pageX;
		}
		if (docheight - e.pageY < (currentimageheight + 70)){
			ycoord += e.pageY - Math.max(0,(70 + currentimageheight + e.pageY - docheight - truebody().scrollTop));
		} else {
			ycoord += e.pageY;
		}

	} else if (typeof window.event != "undefined"){
		if (docwidth - event.clientX < currentimagewidth-20){
			xcoord = event.clientX + truebody().scrollLeft - xcoord - currentimagewidth; // Move to the left side of the cursor
		} else {
			xcoord += truebody().scrollLeft+event.clientX
		}
		if (docheight - event.clientY < (currentimageheight + 70)){
			ycoord = event.clientY + truebody().scrollTop - currentimageheight;//- Math.max(0,(70  + event.clientY - docheight));
		} else {
			ycoord += truebody().scrollTop + event.clientY;
		}
	}

	if(ycoord < 0) { ycoord = ycoord*-1; }
	gettrailobj().left=xcoord+"px"
	gettrailobj().top=ycoord+"px"

}

