
// Browser Detection
isMac = (navigator.appVersion.indexOf("Mac")!=-1) ? true : false;
NS4 = (document.layers) ? true : false;
IEmac = ((document.all)&&(isMac)) ? true : false;
IE4plus = (document.all) ? true : false;
IE4 = ((document.all)&&(navigator.appVersion.indexOf("MSIE 4.")!=-1)) ? true : false;
IE5 = ((document.all)&&(navigator.appVersion.indexOf("MSIE 5.")!=-1)) ? true : false;
IE55 = ((document.all)&&(navigator.appVersion.indexOf("MSIE 5.5")!=-1)) ? true : false;

IE6 = ((document.all)&&(navigator.appVersion.indexOf("MSIE 6.")!=-1)) ? true : false;
IE7 = ((document.all)&&(navigator.appVersion.indexOf("MSIE 7.")!=-1)) ? true : false;
IE8 = ((document.all)&&(navigator.appVersion.indexOf("MSIE 8.")!=-1)) ? true : false;
IE9 = ((document.all)&&(navigator.appVersion.indexOf("MSIE 9.")!=-1)) ? true : false;
ver4 = (NS4 || IE4plus) ? true : false;
NS6 = (!document.layers) && (navigator.userAgent.indexOf('Firefox')!=-1)?true:false;

IE5plus = IE5 || IE6 || IE7 || IE8 || IE9;
IE55plus = IE55 || IE6 || IE7  || IE8 || IE9;
IEMajor = 0;

// IE55plus used in login.pl - changed 8/8/2011 to let any IE pass
IE55plus = IE4plus;

if (IE4plus) {
	var start = navigator.appVersion.indexOf("MSIE");
	var end = navigator.appVersion.indexOf(".",start);
	IEMajor = parseInt(navigator.appVersion.substring(start+5,end));
	IE5plus = (IEMajor>=5) ? true : false;
}

// Make an object visible
function showObject(obj) 
{
        if (NS4) obj.visibility = "show";
        else if (IE4plus||NS6) obj.visibility = "visible";
}

// Hides an object
function hideObject(obj) 
{
        if (NS4) obj.visibility = "hide";
        else if (IE4plus||NS6) obj.visibility = "hidden";
}

// Move a layer
function moveTo(obj,xL,yL) 
{
        obj.left = xL;
        obj.top = yL;
}


//
// MouseTip Methods
//

function MouseTip_ShowNew()
{
	this.WriteLayer();
	this.Show();
}

function MouseTip_Hide()
{
	if ( IE4plus || NS4 || NS6  ) 
	{
		this.snow = 0;
		hideObject(this.over);
	}
}

function MouseTip_Show() 
{
	if ( IE4plus || NS4 || NS6 ) 
	{
		if (this.snow == 0) 	
		{
			if (this.dir == 2) 
			{ // Center
				moveTo(this.over,this.x+MouseTip.offsetX-(MouseTip.width/4),this.y+MouseTip.offsetY);
			}
			if (this.dir == 1) 
			{ // Right
				moveTo(this.over,this.x+MouseTip.offsetX,this.y+MouseTip.offsetY);
			}
			if (this.dir == 0) 
			{ // Left
				moveTo(this.over,this.x-MouseTip.offsetX-MouseTip.width,this.y+MouseTip.offsetY);
			}
			showObject(this.over);
			this.snow = 1;
		}
	}
}


// Writes to a layer
function MouseTip_WriteLayer() 
{
        if (NS4) 
        {
                var lyr = eval(MouseTip.divPath).document;
                lyr.write(this.txt);
                lyr.close();
        }
        else if (IE4plus) 
			document.all["overDiv"].innerHTML = this.txt;
		else if (NS6)
		{
			var lyr = document.getElementById("overDiv");
			lyr.innerHTML = this.txt;
		}
			
}

function MouseTip_AddTip(type,tipText)
{
	var tip = new Object();
	tip.type = type;
	tip.text = tipText;
	MouseTip.tips[MouseTip.tips.length] = tip;
}

function MouseTip_GetTip(type)
{
	var tip = null;
	
	for (i=0; i < MouseTip.tips.length; i++)
	{
		if (MouseTip.tips[i].type==type)
		{
			tip = MouseTip.tips[i];
			break;
		}
	}
	return tip;
}

function MouseTip(type,dir,x,y,xABS,yABS)
{
var orgy=y;
	var tip = MouseTip.GetTip(type);
	var org_txt_len=tip.text.length;
	var txt_len=org_txt_len / 2.2;

	//move y up 200 by for every 250 length
	if (yABS > (YRes/2) )	{		// if half of Y resolution	
		y = y - 120 - Math.ceil(txt_len);
	}
	// if left move over because of NOWRAP
	if (dir == 0)
		x = x - 50;
	this.x = x;
	this.y = y;
	this.snow = 0;
	this.dir = dir;
	this.over = null;

	this.ShowNew = MouseTip_ShowNew;
	this.Hide = MouseTip_Hide;
	this.Show = MouseTip_Show;
	this.WriteLayer = MouseTip_WriteLayer;

	if ( IE4plus || NS4 || NS6 ) 
	{
		if (NS4) this.over = eval(MouseTip.divPath);
		if (IE4plus) this.over = document.all["overDiv"].style;
		if (NS6) this.over = document.getElementById("overDiv").style;
	}

		
	this.txt = '<TABLE WIDTH=' + MouseTip.width + ' BORDER=0 CELLPADDING=' + MouseTip.borderWidth +
		' CELLSPACING=0 BGCOLOR="' + MouseTip.borderColor + '"><TR><TD><TABLE HEIGHT=' + MouseTip.height + ' WIDTH=100% BORDER=0 CELLPADDING=2 CELLSPACING=0 BGCOLOR="' + 
		MouseTip.bgColor + '"><TR><TD valign=top NOWRAP=NOWRAP><font size="-1">' + tip.text + '</font></TD></TR></TABLE></TD></TR></TABLE>';
	
}


MouseTip.current = null;
MouseTip.tips = new Array();
MouseTip.bgColor = "#FFFFE0";
MouseTip.borderColor = "#42316B";
MouseTip.width = 250;
MouseTip.borderWidth = 1;
MouseTip.offsetX = 30;
MouseTip.offsetY = 30;
MouseTip.divPath = "document.overDiv";

MouseTip.AddTip = MouseTip_AddTip;
MouseTip.GetTip = MouseTip_GetTip;

function ShowMouseTip(obj,e,type,dir)
{
	if ( IE4plus || NS4 || NS6 ) 
	{
		var x = 0;
		var y = 0;
		var xABS = 0;
		var yABS = 0;
		if (NS4 || NS6) {x=e.pageX; y=e.pageY;}
		if (IE4plus) {x=e.clientX+document.body.scrollLeft; y=e.clientY+document.body.scrollTop;}
		if (IE4plus) {xABS=e.clientX; yABS=e.clientY;}	// don't build in scroll, want absolute
		if (x < MouseTip.width + 150)
			dir = 1;	//put right
		else
			dir = 0;

		MouseTip.current = new MouseTip(type,dir,x,y,xABS,yABS);
		MouseTip.current.ShowNew();
// comment out for now - interferes with menus
//		MouseTip_attachListener()
	}
}

function HideMouseTip()
{
	if ( IE4plus || NS4 || NS6 ) 
	{
		if (MouseTip.current)
			MouseTip.current.Hide();
	}
}

function MouseTip_attachListener() {
	if (document.layers) {
		document.captureEvents(Event.MOUSEUP);
	}
	document.onmouseup = HideMouseTip; 
}



