/* This notice must be untouched at all times.

tooltip.js    v. 3.13
The latest version is available at http://www.walterzorn.de/

Copyright (c) 2002 Walter Zorn. All rights reserved.
Created 1. 12. 2002 by Walter Zorn <walter@kreuzotter.de>
Last modified: 10. 2. 2003

A cross-browser tooltip script that works even in Opera 5 and 6,
as well as in NN 4, Gecko-Browsers, IE4+, Opera 7 and Konqueror,
and doesn't require onmouseouts.
Appearance of tooltips may be individually configured
via commands within the onmouseovers.

This software is provided "as is", without a warranty of any kind.
*/





////////////////  Global Tooltip Configuration  /////////////////////
var ttBgColor      = '#e6ecff';
var ttBgImg        = '';           // path to background image;
var ttBorderColor  = '#000099';
var ttBorderWidth  = 1;
var ttDelay        = 200;            // time span until tooltip shows up [milliseconds]
var ttFontColor    = '#000066';
var ttFontFace     = 'arial,helvetica,sans-serif';
var ttFontSize     = '11px';
var ttFontWeight   = 'normal';     // alternative is 'bold';
var ttOffsetX      = 8;            // horizontal offset of left-top corner from mousepointer
var ttOffsetY      = 19;           // vertical offset                   "
var ttPadding      = 5;            // spacing between border and content
var ttTitleColor = '#ffffff';    // color of caption text
var ttWidth        = 300;
/////////////////////////////////////////////////////////////////////





//////////////  Tags with tooltip functionality  ////////////////////
// List may be extended or shortened:
var tt_tags = new Array('a','area','b','big','caption','center','code','dd','div','dl','dt','em','h1','h2','h3','h4','h5','h6','i','img','input','li','map','ol','p','pre','s','small','span','strike','strong','sub','sup','table','td','th','tr','tt','u','var','ul','layer');
/////////////////////////////////////////////////////////////////////





var tt_obj,                         // current tooltip
tt_objWidth = 0, tt_objHeight = 0,  // width and height of current tooltip
tt_offsetX = 0, tt_offsetY = 0,
xlim = 0, ylim = 0,                 // right and bottom borders of visible client area
tt_sticky = false,                  // current tooltip sticky?
tt_wait = false,
tt_vis = false,                     // tooltip visibility flag
tt_dwn = false,                     // true if tooltip below mousepointer
tt_u = 'undefined';




var tt_db = (document.compatMode && document.compatMode != 'BackCompat')? document.documentElement : document.body? document.body : null,
tt_n = navigator.userAgent.toLowerCase();


// Browser flags
var tt_op = (window.opera && document.getElementById)? true : false,
tt_op6 = tt_op && parseInt(tt_n.substring(tt_n.indexOf("opera")+6))<7,
tt_ie = tt_n.indexOf('msie') != -1 &&
	document.all &&
	tt_db &&
	!tt_op,
tt_n4 = navigator.appName + parseInt(navigator.appVersion) == 'Netscape4' && document.layers,
tt_kqi = tt_n.indexOf('konq'),
tt_kq = tt_kqi > -1,
tt_kqnew = tt_kq &&
	parseInt(tt_n.substring(tt_kqi + (5<<1))) > 2 &&
	tt_n.substring(tt_kqi + (5<<1), tt_kqi + (6<<1|1)) != '3.0',
tt_n6 = (!tt_op && !tt_kq && document.defaultView && typeof document.defaultView.getComputedStyle != "undefined");


tt_n = '';




function tt_Int(x)
{
	var y;
	return isNaN(y = parseInt(x))? 0 : y;
}




// Substitute for String.replace.
// Doesn't require regExp as to-be-replaced arg
function wzReplace(x, y)
{
	var ret = '',
	str = this,
	xI;
	while ((xI = str.indexOf(x)) != -1)
	{
		ret += str.substring(0, xI) + y;
		str = str.substring(xI + x.length);
	}
	return ret+str;
}
String.prototype.wzReplace = wzReplace;




function tt_n4Tags(tagtyp, d, y)
{
	d = d || document;
	y = y || new Array();
	var x = (tagtyp=='a')? d.links : d.layers;
	for (var z = 0; z<x.length; z++) y[y.length] = x[z];
	for (var z = 0; z<d.layers.length; z++)
	{
		y = tt_n4Tags(tagtyp, d.layers[z].document, y);
	}
	return y;
}




function tt_Htm(tt, id, txt)
{
	var ttw   = (typeof tt.T_WIDTH != tt_u)? tt.T_WIDTH  : ttWidth,
	ttpadd    = (typeof tt.T_PADDING != tt_u)? tt.T_PADDING : ttPadding,
	ttbc      = (typeof tt.T_BORDERCOLOR != tt_u)? tt.T_BORDERCOLOR : ttBorderColor,
	ttbw      = (typeof tt.T_BORDERWIDTH != tt_u)? tt.T_BORDERWIDTH : ttBorderWidth,
	ttbgc     = (typeof tt.T_BGCOLOR != tt_u)? tt.T_BGCOLOR : ttBgColor,
	ttbgimg   = (typeof tt.T_BGIMG != tt_u)? tt.T_BGIMG : ttBgImg,
	ttff      = (typeof tt.T_FONTFACE != tt_u)? tt.T_FONTFACE : ttFontFace,
	ttfc      = (typeof tt.T_FONTCOLOR != tt_u)? tt.T_FONTCOLOR : ttFontColor,
	ttfsz     = (typeof tt.T_FONTSIZE != tt_u)? tt.T_FONTSIZE : ttFontSize,
	ttfwght   = (typeof tt.T_FONTWEIGHT != tt_u)? tt.T_FONTWEIGHT : ttFontWeight;
	tttit     = (typeof tt.T_TITLE != tt_u)? tt.T_TITLE : '';
	tttitc    = (typeof tt.T_TITLECOLOR != tt_u)? tt.T_TITLECOLOR : ttTitleColor;
	
	if (tt_n4 && (ttfsz == '10px' || ttfsz == '11px')) ttfsz = '12px';
	
	var y = '<div id="' + id + '" style="position:absolute;z-index:'+ (2<<8);
	y += ';left:0px;top:0px;width:' + ttw + 'px;visibility:' + (tt_n4? 'hide' : 'hidden') + ';">';
	y += '<table border="0" cellpadding="0" cellspacing="0" bgcolor="' + ttbc + '" width="' + ttw + '"><tr><td>';
	y += '<table border="0" cellpadding="0" cellspacing="' + ttbw + '" width="100%">';
	if (tttit)
	{
		y += '<tr><td><font color="' + tttitc + '" face="' + ttff + '" ';
		y += 'style="color:' + tttitc + ';font-family:' + ttff + ';font-size:' + ttfsz + ';"><b>&nbsp;';
		y += tttit + '<\/b><\/font><\/td><\/tr>';
	}
	y += '<tr><td bgcolor="' + ttbgc + '"' + (ttbgimg? ' background="' + ttbgimg + '"' : '');
	y += '><table border="0" cellspacing="0" cellpadding="' + ttpadd + '" width="100%"><tr>';
	y += '<td style="padding:' + ttpadd + 'px;color:' + ttfc + ';font-family:' + ttff + ';font-size:' + ttfsz + ';font-weight:' + ttfwght + ';">';
	y += '<font color="' + ttfc + '" face="' + ttff + '">';
	if (ttfwght == 'bold') y += '<b>';
	y += txt;
	if (ttfwght == 'bold') y += '<\/b>';
	y += '<\/font><\/td><\/tr><\/table><\/td><\/tr><\/table><\/td><\/tr><\/table><\/div>\n';
	return y;
}




function tt_Init()
{
	if (!(tt_op || tt_n4 || tt_n6 || tt_ie || tt_kq)) return;
	
	var htm = tt_n4? '<div style="position:absolute;"><\/div>' : '',
	tags,
	over,
	esc = 'return escape(';
	for (var i = 0; i<tt_tags.length; i++)
	{
		tags = tt_ie? (document.all.tags(tt_tags[i]) || 1)
			: document.getElementsByTagName? (document.getElementsByTagName(tt_tags[i]) || 1)
			: (!tt_n4 && tt_tags[i]=='a')? document.links
			: 1;
		if (tt_n4 && (tt_tags[i] == 'a' || tt_tags[i] == 'layer')) tags = tt_n4Tags(tt_tags[i]);
		for (var j = 0; j<tags.length; j++)
		{
			if (typeof tags[j].onmouseover == 'function' && tags[j].onmouseover.toString().indexOf(esc) != -1 || tt_n6 && (over = tags[j].getAttribute('onmouseover')) && over.indexOf(esc) != -1)
			{
				if (over) tags[j].onmouseover = new Function(over);
				var txt = unescape(tags[j].onmouseover());
				htm += tt_Htm(
					tags[j],
					'tOoLtIp'+i+''+j,
					txt.wzReplace('& lt;','&lt;').wzReplace('& gt;','&gt;').wzReplace('& amp;','&amp;')
				);

				var offx = (typeof tags[j].T_OFFSETX != tt_u)? tags[j].T_OFFSETX : ttOffsetX,
				offy = (typeof tags[j].T_OFFSETY != tt_u)? tags[j].T_OFFSETY : ttOffsetY,				
				sticky = (typeof tags[j].T_STICKY != tt_u),
				delay = (typeof tags[j].T_DELAY != tt_u)? tags[j].T_DELAY : ttDelay;
				
				tags[j].onmouseover = new Function('e',
					'tt_Show(e,'+
					'"tOoLtIp' +i+''+j+ '",'+
					offx + ','+
					offy + ','+
					sticky + ','+
					delay +
					');'
				);
				tags[j].onmouseout = tt_Hide;
			}
		}
	}
	document.write(htm);
}




function tt_EvX(e)
{
	var y = tt_Int(e.pageX || e.clientX || 0) +
		tt_Int((tt_ie || tt_kqnew)? tt_db.scrollLeft : 0) +
		tt_offsetX;
	if (y > xlim) y = xlim;	
	return y;
}




function tt_EvY(e)
{
	var y = tt_Int(e.pageY || e.clientY || 0) +
		tt_Int((tt_ie || tt_kqnew)? tt_db.scrollTop : 0);		
	if (y > ylim || !tt_dwn && y > ylim-(6<<2))
	{
		y -= (tt_objHeight + 5);
		tt_dwn = false;
	}
	else
	{
		y += tt_offsetY;
		tt_dwn = true;
	}
	return y;
}




function tt_ReleasMov()
{
	if (document.releaseEvents)	document.releaseEvents(Event.MOUSEMOVE);
	document.onmousemove = null;
}




function tt_GetDiv(id)
{
	return (
		tt_n4? (document.layers[id] || null)
		: tt_ie? (document.all[id] || null)
		: (document.getElementById(id) || null)
	);
}




function tt_GetDivWidth()
{
	return (
		tt_n4? tt_obj.clip.width
		: tt_obj.style && tt_obj.style.pixelWidth? tt_obj.style.pixelWidth
		: tt_obj.offsetWidth
	);
}




function tt_GetDivHeight()
{
	return (
		tt_n4? tt_obj.clip.height
		: tt_obj.style && tt_obj.style.pixelHeight? tt_obj.style.pixelHeight
		: tt_obj.offsetHeight
	);
}




// Compat with DragDrop Lib: Ensure z-index of tooltip to be lifted beyond toplevel dragdrop element
function tt_SetDivZindex()
{
	var i = tt_obj.style || tt_obj;
	if (window.dd && dd.zIndex)
		i.zIndex = Math.max(dd.zIndex + 1, i.zIndex);
}




function tt_SetDivPos(x, y)
{
	var i = tt_obj.style || tt_obj;
	var px = (tt_op6 || tt_n4)? '' : 'px';
	i.left = x + px;
	i.top = y + px;
}




function tt_ShowDiv()
{
	if (tt_n4) tt_obj.visibility = 'show';
	else tt_obj.style.visibility = 'visible';
	tt_vis = true;
}




function tt_HideDiv()
{
	if (tt_n4) tt_obj.visibility = 'hide';
	else tt_obj.style.visibility = 'hidden';
	tt_vis = false;
}




function tt_Show(e, id, offx, offy, sticky, delay)
{
	if (tt_obj) tt_Hide();
	if (document.onmousemove) return;  // return if mousemove currently active (for instance drag operation?)


	tt_obj = tt_GetDiv(id);			
	if (tt_obj)
	{
		tt_sticky = sticky;
		tt_objWidth = tt_GetDivWidth();
		tt_objHeight = tt_GetDivHeight();
		tt_offsetX = offx;
		tt_offsetY = offy;
		if (tt_op)
		{
			tt_offsetX -= 5<<1;
			tt_offsetY += 5<<2;
		}
	
		tt_dwn = true;
							
		xlim = tt_Int((tt_db && tt_db.clientWidth)? tt_db.clientWidth : window.innerWidth) +
			tt_Int(window.pageXOffset || (tt_db? tt_db.scrollLeft : 0) || 0) -
			tt_objWidth -
			(tt_n4? 5<<2 : 0);

		ylim = tt_Int(window.innerHeight || tt_db.clientHeight) +
			tt_Int(window.pageYOffset || (tt_db? tt_db.scrollTop : 0) || 0) -
			tt_objHeight - tt_offsetY;
			
		tt_SetDivZindex();
		e = e || window.event;
		tt_SetDivPos(tt_EvX(e), tt_EvY(e));
				
		window.tt_rdl = window.setTimeout(
			'if (tt_sticky)'+
			'{'+
				'tt_ReleasMov();'+
				'window.tt_upFunc = document.onmouseup || null;'+
				'if (document.captureEvents) document.captureEvents(Event.MOUSEUP);'+
				'document.onmouseup = new Function("window.setTimeout(\'tt_Hide();\', 10);");'+
			'}'+
			'tt_ShowDiv();',
			delay
		);

		if (document.captureEvents)	document.captureEvents(Event.MOUSEMOVE);
		document.onmousemove = tt_Move;
	}
}




var tt_area = false;
function tt_Move(e)
{
	if (!tt_obj) return;
	if (tt_n6 || tt_kq)
	{
		if (tt_wait) return;
		tt_wait = true;
		setTimeout('tt_wait = false;', 5);
	}
		
	e = e || window.event;
	tt_SetDivPos(tt_EvX(e), tt_EvY(e));
		
	if (tt_op6)
	{
		if (tt_area && e.target.tagName != 'AREA') tt_Hide();
		else if (e.target.tagName == 'AREA') tt_area = true;
	}
}




function tt_Hide()
{
	if (tt_obj)
	{
		if (window.tt_rdl) window.clearTimeout(tt_rdl);
		if (!tt_sticky || tt_sticky && !tt_vis)
		{
			tt_HideDiv();
			tt_SetDivPos(-tt_objWidth, -tt_objHeight);
			tt_obj = null;
			if (typeof window.tt_upFunc != tt_u) document.onmouseup = window.tt_upFunc;
		}
		tt_sticky = false;
		if (tt_op6 && tt_area) tt_area = false;
		tt_ReleasMov();
	}
}




tt_Init();

