var ie = document.all ? 1 : 0
var ns = document.layers ? 1 : 0
var toolTipPosition;

if(ns){doc = "document."; sty = ""}
if(ie){doc = "document.all."; sty = ".style"}

var initialize = 0
var Ex, Ey, topColor, subColor, ContentInfo

if(ie)
{
	Ex = "event.x"
	Ey = "event.y"

	topColor = "#FFFFD0"	
	subColor = "#FFFFEE"
}

if(ns)
{
	Ex = "e.pageX"
	Ey = "e.pageY"
	window.captureEvents(Event.MOUSEMOVE)
	window.onmousemove=overhere

	topColor = "#FFFFAA"
	subColor = "#FFFFCC"
}

// Find the center of the screen
var xMax;
var yMax;

if (ie)
{
	xMax = screen.width;
	yMax = screen.height;
}
else
{
	if (ns)
	{
		xMax = window.outerWidth;
		yMax = window.outerHeight;
	}
	else
	{
		xMax = 640;
		yMax = 480;
	}
}	

// The placement of tooltips is done by giving the coordinates of the
// top left corner.  We don't want that corner to be in the center of the
// screen, so we shift it left and up by half the size of the tooltip.  
// This places the center of the popup at the center of the screen.

// The popup width (180 pixels) is set in the EnterContent function.
var xOffset = (xMax - 180)/2, yOffset = (yMax)/2;			

// Positions the tooltip on the screen.  Uses xOffset from above.
function MoveToolTip(layerName, FromTop, FromLeft, e)
{

	if(ie)
	{eval(doc + layerName + sty + ".top = "  + (eval(FromTop) + document.body.scrollTop))}

	if(ns){eval(doc + layerName + sty + ".top = "  +  eval(FromTop))}
	
	// Original code to position tooltip horizontally on screen
    if( toolTipPosition == "left" )
    {
	   eval(doc + layerName + sty + ".left = " + (eval(FromLeft) - 230))
	} else {
	   eval(doc + layerName + sty + ".left = " + (eval(FromLeft) + 15))
 	}
	
	// New code which centers the code horizontally on screen instead
	//eval(doc + layerName + sty + ".left = " + xOffset)
}

function ReplaceContent(layerName)
{
	if(ie){document.all[layerName].innerHTML = ContentInfo}

	if(ns)
	{
		with(document.layers[layerName].document) 
		{ 
			open(); 
			write(ContentInfo); 
			close(); 
		}
	}
}

function Activate(){initialize=1}

function deActivate(){initialize=0}

function overhere(e)
{
	if(eval(doc+"ToolTip != null"))
	{
		if(initialize)
		{
		
			MoveToolTip("ToolTip", Ey, Ex, e)
			eval(doc + "ToolTip" + sty + ".visibility = 'visible'")
		}
		else
		{
			MoveToolTip("ToolTip", 0, 0)
			eval(doc + "ToolTip" + sty + ".visibility = 'hidden'")
		}
	}
}

function EnterContent(layerName, TTitle, TContent, position)
{
     	toolTipPosition = position;
	// Increased the width to 224 to fit the Contact Info information - Andrea N.
	ContentInfo =
				  '<table border="0" width="224" cellspacing="0" cellpadding="0">'+
					'<tr><td width="100%" bgcolor="#000000">'+				
					'<table border="0" width="100%" cellspacing="1" cellpadding="0">'+
					
					// The following lines are commented out because the title is not wanted to be seen.
					// To enable a title to the tooltip uncomment the lines.
						'<tr><td width="100%" height="" bgcolor='+topColor+'>'+
						'<table border="0" width="90%" cellspacing="0" cellpadding="0" align="center">'+
							'<tr><td width="100%">'+
							'<font class="tooltiptitle">&nbsp;'+TTitle+'</font>'+
							'</td></tr>'+
						'</table>'+
						'</td></tr>'+
					// end of commented lines
						
						'<tr><td width="100%" bgcolor='+subColor+'>'+
						'<table border="0" width="90%" cellpadding="0" cellspacing="1" align="center">'+
							'<tr><td width="100%">'+
							'<font class="tooltipcontent"><b>'+TContent+'</b></font>'+
							'</td></tr>'+
						'</table>'+
						'</td></tr>'+
					'</table>'+
					'</td></tr>'+
				'</table>';
					
	ReplaceContent(layerName)
}