/*  image hover */
/* ver 0.4 by boris for webflow.web dynamic web sites*/


if (document.getElementById || document.all){
document.write('<div id="trailimageid" style="z-index:2000;">');
document.write('</div>');
}

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 get_image(){
if (document.getElementById)	return document.getElementById("timage")
else if (document.all)	return document.all.trailimagid
}

function truebody(){
return (!window.opera && document.compatMode && document.compatMode!="BackCompat")? document.documentElement : document.body
}

function showtrail(imagename,title,height){

document.onmousemove=followmouse;

newHTML = '<div style="padding: 5px; background-color: #FFF; border: 1px solid #888;">';
newHTML = newHTML + '<div align="center" style="padding: 2px 2px 2px 2px;">';
newHTML = newHTML + '<img name="timage" id="timage" src="' + imagename + '" border="0"></div>';
newHTML = newHTML + '</div>';

gettrailobjnostyle().innerHTML = newHTML;
gettrailobj().display="none";
gettrailobj().position="absolute";

}

function hidetrail(){
gettrailobj().innerHTML = " ";
gettrailobj().display="none"
document.onmousemove=""
gettrailobj().left="-500px"

}

function followmouse(e){

var xcoord=15;			//offset from mouse
var ycoord=15;			//offset from mouse

var docwidth=document.all? truebody().scrollLeft+truebody().clientWidth : pageXOffset+window.innerWidth-1
var docheight=document.all? Math.min(truebody().scrollHeight, truebody().clientHeight) : Math.min(window.innerHeight)

var trailwidth=get_image().width;  //get_image().width+10; 
var trailheight=get_image().height; 	//get_image().height+10;	

if (typeof e != "undefined"){
if ((docwidth - e.pageX + truebody().scrollLeft ) < (trailwidth +50) ){
xcoord = xcoord - trailwidth + e.pageX -50 ; // Move to the left side of the cursor or to the right side of the page
} else {
xcoord += e.pageX;
}
if ((docheight - e.pageY + truebody().scrollTop) < trailheight && e.pageY > (trailheight) ){
ycoord += e.pageY - trailheight -30  - ycoord;
} else {
ycoord += e.pageY;
}

} else if (typeof window.event != "undefined"){
if ((docwidth - event.clientX+ truebody().scrollLeft ) < (trailwidth +30) ){
xcoord = xcoord - trailwidth - 30 + event.clientX; // Move to the left side of the cursor or to the right side of the page
} else {
xcoord += truebody().scrollLeft+event.clientX
}

if ((docheight - event.clientY < trailheight) && event.clientY > (trailheight -80) ) {
ycoord += event.clientY + truebody().scrollTop - ycoord  - trailheight -30 ;// + docheight;
} else {
ycoord += truebody().scrollTop + event.clientY;
}
}

if(ycoord < 0) { ycoord = ycoord*-1; }
gettrailobj().left=xcoord+"px"
gettrailobj().top=ycoord+"px"
gettrailobj().display="inline";
}
