//****************************************************
//* JavaScript Tooltip for IE, Netscape, and Firefox *
//* Written By: Matt Wiggins                         *
//* Updated: 10.07.2005                              *
//****************************************************

// configurable options for the tooltip
var font = "Arial";
var font_size = "0.75em";
var pad = "5px";
var bg_color = "#000000";
var border_style = "none";
var border_width = "0px";
var border_color = "#666666";

// create div for tooltip onload
window.onload = create_div;

// mouse pos
xMousePos = 0; // Horizontal position of the mouse on the screen
yMousePos = 0; // Vertical position of the mouse on the screen

// check browser
if (document.layers) { // Netscape
    document.captureEvents(Event.MOUSEMOVE);
    document.onmousemove = captureMousePosition;
} else if (document.all) { // Internet Explorer
    document.onmousemove = captureMousePosition;
} else if (document.getElementById) { // Netcsape 6
    document.onmousemove = captureMousePosition;
}

// create tooltip
function create_div() {
	// create a new div for the tooltip
	var objNewDiv = document.createElement("div");
	objNewDiv.id = "divInfo";
	
	// set styles for tooltip
	objNewDiv.style.zIndex = 50000; // king of all
	objNewDiv.style.position = "absolute";
	objNewDiv.style.display = "none";
	objNewDiv.style.top = 0;
	objNewDiv.style.left = 0;
	objNewDiv.style.width = 0;
	objNewDiv.style.fontFamily = font;
	objNewDiv.style.fontSize = font_size;
	objNewDiv.style.color = "#666666";
	objNewDiv.style.padding = pad;
	objNewDiv.style.backgroundColor = bg_color;
	objNewDiv.style.borderStyle = border_style;
	objNewDiv.style.borderWidth = border_width;
	objNewDiv.style.borderColor = border_color;
	objNewDiv.style.textAlign = "center";
	
	// append the div to the body
	document.body.appendChild(objNewDiv);
}

// show tooltip
function tooltip(obj) {
	objDiv = document.getElementById("divInfo");
	
	var text = obj.msg;
	var w = 0;
	
	for(x = 0; x < text.length; x++) {
		w += 6;
	}
	
	objDiv.style.width = w + "px";
	objDiv.innerHTML = text;
	objDiv.style.display = "block";
}

// lock tooltip to the mouse
function captureMousePosition(e) {
	objDiv = document.getElementById("divInfo");
	
    if (document.layers) {
        xMousePos = e.pageX;
        yMousePos = e.pageY;
    } else if (document.all) {
        xMousePos = window.event.x+document.body.scrollLeft;
        yMousePos = window.event.y+document.body.scrollTop;
    } else if (document.getElementById) {
        xMousePos = e.pageX;
        yMousePos = e.pageY;
    }
	
	if (xMousePos < 0){xMousePos = 0}
	if (yMousePos < 0){yMousePos = 0}  
	
	if(objDiv) objDiv.style.left = xMousePos - 48 + 'px';
	if(objDiv) objDiv.style.top = yMousePos + 30 + 'px';
}

// hide tooltip
function untooltip(obj) {
	objDiv = document.getElementById("divInfo");
	objDiv.style.display = "none";
}