﻿var isOpen = "no";

/*
Simple Image Trail script- By JavaScriptKit.com
Visit http://www.javascriptkit.com for this script and more
This notice must stay intact
*/

var trailimage = ["", 400, 183] //image path, plus width and height
var offsetfrommouse = [25, -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.

if (displayduration > 0) setTimeout("hidetrail()", displayduration * 1000)

if (document.getElementById || document.all) {
    document.write('<div id="trailimageid" style="position:absolute;visibility:hidden;left:0px;top:0px;width:auto;height:auto;padding:10px;border-top:solid 2px grey;border-left:solid 2px grey;border-right:solid 3px black;border-bottom:solid 3px black;background:white;"><img id="theimage" src="_img/loading.gif" style="border: solid 1px grey;"></div>');
}


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(whichimage) {  
    var theImage = document.getElementById('theimage');
    if (theImage != null) {        
        whichimage = whichimage.replace(".jpg", ".gif");       
        theImage.setAttribute('src', whichimage);
        document.onmousemove = followmouse;
        gettrailobj().visibility = "visible";
    }
}


function hidetrail() {
    gettrailobj().visibility = "hidden";
    var theImage = document.getElementById('theimage');
    if (theImage != null) {
        theImage.setAttribute('src', '_img/loading.gif');
    }
    document.onmousemove = "";

}

function followmouse(e) {

    var xcoord = 0;
    var ycoord = 0;

    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) {
        //gettrailobj().display = "none"
        gettrailobj().left = xcoord - trailimage[1] - 50 - offsetfrommouse[0] + "px"
    }
    else {
        //gettrailobj().display = ""
        gettrailobj().left = xcoord + offsetfrommouse[0] + "px"
    }
    if (ycoord + trailimage[2] > truebody().scrollTop + truebody().clientHeight) {
        //gettrailobj().display = "none"
        gettrailobj().top = ycoord - trailimage[2] + offsetfrommouse[1] + "px"
    }
    else {
        //gettrailobj().display = ""
        gettrailobj().top = ycoord + offsetfrommouse[1] + "px"
    }

}

function SwitchImage(imageobject, imagename) {
    var myObj = document.getElementById(imageobject);
    myObj.src = imagename;
}
