var trailimage=["", 100, 99]; //image path, plus width and height
var offsetfrommouse=[-180,-100]; //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 siteBox;
siteBox = '<div id="trailimageid" style="position:absolute;visibility:visible;left:0px;top:0px;width:1px;height:1px"></div>';

//Visar sidans information i en popup-ruta som följer musen.
function showSiteDescription(page,description,image)
{

gettrailobj().style.visibility="visible";

siteBox = "";
//siteBox = '<div id="trailimageid" style="border:1px solid;border-color:#000;color:#000;z-index:5;background-color: #FFF; position:absolute; visibility:visible; left:0px; top:0px;opacity: .9;width:150px;">';
siteBox = siteBox + '<b style="font-size:12px;">'+ page +'</b><br>';
siteBox = siteBox + description + '<br>';
siteBox = siteBox + '<img src="'+image+'" border="0" width="150" height="100">';
//siteBox = siteBox + '</div>';

gettrailobj().innerHTML = siteBox;
document.onmousemove=followmouse();
}


//Gömmer popup-rutan
function hideSiteDescription()
{

siteBox = '<div id="trailimageid" style="position:absolute;visibility:visible;left:0px;top:0px;width:1px;height:1px"></div>';
siteBox = "";
gettrailobj().innerHTML = siteBox;
gettrailobj().style.visibility="hidden";


document.onmousemove="";

}

//siteBox = '<div id="trailimageid" style="border:1px solid;border-color:#000;color:#000;z-index:5;background-color: #FFF; position:absolute; visibility:visible; left:0px; top:0px;opacity: .9;width:150px;">';

var siteBox = '<div id="trailimageid" style="border:1px solid;border-color:#000;color:#000;z-index:5;background-color: #FFF; position:absolute; visibility:hidden; left:0px; top:0px;opacity: .9;width:150px;"></div>';



if (document.getElementById || document.all)
{
	document.write(siteBox);
}



function gettrailobj()
{
	if (document.getElementById)
	{
		return document.getElementById("trailimageid");
	}
	else if (document.all)
	{
		return document.all.trailimageid;
	}
}
/*
function gettrailobjnostyle()
{
	if (document.getElementById)
	{
		return document.getElementById("trailimageid");
	}
	else if (document.all)
	{
		return document.all.trailimageid;
	}
}
*/

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


/*
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+100+3>docwidth || ycoord+100> docheight)
gettrailobj().style.display="none"
else 
gettrailobj().style.display=""
gettrailobj().style.left=xcoord+"px"
gettrailobj().style.top=ycoord+"px"
}
*/



function followmouse(e)
{
var xcoord=offsetfrommouse[0];
var ycoord=offsetfrommouse[1];

//document.write("Xcoord:" + xcoord+"px  \nYcoord:" +ycoord);
	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;
	}
	
	//xcoord = 170;
	
var docwidth=document.all? truebody().scrollLeft+truebody().clientWidth : pageXOffset+window.innerWidth-15;

	if (document.body != null)
	{
	var docheight=document.all? Math.max(truebody().scrollHeight, truebody().clientHeight) : Math.max(document.body.offsetHeight, window.innerHeight);
	
	}
	else
	{
		var docheight = 2000;	
	}
	
	if (xcoord+trailimage[1]+3>docwidth || ycoord+trailimage[2]> docheight)
	{
	gettrailobj().style.display="none";
	}
	else
	{ 
	//gettrailobj().style.display="";
		if (gettrailobj() != null)
		{
			if (xcoord < 0 || xcoord > 1600)
			{
				xcoord = 100;
			}
			if (ycoord < 0 || ycoord > 1600)
			{
				ycoord = 100;
			}
			//alert("Style.left:" + gettrailobj().style.left + "\nXcoord: " + xcoord);
		gettrailobj().style.left=xcoord+"px";
		gettrailobj().style.top=ycoord+"px";
		}


			
	}
}

document.onmousemove=followmouse();



