// JavaScript Document
// AIDE VOLANTE (TOOLTIP)
// f.bruel 2003 (inspired by a Macromedia Dreamweaver snippet)
// v1.2 (putting out of screen instead of hiding was not a good idea after all!)
 /*
 IMPORTANT!
 
* You need to include "dom_lyrobj.js" too. Include it first.

* You must call DomInit() FrameDims() and  InitMouseMove() early in you body part.
And call again FrameDims() everytime your window is resized, 
but with a delay otherwise ie will give you the old window dimensions.
ex: 
<body onResize="javascript:setTimeout('FrameDims()',10);" >
<script>
DomInit();
FrameDims();
InitMouseMove();
</script>

*You must include this in the body of your page:
<div id="TooltipLayer" style="position:absolute; visibility: hidden; z-index: 99; overflow: visible;"></div>
<script language="JavaScript">
aidevolante = new LyrObj("TooltipLayer");
</script>

*You can then add a tooltip to any element receiving any event, ex:

<a href="#" onMouseOver="Tooltip('Because!')" onMouseOut="Tooltip()">Why?</a>

(call tooltip without arguments to dismiss it)

* Have fun (this is important, too)
*/

AVoffsetX = 0;									// default tooltip location (from mouse pointer)
AVoffsetY = 10;
AVdefaultfg = "#333333"		// tooltip text color; my taste, can be changed from your script
AVdefaultbg = "#FFCC7F"			// tooltip background color
m_x = 0;
m_y = 0; //  mouse coords, updated at each mousemove

// loc= 'up', 'upleft' or 'left'. Default: tooltip down and right from the pointer 
function Tooltip(msg, fg, bg, locx, locy)
{
	if(Tooltip.arguments.length < 1) // hide
	{
	   	aidevolante.Hide();
	}
	else // show
	{
		if(!locx) locx = AVoffsetX;
		if(!locy) locy = AVoffsetY;
		aidevolante.MoveTo(m_x + locx, m_y + locy);
		if(!fg || fg == -1) fg = AVdefaultfg;
		if(!bg || bg == -1) bg = AVdefaultbg;
		var content =
		'<table border="0" cellspacing="0" cellpadding="1" bgcolor="' + fg + '"><td>' +
		'<table border="0" cellspacing="0" cellpadding="2" bgcolor="' + bg + 
		'"><td align="center" nowrap><span class="tooltipcss"><font color="' + fg +
		'">' +msg +
		'</font></span></td></table></td></table>';
		aidevolante.WriteContent(content);
		depasse = aidevolante.Right() -frame_width;
		if( depasse > 0)
		{
			aidevolante.MoveBy(-depasse, 0);
		}
		aidevolante.Show();
	}
}// Tooltip()

function MouseMove(e)
{
  if(is.ns4||is.ns6)
  {
    m_x = e.pageX;
    m_y = e.pageY;
  }
  else
  {
    m_x = event.x + document.body.scrollLeft;
    m_y = event.y + document.body.scrollTop;
  }
  return true;
}

frame_width = 0;
frame_height = 0;

function InitMouseMove()
{
if (is.ns4 || is.ns6) document.captureEvents(Event.MOUSEMOVE);		
document.onmousemove = MouseMove;
}
