/************************

HELP: http://www.willmaster.com/blog/css/floating-layer-at-cursor-position.php

*************************/

/**
var cX = 0; var cY = 0; var rX = 0; var rY = 0;
	
function UpdateCursorPosition(e){ cX = e.pageX; cY = e.pageY;}

function UpdateCursorPositionDocAll(e){ cX = event.clientX; cY = event.clientY;}

if(document.all) { document.onmousemove = UpdateCursorPositionDocAll; }
else { document.onmousemove = UpdateCursorPosition; }

function AssignPosition(d) {
	if(self.pageYOffset) {
		rX = self.pageXOffset;
		rY = self.pageYOffset;
		}
	else if(document.documentElement && document.documentElement.scrollTop) {
		rX = document.documentElement.scrollLeft;
		rY = document.documentElement.scrollTop;
		}
	else if(document.body) {
		rX = document.body.scrollLeft;
		rY = document.body.scrollTop;
		}
	if(document.all) {
		cX += rX; 
		cY += rY;
		}
	d.style.left = (cX+15) + "px";
	d.style.top = (cY+15) + "px";
}
function HideContent(d) {
	if(d.length < 1) { return; }
	document.getElementById(d).style.display = "none";
}
function ShowContent(d) {
	if(d.length < 1) { return; }
	var dd = document.getElementById(d);
	AssignPosition(dd);
	dd.style.display = "block";
}
function ReverseContentDisplay(d) {
	if(d.length < 1) { return; }
	var dd = document.getElementById(d);
	AssignPosition(dd);
	if(dd.style.display == "none") { dd.style.display = "block"; }
	else { dd.style.display = "none"; }
}
**/



//Edit the informaiton between the quotes below with the path to your image.

var offsetfromcursorX=-7; //Customize x offset of tooltip
var offsetfromcursorY=23; //Customize y offset of tooltip

var offsetdivfrompointerX=13; //Customize x offset of tooltip DIV relative to pointer image
var offsetdivfrompointerY=13; //Customize y offset of tooltip DIV relative to pointer image. Tip: Set it to (height_of_pointer_image-1).


ie=document.all;
ns6=document.getElementById && !document.all;
enabletip=false;
	
/*	This codeblock (w/o the dom:loaded wrap) has been placed inline 
document.observe("dom:loaded", function() {

	tipobj = $('infoPane');
	
	pointerobj= $('infoPanePointer'); //element that is an img tag with the pointer graphic
	
	document.onmousemove=positiontip;

}); 
*/

function ietruebody(){
	return (document.compatMode && document.compatMode!="BackCompat")? document.documentElement : document.body;
}

function ShowContent(id){
	
	enabletip=true;
	
	// If tooltip is empty, bail out.
	// *** NOTE: Prototype Library DEPENDENCY ***
	if($('infoPaneUpdate')) {
		if(	$('infoPaneUpdate').innerHTML.length < 10 || tipobj.innerHTML.length < 10  ) {
			return;	
		}
	}
	if(!tipobj.visible()) {
		new Effect.Appear(tipobj.id, { duration: 0.3 });
		//tipobj.show();
	}
	
	
	return false;	
}

function positiontip(e){
	if (enabletip){
	var nondefaultpos=false;
	var curX=(ns6)?e.pageX : event.clientX+ietruebody().scrollLeft;
	var curY=(ns6)?e.pageY : event.clientY+ietruebody().scrollTop;
	//Find out how close the mouse is to the corner of the window
	var winwidth=ie&&!window.opera? ietruebody().clientWidth : window.innerWidth-20;
	var winheight=ie&&!window.opera? ietruebody().clientHeight : window.innerHeight-20;
	
	var rightedge=ie&&!window.opera? winwidth-event.clientX-offsetfromcursorX : winwidth-e.clientX-offsetfromcursorX;
	var bottomedge=ie&&!window.opera? winheight-event.clientY-offsetfromcursorY : winheight-e.clientY-offsetfromcursorY;
	
	var leftedge=(offsetfromcursorX<0)? offsetfromcursorX*(-1) : -1000;
	
	//if the horizontal distance isn't enough to accomodate the width of the context menu
	if (rightedge<tipobj.offsetWidth){
		//move the horizontal position of the menu to the left by it's width
		tipobj.style.left=curX-tipobj.offsetWidth+"px";
		nondefaultpos=true;
	}
	else if (curX<leftedge)
	{tipobj.style.left="5px";}
	else{
		//position the horizontal position of the menu where the mouse is positioned
		tipobj.style.left=curX+offsetfromcursorX-offsetdivfrompointerX+"px";
		pointerobj.style.left=curX+offsetfromcursorX+"px";
	}
	
	//same concept with the vertical position
	if (bottomedge<tipobj.offsetHeight){
		tipobj.style.top=curY-tipobj.offsetHeight-offsetfromcursorY+"px";
		nondefaultpos=true;
	}
	else{
		tipobj.style.top=curY+offsetfromcursorY+offsetdivfrompointerY+"px";
		pointerobj.style.top=curY+offsetfromcursorY+"px";
	}
	tipobj.style.visibility="visible";
	if (!nondefaultpos) {pointerobj.style.visibility="visible";}
	else{
		pointerobj.style.visibility="hidden";}
	}
}

function HideContent(id){

	enabletip=false;
	if(tipobj.visible()) {
		//new Effect.Fade(tipobj.id, { duration: 0.3 });
		tipobj.hide();
	}
	
}



