function showToolTip (tag)
{
	var toolTip = document.getElementById('tooltip');
	if (!toolTip || !tag) {
		return;
	}

	toolTip.innerHTML     = tag.innerHTML;
	toolTip.style.display = 'block';

	if ( toolTip.clientWidth < tag.clientWidth ) {
		toolTip.style.display = 'none';
		return;
	}		

	ttTop  = -2;
	ttLeft = -2;
	var parent = tag;
	while ( parent.offsetParent != null ) {
		ttTop  += parent.offsetTop;
		ttLeft += parent.offsetLeft;
		parent  = parent.offsetParent;
	}
	if ( ttLeft + toolTip.clientWidth > document.body.clientWidth - 5 ) {
		ttLeft -= toolTip.clientWidth;
	}
	toolTip.style.top  = ttTop + 'px';
	toolTip.style.left = ttLeft + 'px';
}


function initToolTip ()
{
	var toolTip = document.createElement('div');
	toolTip.id = 'tooltip';
	document.body.appendChild(toolTip);

	toolTip.onmouseout  = function () { this.style.display = 'none'; }
	toolTip.onmousemove = function () { this.style.display = 'block'; }
}

addEvent (window, 'load', initToolTip);
