/*
Simple Image Trail script- By JavaScriptKit.com
Visit http://www.javascriptkit.com for this script and more
This notice must stay intact
*/

function showThumb(id, model, thumbtitle, src, width){
	document.onmousemove=followMouse;
	var el = document.getElementById('home-thumbnail');
	el.innerHTML = "<img src=\""+src+"\" alt=\""+thumbtitle+"\" /><p>"+thumbtitle+"<\/p>";
	var myimg = document.getElementById("home-thumbnail").getElementsByTagName("img");
	getObjectStyle().width=width+"px";
	getObjectStyle().visibility="visible";
}

var offsetfrommouse=[15,-20] //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 = 160;	// maximum image size.


if (document.getElementById || document.all)
document.write('<div id="home-thumbnail"><\/div>')



function getObjectStyle(){
if (document.getElementById)
return document.getElementById("home-thumbnail").style
else if (document.all)
return document.all.rv-thumb-nail.style
}

function truebody(){
return (!window.opera && document.compatMode && document.compatMode!="BackCompat")? document.documentElement : document.body
}

function hideThumb(){
getObjectStyle().visibility="hidden"
document.onmousemove=""
getObjectStyle().left="-500px"
}

function followMouse(e){
var xcoord=offsetfrommouse[0]
var ycoord=offsetfrommouse[1]

var myimg = document.getElementById("home-thumbnail").getElementsByTagName("img");
var w = myimg[0].width;
var currentimageheight = myimg[0].height;

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 < (w + 50)){
			xcoord = e.pageX - xcoord - (w + 10);
		} else {
			xcoord += e.pageX;
		}
		if (docheight - e.pageY < (currentimageheight + 40)){
			ycoord += e.pageY - Math.max(0,(40 + currentimageheight + e.pageY - docheight - truebody().scrollTop));
		}else{
			ycoord += e.pageY;
		}

		//ycoord += e.pageY;
}
else if (typeof window.event !="undefined"){
		if (docwidth - event.clientX < (w + 50)){
			xcoord = event.clientX + truebody().scrollLeft - xcoord - (w + 10);
		} else {
			xcoord += truebody().scrollLeft+event.clientX;
		}
		if (docheight - event.clientY < (currentimageheight + 40)){
			ycoord += event.clientY + truebody().scrollTop - Math.max(0,(40 + currentimageheight + event.clientY - docheight));
		}else{
			ycoord += truebody().scrollTop + event.clientY;
		}
			//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)

getObjectStyle().left=xcoord+"px"
getObjectStyle().top=ycoord+"px"
}

if (displayduration>0)
setTimeout("hideThumb()", displayduration*1000)
