// Free to use as long as this copyright notice is intact
// Made by Edward Traversa 2004 etraversa@dhtmlnirvana.com 
// http://www.dhtmlnirvana.com/


// offset positions for the tooltip
// set these to where you want the tooltip to be placed in relation to the element

var placeleft = 40;
var placetop  = 30;

function titleManager()
{
    var args = titleManager.arguments;
    switch ( args[ 0 ] )
    {
	case "make_div":
    thediv = document.getElementById('tooltipLYR');
	thediv.onmouseover = setBlock;
    thediv.onmouseout = setNone;
    break;
	case "find_pos":
	x =  args[ 1 ].parentNode.offsetLeft;
	y =  args[ 1 ].parentNode.offsetTop; 
	return {x:x,y:y};
    break;
	case "attach_events":
    if ( args[ 1 ].addEventListener )
    {
	args[ 1 ].addEventListener( args[ 2 ], args[ 3 ], args[ 4 ] );
	return true;
    }
    else  ( args[ 1 ].attachEvent )
    {
	return args[ 1 ].attachEvent( "on" + args[ 2 ], args[ 3 ] );
	}
    break;
	case "detach_events":
    if (args[ 1 ].removeEventListener) 
	{
	return args[ 1 ].removeEventListener(args[ 2 ],args[ 3 ],args[ 4 ]);
	}
	else (args[ 1 ].detachEvent) 
	return args[ 1 ].detachEvent("on"+args[ 2 ],args[ 3 ]);
	break;
  }
}

function tooltipStart( obj )
{
    if (  ! obj )
    {
	obj = '*';
    }
    obj = obj.split( ',' );
    for ( var i = 0, thelength = obj.length; i < thelength; i ++ )
    {
	var gettags = document.getElementsByTagName( obj[ i ] );
	for ( var j = 0, thelength2 = gettags.length; j < thelength2; j ++ )
	{
    	var el = gettags[ j ];
		var thetitle = el.getAttribute( 'title' );
    	if (  ! thetitle  )
    	{
		continue;
    	}
    	el.setAttribute( 'snagtitle', thetitle );
		el.setAttribute( 'title', '' );
		titleManager('detach_events', el, 'mouseover', showTip, false );
		titleManager('detach_events', el, 'mouseout', setNone, false );
		titleManager('attach_events', el, 'mouseover', showTip, false );
		titleManager('attach_events', el, 'mouseout', setNone, false );
	 }
   }
}


function showTip( evt )
{
    var el = evt.currentTarget || evt.srcElement;
    var t = el.getAttribute( 'snagtitle' );
	t = el.getAttribute( 'snagtitle' );
 	titleManager('make_div');
    thediv.innerHTML=t;
    thediv.style.display = "block";
    titleManager('find_pos',el);
    thediv.style.left = x + placeleft+'px';
    thediv.style.top = y + placetop +'px';
}

function setBlock()
{
   thediv.style.display = "block";
}

function setNone()
{
    thediv.style.display = "none";
}