/*
Simple Image Trail script - By JavaScriptKitten.com
This notice must stay intact
*/

var offsetfrommouse=[15,0] //image x,y offsets from cursor position in pixels. Enter 0,0 for no offset

function loadQT()
{
   if (document.getElementById || document.all) {
// Change path to blank.gif !
    document.write('<div id="trailimageid"><img src="/blank.gif"></div>');
//    gettrailobj().width=0;
//    gettrailobj().height=0;
//    gettrailobj().left="-1000px"
//    gettrailobj().top="0px"
//    gettrailobj().visibility="hidden"
//    gettrailobj().display=""
   }

}

loadQT()


function gettrailobj(){
if (document.getElementById)
return document.getElementById("trailimageid").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 showtrail(comppath,compwidth,compheight){
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(document.body.offsetHeight, window.innerHeight)

  if (docwidth < xcoord+compwidth || docheight < truebody.scrollTop+compheight) {
    gettrailobj().visible="none"
  } else {
    if (typeof e != "undefined") {
      xcoord+=e.pageX
      ycoord+=e.pageY
      if (xcoord+compwidth+14 >docwidth)
        xcoord = e.pageX - compwidth - offsetfrommouse[0]
      if (ycoord+compheight+15> docheight + truebody().scrollTop)
        ycoord = (truebody().scrollTop+docheight) - compheight - 40
    }
    else if (typeof window.event !="undefined") {
      xcoord+=truebody().scrollLeft+event.clientX
      ycoord+=truebody().scrollTop+event.clientY

      if (xcoord+compwidth+14 > docwidth) 
        xcoord = (truebody().scrollLeft+event.clientX) - compwidth - offsetfrommouse[0]
      if (ycoord+compheight > docheight + truebody().scrollTop) 
        ycoord = (truebody().scrollTop+docheight) - compheight - 15

      // this is to move the .top up if it is too far down from the mouse pointer
      if (ycoord > (truebody().scrollTop+event.clientY) + 10)
         ycoord  = ycoord  - (ycoord - (truebody().scrollTop+event.clientY))
    }
  }

  if (xcoord < 0 || ycoord < 0) {
    gettrailobj().visible="none"
    gettrailobj().display=""
  } else {
    gettrailobj().display=""
    gettrailobj().left=xcoord+"px"
    gettrailobj().top=ycoord+"px"
  }  
}

document.onmousemove=followmouse;

document.getElementById("trailimageid").innerHTML = '<div style="width:'+compwidth+'px;height:'+compheight+'px;padding:4px;background-color:#fff;border:1px solid #888;"><img src="'+comppath+'" border="0"></div>'

gettrailobj().width=compwidth;
gettrailobj().height=compheight;
gettrailobj().visibility="visible";
}

function hidetrail(){
gettrailobj().visibility="hidden"
gettrailobj().left="-1000px"
document.onmousemove=""
}
