// Define global browser-detection variables
// New Globals
var NN 		 = (document.layers ? true : false);
NN = (document.layers ? true : false);
var zIdx 	 = -1;
var mouseX = 0;
var mouseY = 0;
var hideT = (NN ? 'hide' : 'hidden');
var showT = (NN ? 'show' : 'visible');
var gHelpW  = 200;
var gHelpH  = 30;
var winH = 0;
var winW= 0;
var layerH = 0;
var layerW = 0;
var totalWidth = 0;
var totalHeight = 0;
var timerId = null;
var heldObj = null;
// Set the Mouse Handler based on the browser
function setMouseHandler()
{
// alert('Mouse handler being set');
NN = (document.layers ? true : false);
	if (NN)
	{
		window.captureEvents(Event.MOUSEMOVE);
		window.onmousemove = grabXY;
	}
	else
	{ 
		document.onmousemove = grabXY;
	}
//	alert('Mouse handler SET');
}
// -------------------------------
// Track the x/y coordinates  
// of mouse pointer arrow
function grabXY(ev)
{
NN = (document.layers ? true : false);
	if(NN)
	{
		mouseX = ev.pageX;
		mouseY = ev.pageY;
	}
	else
	{
		mouseX = event.x;
		mouseY = event.y;
	}
}
// ===========================================================================================
// Define the Class PopMsg
//
function PopMsgHW(name, sClass, h, w, src, text)
{
	this.name = name;
	this.left = 0;
	this.top = 0;
	this.h = h;
	this.w = w;
	this.sClass = sClass;
	this.text = text;
	this.zIdx = ++zIdx;
// New ********
	this.src = src
NN = (document.layers ? true : false);
	if (NN)
	{
		this.layerVal =  '<LAYER name="' + this.name + '" ';
		this.layerVal += ' VISIBILITY=hide' + ' z-Index='+this.zInx;
		this.layerVal += ' height='+this.h+' width='+this.w;
		if (this.src != '')
			{this.layerVal += ' SRC='+this.src;}
		this.layerVal += ' >'
		this.spanTag = '<SPAN class="' + this.sClass +'"' + '>' + this.text  +'</SPAN>';
		if (this.src != '')
			{
				this.layerVal += '</LAYER>';
			}
		else
		{
				this.layerVal += this.spanTag+'</LAYER>';
		}
	}
	else
	{
		this.layerVal =  '<DIV ID="' + this.name + '" NAME="' + this.name + '" CLASS="'+this.sClass+'" ';
		this.layerVal += ' STYLE="position:absolute; overflow:none; left:';
		this.layerVal += this.left + 'px; top:' + this.top + 'px; width:' + this.w + 'px; height:' + this.h + 'px;';
		this.layerVal += ' visibility:' + hideT + '; z-Index=' + this.zIdx;
		this.layerVal += '; border-left: 15px';
		this.layerVal += ';">' + this.text + '</DIV>';
	}
	document.writeln (this.layerVal);
//	alert(this.layerVal);
}
// new PopMsg;
// Define a central function to reference layers
function refLayer(name)
{
NN = (document.layers ? true : false);
	if (NN) { return document.layers[name]; }
	else { return eval('document.all.' + name + '.style'); }
}
// -------------------------
function showLayer(obj)
{
NN = (document.layers ? true : false);
	layerH = gHelpH;
	layerW = gHelpW;
//	alert('layerH='+layerH+', layerW='+layerW);
	totalWidth = mouseX + gHelpW;
	totalHeight = mouseY + gHelpH;
	totalWidth = mouseX + layerW;
	totalHeight = mouseY + layerH;
 	if (NN) 
	{
		winH = document.height;
		winW = document.width;
	}
	else
	{
		winH = document.body.clientHeight;
		winW = document.body.clientWidth;
	//	alert('totalHeight=' + totalHeight + ', totalWidth='+ totalWidth + ', winH=' + winH + ', winW=' + winW);
	}


	mouseX = (totalWidth > winW ? (winW - gHelpW - 40) : mouseX);
	mouseY = (totalHeight > winH ? (winH- gHelpH - 40) : mouseY);
//	mouseX = 10;
//	mouseY = 10;
	refLayer(obj.name).left = mouseX;
	refLayer(obj.name).top = mouseY;
	if (NN)
	{
		refLayer(obj.name).hidden = false;
	}
	else
	{
		refLayer(obj.name).visibility = showT;
	}
}
//
function showLayerAtX(obj,x)
{
	NN = (document.layers ? true : false);
	layerH = gHelpH;
//	alert('nn='+NN+', layerH='+layerH+', mouseX='+mouseX+', mouseY='+mouseY);
	totalHeight = mouseY + layerH;
 	if (NN) 
	{
		winH = document.height;
		winW = document.width;
	}
	else
	{
		winH = document.body.clientHeight;
		winW = document.body.clientWidth;
	//	alert('totalHeight=' + totalHeight + ', totalWidth='+ totalWidth + ', winH=' + winH + ', winW=' + winW);
	}
	mouseY = (totalHeight > winH ? (winH- gHelpH - 40) : mouseY);
	refLayer(obj.name).left = x;
	refLayer(obj.name).top = mouseY;
//	alert('mouseY='+mouseY);
	if (NN)
	{
		refLayer(obj.name).hidden = false;
	}
	else
	{
		refLayer(obj.name).visibility = showT;
	}
}
//
function showLayerAt(obj,x,y)
{
NN = (document.layers ? true : false);
	refLayer(obj.name).left = x;
	refLayer(obj.name).top = y;
	if (NN)
	{
		refLayer(obj.name).hidden = false;
	}
	else
	{
		refLayer(obj.name).visibility = showT;
	}
}
// --------------------------------------------------------
function hideLayer(obj)
{
NN = (document.layers ? true : false);
	if (NN)
	{
		refLayer(obj.name).hidden=true;
	}
	else
	{
		refLayer(obj.name).visibility = hideT;
	}
}
function delayHideLayer(obj, time)
{
	heldObj = obj;
	timerId = setTimeout('delayFired()',time*1000);
}
function delayFired()
{
	hideLayer(heldObj);
}
// ========================================================
function handleResize()
{
	location.reload();
	return false;
}
/*
NN = (document.layers ? true : false);
	if (NN)
	{
		window.captureEvents(Event.RESIZE);
		window.onresize = handleResize;
	}
*/
self.focus();
setMouseHandler();    // Listen for Mouse Movements
