//------- toolTip params ------------------------------------------

var Xoffset      =    5;		// X off set from cursor, 0 or greater
var Yoffset      =    5;		// Y off set from cursor, 0 or greater
var delayA       =    0;		// delay in milli seconds before toolTip appears
var delayD       =    0;		// delay in milli seconds before toolTip disappears (only works if move is 0)
var move         =    0;		// moves toolTip with mouse, 0 or 1

// this is the html that is displayed in the toolTip
var tipdisplay   =    "<TABLE CELLSPACING=1 CELLPADDING=5 BGCOLOR=D5D5D5>";
    tipdisplay  +=    "<TR>";
    tipdisplay  +=    "    <TD NOWRAP BGCOLOR=F5F5F5><b> + title + </b></TD>";
    tipdisplay  +=    "</TR>";
    tipdisplay  +=    "<TR>";
    tipdisplay  +=    "    <TD WRAP BGCOLOR=FFFFFF> + content + </TD>";
    tipdisplay  +=    "</TR>";
    tipdisplay  +=    "</TABLE>";

//------- toolTip params ------------------------------------------

var isNS4=document.layers?true:false;
var isIE=document.all?true:false;
var isNS6=!isIE&&document.getElementById?true:false;
var old=!isNS4&&!isNS6&&!isIE;

var note, cursor, size, delayappear, delaydis;
var XoffsetAdjusted = Xoffset;
var YoffsetAdjusted = Yoffset;

function init()
{
	if(isNS4)
	{
		note=document.info;
		cursor=document.cursor;
		size=document.size;
		
		document.captureEvents(Event.MOUSEMOVE); 
	}
	if(isNS6)
	{
		note=document.getElementById('info');
		cursor=document.getElementById('cursor');
		size=document.getElementById('size');
		
		document.addEventListener("mousemove", moveTip, true);
	}
	if(isIE)
	{
		note=document.all.info;
		cursor=document.all.cursor;
		size=document.all.size;
		
		document.onmousemove=moveTip;
	}
}

function displayTip(_title,_content)
{
	var content = tipdisplay.replace(" + title + ", _title);
	content = content.replace(" + content + ", _content);
	
	window.clearTimeout(delaydis);
	note.style.display="none";

	if(isNS4)
	{
		note.document.open();
		note.document.write(content);
		note.document.close();		
		delayappear = window.setTimeout('note.style.display=""',delayA);
	}
	else if(isNS6)
	{
		XoffsetAdjusted = Xoffset;
		YoffsetAdjusted = Yoffset;

		size.innerHTML=content;

		if ((parseInt(cursor.style.left) + size.offsetWidth) + Xoffset > (window.innerWidth + document.body.scrollLeft))
		{
			XoffsetAdjusted = (size.offsetWidth + Xoffset) - ((size.offsetWidth + Xoffset) * 2)
		}
		else if ((parseInt(cursor.style.left) + size.offsetWidth) + Xoffset < 0)
		{
			XoffsetAdjusted = Xoffset + size.offsetWidth;
		}
		
		if ((parseInt(cursor.style.top) + size.offsetHeight) + Yoffset > (window.innerHeight + document.body.scrollTop))
		{
			YoffsetAdjusted = (size.offsetHeight + Yoffset) - ((size.offsetHeight + Yoffset) * 2)
		}
		else if ((parseInt(cursor.style.top) + size.offsetHeight) + Yoffset < 0)
		{
			YoffsetAdjusted = Yoffset + size.offsetHeight;
		}

		if (!move)
		{
			note.style.left = parseInt(cursor.style.left) + XoffsetAdjusted;
			note.style.top = parseInt(cursor.style.top) + YoffsetAdjusted;
		}
		
		note.innerHTML=content;
		delayappear = window.setTimeout('note.style.display=""',delayA);
	}
	else if(isIE)
	{
		XoffsetAdjusted = Xoffset;
		YoffsetAdjusted = Yoffset;

		size.innerHTML=content;
		
		if ((parseInt(cursor.style.left) + size.offsetWidth) + Xoffset > (document.body.offsetWidth + document.body.scrollLeft))
		{
			XoffsetAdjusted = (size.offsetWidth + Xoffset) - ((size.offsetWidth + Xoffset) * 2)
		}
		else if ((parseInt(cursor.style.left) + size.offsetWidth) + Xoffset < 0)
		{
			XoffsetAdjusted = Xoffset + size.offsetWidth;
		}
		
		if ((parseInt(cursor.style.top) + size.offsetHeight) + Yoffset > (document.body.offsetHeight + document.body.scrollTop))
		{
			YoffsetAdjusted = (size.offsetHeight + Yoffset) - ((size.offsetHeight + Yoffset) * 2)
		}
		else if ((parseInt(cursor.style.top) + size.offsetHeight) + Yoffset < 0)
		{
			YoffsetAdjusted = Yoffset + size.offsetHeight;
		}

		if (!move)
		{
			note.style.left = parseInt(cursor.style.left) + XoffsetAdjusted;
			note.style.top = parseInt(cursor.style.top) + YoffsetAdjusted;
		}
		else
		{
			moveTip();
		}

		note.innerHTML=content;
		delayappear = window.setTimeout('note.style.display=""',delayA);		
	}
	else
	{
		alert("Your web browser is not\ncompatable with this note");
		return;
	}
}

function moveTip(e)
{
	cursor.style.left = (isNS4||isNS6)?e.pageX:event.clientX + document.body.scrollLeft;
	cursor.style.top = (isNS4||isNS6)?e.pageY:event.clientY + document.body.scrollTop;

	if (move)
	{
		note.style.left = parseInt(cursor.style.left) + XoffsetAdjusted;
		note.style.top = parseInt(cursor.style.top) + YoffsetAdjusted;
	}
}

function removeTip()
{
	if(!old)
	{
		if (move){ note.style.display="none"; }
		else{ delaydis = window.setTimeout('note.style.display="none"',delayD); }
		
		window.clearTimeout(delayappear);
	}
}

document.write("<div id=\"info\" style=\"position:absolute; display:none; z-index:200;\"></div>");
document.write("<div id=\"cursor\" style=\"position:absolute;\"></div>");
document.write("<div id=\"size\" style=\"position:absolute; left:-900; to:-900\"></div>");
onload = init;