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

wordt gebruikt voor produktinfo

voorbeeld:

<a href="?actie=details&productid=1244&act_rub=35">
<img onmouseover="showtrail('%3Cspan+class%3D%27titel%27%3EElement%3Cbr%3ECannon+cubic%3C%2Fspan%3E%3Cbr%3EBoz%3Cbr%3E%3Cspan+class%3D%27prijs%27%3E%26euro%3B+60.00%3C%2Fspan%3E%3Cbr%3E%3Cimg+name%3D%27Cannon+cubic%27+src%3D%27..%2Fcms_files%2Fshop%2Fproductenafbeeldingen%2F1244_thumb_CANNON-CUBIC7%2C5.jpg%27+width%3D%27200%27+%2F%3E%3Cbr+%2F%3E');" 
onmouseout="hidetrail();" 
name="Cannon cubic" src="../cms_files/shop/productenafbeeldingen/1244_minithumb_CANNON-CUBIC7,5.jpg" width="90" border="0" /></a>

*/

var offsetfrommouse=[15,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.
var currentimageheight = 270;	// maximum image size.
var eerstekeer = true;

if (document.getElementById || document.all){
	document.write('<div id="trailimageid">');
	document.write('</div>');
	document.write('<iframe id="DivShim" src="javascript:false;" scrolling="no" frameborder="0" style="position:absolute; top:0px; left:0px; display:none;"></iframe>');
}

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 getdivshimobj(){
if (document.getElementById)
return document.getElementById("DivShim").style
else if (document.all)
return document.all.DivShim.style
}


function urldecode(str){
    str=str.replace(new RegExp('\\+','g'),' ');
    return unescape(str);
}

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

function showtrail(html){
	document.onmousemove=followmouse;

	newHTML = '<div style="padding-left: 5px; background-color: #FFFFFF; border: 1px solid #333333;">'+urldecode(html)+'</div>';

	gettrailobjnostyle().innerHTML = newHTML;
	
	//if(!(navigator.userAgent.indexOf('Mac') != -1)){ 
	if(eerstekeer == true){	
		followmouse();
		eerstekeer = false;
	}
	
	gettrailobj().visibility="visible";
}


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

}

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 (document.all){
	//	gettrailobjnostyle().innerHTML = 'A = ' + truebody().scrollHeight + '<br>B = ' + truebody().clientHeight;
	//} else {
	//	gettrailobjnostyle().innerHTML = 'C = ' + document.body.offsetHeight + '<br>D = ' + window.innerHeight;
	//}
	
	if(navigator.appName == "Microsoft Internet Explorer"){
		getdivshimobj().width = gettrailobjnostyle().offsetWidth;
		getdivshimobj().height = gettrailobjnostyle().offsetHeight;
		getdivshimobj().top = gettrailobj().top;
		getdivshimobj().left = gettrailobj().left;
		getdivshimobj().zIndex = 999;
		getdivshimobj().display = "block";	
	}

	if (typeof e != "undefined"){
		if (docwidth - e.pageX < 300){
			xcoord = e.pageX - xcoord - 200; // Move to the left side of the cursor
		} else {
			xcoord += e.pageX;
		}
		if (docheight - e.pageY < (currentimageheight + 110)){
			ycoord += e.pageY - Math.max(0,(110 + currentimageheight + e.pageY - docheight - truebody().scrollTop));
		} else {
			ycoord += e.pageY;
		}

	} else if (typeof window.event != "undefined"){
		if (docwidth - event.clientX < 300){
			xcoord = event.clientX + truebody().scrollLeft - xcoord - 200; // Move to the left side of the cursor
		} else {
			xcoord += truebody().scrollLeft+event.clientX
		}
		if (docheight - event.clientY < (currentimageheight + 110)){
			ycoord += event.clientY + truebody().scrollTop - Math.max(0,(110 + currentimageheight + event.clientY - docheight));
		} else {
			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)

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

}