//Some groovy dHTML © Jim Richardson 2002.
//If you want to use it credit me, or karma will come and getcha!

//Initialise master vars

chosenLayer = 'none';

masterVis = 'visible';

helpState = true;

offpointX = 12;

offpointY = 12;

//determine which model - IE or DOM compliant - then init mousemove event handler

if (document.all){
	document.onmousemove=follow;
	}
	
if(document.getElementById){
	window.addEventListener("mousemove",follow,false);
	}
	
//Init follow function

function follow(e){

	if(document.getElementById && !document.all){ //DOM Compliant
		if(chosenLayer != 'none'){
			checkWidth = e.clientX + offpointX + 20 + parseFloat(document.getElementById(chosenLayer).style.width);
			maxHoriz = window.innerWidth - offpointX - 6 - parseFloat(document.getElementById(chosenLayer).style.width);
			if (window.innerWidth <= checkWidth){
				eval('document.getElementById(chosenLayer).style.left = \'' + maxHoriz + 'px\';');
				eval('document.getElementById(chosenLayer).style.top = \'' + (e.clientY + offpointY + window.pageYOffset) + 'px\';')
				document.getElementById(chosenLayer).style.visibility = masterVis;
				}
			else{
				eval('document.getElementById(chosenLayer).style.left = \'' + (e.clientX + offpointX) + 'px\';');
				eval('document.getElementById(chosenLayer).style.top = \'' + (e.clientY + offpointY + window.pageYOffset) + 'px\';');
				document.getElementById(chosenLayer).style.visibility = masterVis;
				}
			}
		}
		
	if (document.all){ //IE
		if (chosenLayer != 'none'){
			if (document.body.clientWidth <= event.x + offpointX + parseFloat(document.all(chosenLayer).style.width)){
				document.all(chosenLayer).style.left = document.body.clientWidth - 2 - parseFloat(document.all(chosenLayer).style.width);
				document.all(chosenLayer).style.top = document.documentElement.scrollTop + event.y + offpointY;
				document.all(chosenLayer).style.visibility = masterVis;
				}
			else{
				document.all(chosenLayer).style.left = document.body.scrollLeft + event.x + offpointX;
				document.all(chosenLayer).style.top = document.documentElement.scrollTop + event.y + offpointY;
				document.all(chosenLayer).style.visibility = masterVis;
				}
			}
		}

}

function visible(layerid,state){

	masterVis = state

	if (state == 'visible'){
		chosenLayer = layerid;
		}

	else{
		chosenLayer = 'none';
		}

	if (document.getElementById && !document.all){
			eval('document.getElementById(\'' + layerid + '\').style.visibility = \'hidden\'');
		}

	if (document.all){
		document.all(layerid).style.visibility = 'hidden';
		}
}