var offsetfrommouse=[15,-15]; //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 trailimage=["test.gif", 320, 320]
if (document.getElementById || document.all)
{
	document.write('<div id="trailimageid"></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 showPreview(imagename,title,description,width, height, parms )
{
	trailimage[0]=imagename;
	trailimage[2]=height;
	trailimage[1]=width;
	document.onmousemove=followmouse;
	var html = '<div style="padding: 10px; background-color: #FFFFFF; border: 1px solid #006600; width:' + width + ';height:'+ height + ' >';
	html = html + '<span style="font:10px Arial, Helvetica, sans-serif;font-weight:bold;"><strong>' + title + '</strong><br>' + description + '</span>';
	html = html + '<div align="center" style="padding: 5px 0px 0px 0px;"><img src="' + imagename + '" ' + parms + ' ></div>';
	html = html + '</div>';
	gettrailobjnostyle().innerHTML = html;
	gettrailobj().visibility="visible";
}
function hidePreview(){
	gettrailobj().visibility="hidden"
	document.onmousemove=""
	gettrailobj().left="-500px"
}
function followmouse(e){
	var x=offsetfrommouse[0]
	var y=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 + trailimage[1]))
		{
			x = e.pageX - 2 * x - trailimage[1]; // Move to the left side of the cursor
		} 
		else 
		{
			x += e.pageX;
		}
		if (docheight < (e.pageY + (1.1 * trailimage[2]) - truebody().scrollTop) )
		{
			y = e.pageY - trailimage[2];
		} 
		else 
		{
			y += e.pageY;
		}
	} 
	else if (typeof window.event != "undefined")
	{
		if (docwidth < (event.clientX + trailimage[1]))
		{
			x = event.clientX + truebody().scrollLeft - 2 * x - trailimage[1]; 
		} 
		else 
		{
			x += truebody().scrollLeft+event.clientX
		}
		if (docheight < (event.clientY + (1.1 * trailimage[2]) ) )
		{
			y = event.clientY + truebody().scrollTop - Math.max(0,(1.2 * trailimage[2] + event.clientY - docheight));
		} 
		else 
		{
			y += truebody().scrollTop + event.clientY;
		}
	}
	if ( x < 0 )
		x = 0;
	if ( y < 0 )
		y = 0;
	gettrailobj().left=x+"px"
	gettrailobj().top=y+"px"
}