//glossary.js
//written by Marcin Depinski
//depinski@usc.edu
//Copyright 1999
//feel free to use this code but leave my name in it

function Glossary(array_def)
{
	this.mouseX = 10; 
	this.mouseY = 10; 
	this.defins = array_def;
	this.length = array_def.length;
	this.textcolor = "#000000";
	this.bgcolor = "#ffffcc";
	this.width = "220";
	this.height = "auto";
	this.font = "Arial, Geneva, Helvetica, Verdana";
	this.size = "10pt";
	
	this.current_def = "def0";

	this.showBubble = _showBubble;
	this.build = _build;

	if(navigator.appName == "Netscape")
	{
   		document.captureEvents(Event.MOUSEMOVE|Event.MOUSEUP);
    	document.onmousemove=_mousePos;
		document.onmouseup=_hideAll;
	} 
	else if(navigator.appName != "Netscape")
	{
  		document.onmousemove = _mousePos;
		document.onmouseup = _hideAll;
	}
	return this;
}

function _build()
{
	div = '<div id="empty" style="position:absolute; left:1px; top:1px; width:1px; height:1px; z-order:1; visibility:hidden;">&nbsp;</div>';
	for(i=0;i<this.length;i++)
	{
		div += '<div id="def' + i + '" style="position:absolute; visibility:hidden; font-size:' + this.size + '; font-family:' + this.font + '; color:' + this.textcolor + '; background-color:' + this.bgcolor + '; border-style:outset; border-width:1px; height:' + this.height + '; width:' + this.width + '; left:2px; top:7px; padding-left:6px; layer-background-color:' + this.bgcolor + '; z-order:' + (2 + i) + '; text-align: left;">' + this.defins[i] + '<p align="right"><a href="../../shared/glossary/glossary.html" style="font-size: 9pt; font-style: italic; text-align: right">Master Glossary</a></p></div>' + "\n";
	}
	document.open();
	document.writeln(div);
	document.close();
}

function _mousePos(e)
{
	if(document.layers)
	{
		event = e;
		g.mouseX = e.x;
		g.mouseY = e.y;
	//	window.status="mouseX="+ g.mouseX + "  mouseY=" + g.mouseY;
	}
	else if(document.all)
	{
		g.mouseX = event.x;
		g.mouseY = event.y;
	//	window.status="mouseX="+ g.mouseX + "  mouseY=" + g.mouseY + "  clientX=" + event.clientX + "  clientY=" + event.clientY + "  screenX="+ event.screenX +"  screenY=" + event.screenY + "  docX=" + document.body.scrollLeft + "  docY=" + document.body.scrollTop;
	}
	return true;
}

function _showBubble(l_name)
{
	this.current_def = l_name;
	if(document.layers)
	{
		the_layer = eval("document.layers[\'" + l_name + "\']");
		the_layer.visibility = "show";
		the_layer.x = this.mouseX;
		the_layer.y = this.mouseY;
	}
	else if(document.all)
	{
		var agt=navigator.userAgent.toLowerCase(); 
		is_major = parseInt(navigator.appVersion); 
	    is_ie   = (agt.indexOf("msie") != -1); 
	    is_ie3  = (is_ie && (is_major < 4)); 
	    is_ie4  = (is_ie && (is_major == 4) && (agt.indexOf("msie 5.0")==-1) ); 
	    is_ie4up  = (is_ie  && (is_major >= 4)); 
	    is_ie5  = (is_ie && (is_major == 4) && (agt.indexOf("msie 5.0")!=-1) ); 
	    is_ie5up  = (is_ie  && !is_ie3 && !is_ie4); 
		is_mac    = (agt.indexOf("mac")!=-1);
		the_layer = eval("document.all[\'" + l_name + "\'].style");
		if(is_ie5up || is_mac)
		{
			the_layer.left = this.mouseX + document.body.scrollLeft;
			the_layer.top = this.mouseY + document.body.scrollTop;
		}
		else if(is_ie4up)
		{
			the_layer.left = this.mouseX;
			the_layer.top = this.mouseY;
		}
		the_layer.visibility = "visible";
	}
}

function _hideAll(e)
{
	hideLayer(g.current_def);
	return true;	
}

function hideLayer(layer_name) // this function was written by marcin depinski
{ 
	var     bV = parseInt(navigator.appVersion);
	NS4 = (document.layers) ? 1 : 0;
	IE4 = ((document.all) && (bV >= 4)) ? 1 : 0;
	ver4 = (NS4 || IE4) ? 1 : 0;
	
	if (!ver4) return;	
	var the_layer;
  	if (NS4)
	{
		the_layer = eval("document.layers\[\'" + layer_name + "\'\]");
		the_layer.visibility = "hide";
    }
	else if(IE4)
	{
		the_layer = eval("document.all\[\'"+ layer_name + "\'\]");
		the_layer.style.visibility = "hidden";
  	}
}