startToolTip = false;
displayToolTip = false;
ToolTipID = "";

function showToolTip(ev, tooltipdiv)
	{
	
	if(ToolTipID != "")
		{
		hideToolTip();
		}
	
	/* ToolTipID = tooltipdiv; */

	document.getElementById("toolTipStage").innerHTML = document.getElementById(tooltipdiv).innerHTML;
	document.getElementById("toolTipStage").style.width = document.getElementById(tooltipdiv).style.width;

	ToolTipID = "toolTipStage";
	
	displayToolTip = true; 
	
	MsX = ev.clientX;
	MsY = ev.clientY;
	
	if(ToolTipID != "" && document.getElementById(ToolTipID).style.display != "block") 
		{
		document.getElementById(ToolTipID).style.display = "block";
		processToolTipID(MsX, MsY);
		}
	}

function showToolTipX(ev, tooltipdiv, posX)
	{
	
	if(ToolTipID != "")
		{
		hideToolTip();
		}
	
	ToolTipID = tooltipdiv; 
	displayToolTip = true; 
	
	MsX = posX;
	MsY = ev.clientY;
	
	if(ToolTipID != "" && document.getElementById(ToolTipID).style.display != "block") 
		{
		processToolTipID(MsX, MsY);
		document.getElementById(ToolTipID).style.display = "block";
		}
	}


function hideToolTip()
	{
	document.getElementById(ToolTipID).style.display = "none";
	document.getElementById(ToolTipID).style.left = "-2000px";
	displayToolTip = false; 
	ToolTipID = ""; 
	}

function processToolTipID(PosX, PosY)
	{
	ToolTipIDHeight = parseInt(document.getElementById(ToolTipID).offsetHeight, 0);
	ToolTipIDWidth = parseInt(document.getElementById(ToolTipID).offsetWidth, 0);

	// alert(ToolTipIDHeight)

	if (window.innerHeight)
		{
		WindowInnerWidth = window.innerWidth; 
		WindowInnerHeight = window.innerHeight;
		}
	else if (document.documentElement && document.documentElement.clientHeight)
		{
		WindowInnerWidth = document.documentElement.clientWidth;
		WindowInnerHeight = document.documentElement.clientHeight;
		}
	else if (document.body)
		{
		WindowInnerWidth = document.body.clientWidth; 
		WindowInnerHeight = document.body.clientHeight;
		}

	/* alert(ToolTipIDWidth + "" + ToolTipIDHeight) */
	
	/* ToolTipPosX = PosX - parseInt(ToolTipIDWidth/2, 0); */
	/* ToolTipPosY = PosY - 16 - ToolTipIDHeight;  */

	ToolTipPosX = PosX - 16 - ToolTipIDWidth;
	ToolTipPosY = PosY - 8;

	if( (ToolTipPosY + ToolTipIDHeight) > WindowInnerHeight )
		{
		if( (PosY - 5 - ToolTipIDHeight) > 0 ) 
			{ ToolTipPosY = PosY - 5 - ToolTipIDHeight; }
		}

	if( ToolTipPosY < 0 )
		{
		ToolTipPosY = PosY + 16;
		}

	if( (ToolTipPosX + ToolTipIDWidth) > WindowInnerWidth )
		{
		if ( (PosX  - ToolTipIDWidth) > 0)
			{ ToolTipPosX = PosX  - ToolTipIDWidth; }
		}

	document.getElementById(ToolTipID).style.top = ToolTipPosY + "px";
	document.getElementById(ToolTipID).style.left = ToolTipPosX + "px";
	
	}


