/*
 * Script for website www.modulo-architects.be
 * 
 * This script deals with the floating text over the images.
 *
 * @ author: Lieven Van Landschoot.
 */
var divName = 'floating'; // div that is to follow the mouse
var offX = 20; // X offset from mouse position
var offY = -5; // Y offset from mouse position

/* function moving the div to the horizontal mouse-position */ 
function mouseX(evt){
	if (!evt) evt = window.event; 
	if (evt.pageX) return evt.pageX; 
	else if (evt.clientX)return evt.clientX + (document.documentElement.scrollLeft ?  document.documentElement.scrollLeft : document.body.scrollLeft); else return 0;
}

/* function moving the div to the vertical mouse-position */ 
function mouseY(evt) {
	if (!evt) evt = window.event; 
	if (evt.pageY) return evt.pageY; else if (evt.clientY)return evt.clientY + (document.documentElement.scrollTop ? document.documentElement.scrollTop : document.body.scrollTop); else return 0;
}

/* function moving the div to the current mouse-position */ 
function follow(evt) {
	if (document.getElementById){
		var obj = document.getElementById(divName).style; 
		obj.visibility = 'visible';
		obj.left = (parseInt(mouseX(evt))+offX) + 'px';
		obj.top = (parseInt(mouseY(evt))+offY) + 'px';
	}
}

/* making sure that the div moves when the mouse moves */ 
document.onmousemove = follow;


/* function hiding the div */ 
function HideContent(d) {
	if(d.length < 1) { 
		return; 
	}
	document.getElementById(d).style.display = "none";
	offX = 20;
}

/* function showing the div and loading it with the given content */ 
function ShowContent(d,content,position) {
	if(d.length < 1){
		return; 
	}
	if(position > 5){
		offX = -155; // on the left side the div will be positioned on the right side of the mouse
	}
	var dd = document.getElementById(d);
	dd.style.display = "block";
	dd.innerHTML = content;
}



