

// Define browser version.
var ns4 = (document.layers)? true:false;
var ns6 = (document.getElementById)? true:false;
var ie4 = (document.all)? true:false;
var ie5 = false; 


if (ie4) { 
	if ((navigator.userAgent.indexOf('MSIE 5') > 0) || (navigator.userAgent.indexOf('MSIE 6') > 0)) {
		ie5 = true;
	}
	if (ns6) {
		ns6 = false;
	}
}

// Define the tooltipLayer object.
if (ns4) {
	tooltipObj = self.document.tooltipLayer;
}
if (ie4) {
	tooltipObj = self.tooltipLayer.style;
}
if (ns6) {
	tooltipObj = self.document.getElementById("tooltipLayer");
}

// Define the tooltipLayer's default state.
showtooltip = false;

// Map the onmousemove event function.
if ((ns4) || (ie4) || (ns6)) {
	document.onmousemove=mouseMove
	if (ns4) { 
		document.captureEvents(Event.MOUSEMOVE);
	}
}

// Define the "tooltip" function.
function tooltip(text) {
	if (!text) {
		layerHide();
		showtooltip = false;	
	}
	else {
		layerWrite(text);
		layerShow();
		showtooltip = true;	
	}
}

// Define the "mouseMove" function.
function mouseMove(e) {

	// Get mouse coordinates.
	if ((ns4) || (ns6)) {
		x = e.pageX;
		y = e.pageY;
	}
	if (ie4) {
		x = event.x;
		y = event.y;
	}
	if (ie5) {
		x = event.x + self.document.body.scrollLeft;
		y = event.y + self.document.body.scrollTop;
	}

	// Calculate the tooltipLayer coordinates.
	x -= -120; 
	y -= 30; 

	if (showtooltip) {
		// Execute the layermove function.
		layerMove(x, y);
	}
}

// Define the "layerMove" function.
function layerMove(x, y) {
	if ((ns4) || (ie4)) {
		tooltipObj.left = x;
		tooltipObj.top = y;
	}
	else if (ns6) {
		tooltipObj.style.left = x + "px";
		tooltipObj.style.top = y + "px";
	}
}

// Define the "layerShow" function.
function layerShow() {
	if (ns4) {
		tooltipObj.visibility = "show";
	}
	else if (ie4) {
		tooltipObj.visibility = "visible";
	}
	else if (ns6) {
		tooltipObj.style.visibility = "visible";
	}
}

// Define the "layerHide" function.
function layerHide() {
	if (ns4) {
		tooltipObj.visibility = "hide";
	}
	else if (ie4) {
		tooltipObj.visibility = "hidden";
	}
	else if (ns6) {
		tooltipObj.style.visibility = "hidden";
	}
	self.status = "";
}

// Define the "layerWrite" function.
function layerWrite(text) {

	// Empty the "layerhtml" variable.
	layerhtml = '';

	// Define the tooltipLayer's html. (part 1)

	//  layerhtml += ' <table border="0" cellspacing="0" cellpadding="0" width="200"><tr><td valign="bottom"><img src="corner_top.gif" width="3" height="13"></td><td>';

	layerhtml += ' <table border="0" cellspacing="0" cellpadding="1" width="200"><tr bgcolor="#0f3a68"><td><table border="0" cellspacing="0" cellpadding="0" bgcolor="#f6f6f6"><tr><td colspan="3"><img src="images/clear_pixel.gif" width="1" height="5"></td></tr><tr><td width="5"><img src="images/clear_pixel.gif" width="5" height="1"></td><td class="list">';


	// Place the tooltipLayer's content text. ("text" variable)
	layerhtml += '' + text + '';
	// layerhtml += '' + x + '';
	// layerhtml += '' + y + '';

	// Define the tooltipLayer's html. (part 2)
	layerhtml += '<br><img src="images/clear_pixel.gif" width="195" height="1"></td><td width="5"><img src="images/clear_pixel.gif" width="5" height="1"></td></tr><tr><td colspan="3"><img src="images/clear_pixel.gif" width="1" height="5"></td></tr></table></td></tr></table>';

	// layerhtml += '</td></tr><tr align="left"><td colspan="2"><img src="corner_bottom.gif" width="15" height="3"></td></tr></table>';



	// Add a linebreak to the "layerhtml" variable.
	layerhtml += '\n';

	// Apply defined html into tooltipLayer.
	if (ns4) {
		var layer = self.document.tooltipLayer.document
		layer.write(layerhtml)
		layer.close()
	}
	else if (ie4) {
		self.document.all["tooltipLayer"].innerHTML = layerhtml
	}
	else if (ns6) {
		layer = self.document.createRange();
		layer.setStartBefore(tooltipObj);
		domfrag = layer.createContextualFragment(layerhtml);
		while (tooltipObj.hasChildNodes()) {
			tooltipObj.removeChild(tooltipObj.lastChild);
		}
		tooltipObj.appendChild(domfrag);
	}
}
