/*
Simple Image Trail script- By JavaScriptKit.com
Visit http://www.javascriptkit.com for this script and more
This notice must stay intact
*/

var offsetfrommouse=[-400,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 currentimagewidth = 300;	// temp
var currentimageheight = 270;	// 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(imagename,title,description,height,width)
{
	document.onmousemove = followmouse;

	var xcoord=-5000
	var ycoord=-5000

	newHTML = '<div id="zoomPhoto" style="position:absolute; z-index:1;visibility:visible;left:' + xcoord + 'px;top:' + ycoord + 'px;padding: 5px; background-color: #FFF; border: 1px solid #888;">';
	newHTML = newHTML + '<div align="center" style="padding: 2px 2px 2px 2px;">';
	newHTML = newHTML + '<img src="' + imagename + '"';
	
	if (height > 0 && width > 0)
	{
		newHTML = newHTML + ' height="' + height + '" width="' + width + '"';
	}
	newHTML = newHTML + ' border="0"/></div>';
	newHTML = newHTML + '</div>';

	gettrailobjnostyle().innerHTML = newHTML;
	gettrailobj().display="inline";

	currentimageheight = document.getElementById("zoomPhoto").offsetHeight;
	currentimagewidth = document.getElementById("zoomPhoto").offsetWidth;

	followmouse(0);
}

function hidetrail()
{
	gettrailobj().innerHTML = " ";
	gettrailobj().display="none"
	document.onmousemove=""
	gettrailobj().left="-500px"
}

function followmouse(e)
{
	var xcoord=0
	var ycoord=offsetfrommouse[1]

	if (typeof e != "undefined")
	{
		xcoord+=e.pageX
		ycoord+=e.pageY
	}
	else if (typeof window.event !="undefined")
	{
		xcoord+=truebody().scrollLeft+event.clientX
		ycoord+=truebody().scrollTop+event.clientY
	}

	xcoord+=(currentimagewidth * -1) - 15;
	ycoord+=(currentimageheight/1.25 * -1);

	if (ycoord < 458)
	{
		ycoord = 458;
	}

	document.getElementById("zoomPhoto").style.left = xcoord+"px";
	document.getElementById("zoomPhoto").style.top = ycoord+"px";
}
