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

var imgWidth=1; 
var imgHeight=1;//image path, plus width and height
var docSize = [500,500];
var offsetfrommouse=[20,20];
var displayduration=0;

if (document.getElementById || document.all){
	document.write('<div id="trailimageid" style="color: #CC3333;position:absolute;visibility:hidden;left:0px;top:0px; border : 1px solid #CC3333; padding: 5px;background-image: url(./images/thumbback.jpg);"></div>');
	document.write('</div>');
}

gettrailobj().visibility="hidden"; //hide object on begin


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 hidetrail(){

gettrailobj().visibility="hidden"
document.onmousemove=""

}

function followmouse(e){
var xcoord=offsetfrommouse[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
}
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 (xcoord+trailimage[1]+3>docwidth || ycoord+trailimage[2]> docheight)
gettrailobj().display="none"
else
gettrailobj().display="";*/

//if (((xcoord +imgWidth+20+offsetfrommouse[0]) > (docSize[0]))){xcoord-=(xcoord +imgWidth+20+offsetfrommouse[0])-(docSize[0]);}
//if (((ycoord +imgHeight+20+offsetfrommouse[1]) > (docSize[1]))){ycoord-=(ycoord +imgHeight+20+offsetfrommouse[1])-(docSize[1]);}

if (((xcoord +imgWidth+20+offsetfrommouse[0]) > (docwidth))){xcoord-=(imgWidth+40+offsetfrommouse[0]);}
if (((ycoord +imgHeight+20+offsetfrommouse[1]) > (docheight))){ycoord-=(imgHeight+40+offsetfrommouse[1]);}


gettrailobj().left=xcoord+"px"
gettrailobj().top=ycoord+"px"
}


function showtrail(imagename,description,width,height){

imgWidth=parseInt(width);
imgHeight=parseInt(height);
document.onmousemove=followmouse;

gettrailobjnostyle().innerHTML = "<div id=\"trailimageid\"><img src=\""+imagename+"\"><br />"+ 
"<div style=\"color: #CC3333; width: "+(width-10)+"px; padding: 2px;\"><span>"+description+"</span></div></div>";
gettrailobj().display="inline";
gettrailobj().visibility = 'visible';
}

if (displayduration>0)
setTimeout("hidetrail()", displayduration*1000)


