/*
Simple Image Trail script- By JavaScriptKit.com
Visit http://www.javascriptkit.com for this script and more
This notice must stay intact

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 divh = 270;	// maximum image size.
*/

var offsetfrommouse=[15,15];
var ua = navigator.userAgent.toLowerCase();
var divw=0;
var divh=0;

if (document.getElementById || document.all)
	document.write('<div id="imgtrailer" style="position:absolute;visibility:hidden;"></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='';
	gettrailobj().visibility="hidden";
	}

function trailOnnoroomset(thumbimg,imgtitle,thw,thh)
	{
	if(ua.indexOf('opera') == -1 && ua.indexOf('safari') == -1)
		{
		gettrailobj().left="-1000px"; // distance where image loads before appearing onscreen
		divthw = parseInt(thw)+0; // the total width required
		gettrailobject().innerHTML = '<div style="background-color: #fffed8; layer-background-color: #fffed8; border: 1px none #808080; padding:10px; width:'+divthw+'px;"><img src="'+thumbimg+'" border="0" width="'+thw+'" height="'+thh+'"><br><span class="txtgrey11">'+imgtitle+'</span></div>';
		gettrailobj().visibility="visible";
		divw = parseInt(thw)+250;
		divh = parseInt(thh)+13;
		document.onmousemove=followmouse;
		}
	}

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 (document.all){
	//	gettrailobjnostyle().innerHTML = 'A = ' + truebody().scrollHeight + '<br>B = ' + truebody().clientHeight;
	//} else {
	//	gettrailobjnostyle().innerHTML = 'C = ' + document.body.offsetHeight + '<br>D = ' + window.innerHeight;
	//}

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

	} else if (typeof window.event != "undefined"){ // typically this deals with moving the image to the left
		if (docwidth - event.clientX < 730){
			xcoord = event.clientX + truebody().scrollLeft - xcoord - 620; // Move to the left side of the cursor
		} else {
			xcoord += truebody().scrollLeft+event.clientX
		}
		if (docheight - event.clientY < (divh + 110)){
			ycoord += event.clientY + truebody().scrollTop - Math.max(0,(110 + divh + event.clientY - docheight));
		} else {
			ycoord += truebody().scrollTop + event.clientY;
		}
	}

	var docwidth=document.all? truebody().scrollLeft+truebody().clientWidth : pageXOffset+window.innerWidth-15
	var docheight=document.all? Math.max(truebody().scrollHeight, truebody().clientHeight) : Math.max(document.body.offsetHeight, window.innerHeight)
		if(ycoord < 0) { ycoord = ycoord*-1; 
	}
	gettrailobj().left=xcoord+"px"
	gettrailobj().top=ycoord+"px"
	}

