var ns4 = document.layers;
var ns6 = document.getElementById && !document.all;
var ie4 = document.all;
offsetX = -5;
offsetY = 20;
var toolTipSTYLE = "";

function initToolTips()
{
	if (ns4 || ns6 || ie4 || ie55)
	{
		if (ns4)
		{
			toolTipSTYLE = document.toolTipLayer;
		}
		else if (ns6)
		{
			toolTipSTYLE = document.getElementById("toolTipLayer").style;
		}
		else if (ie4 || ie55)
		{
			toolTipSTYLE = document.all.toolTipLayer.style;
		}
		
		if (ns4)
		{
			document.captureEvents(Event.MOUSEMOVE);
		}
		else
		{
			toolTipSTYLE.visibility = "visible";
			toolTipSTYLE.display	= "none";
		}
    
		document.onmousemove = moveToMouseLoc;
	}

	//NaviHelperLeft = findPosX (document.getElementById('NavigationControl'));
}

function toolTipMove()
{
	if (toolTipMove.arguments.length < 1)
	{
	document.onmousemove = "";
	}
	else
	{
	document.onmousemove = moveToMouseLoc;
	}
}

function toolTip (msg, width, bg)
{
	fg = "#000000";
	//bg = "#FFFFCC";

		if (!bg)
		{
			bg = "#FFFFCC";
		}
		if (bg == 0)
		{
			bg = "#FFFFCC";
		}
	
	if (toolTip.arguments.length < 1) // hide
	{
		if (ns4)
		{
			toolTipSTYLE.visibility = "hidden";
		}
		else 
		{
			toolTipSTYLE.display = "none";
		}
	}
	else // show
	{
		/*if (!fg)
		{
			fg = "#000000";
		}
    
		if (!bg)
		{
			bg = "#FFFFCC";
		}*/
		
		if (!width)
		{
			width = 170;
		}
		if (width == 0)
		{
			width = null;
		}

		var content =
		'<table width="' + width + '" border="0" cellspacing="1" cellpadding="0" bgcolor="' + fg + '"><td>' +
		'<table width="' + width + '" height="30" border="0" cellspacing="0" cellpadding="5" bgcolor="' + bg + 
		'"><td align="left"><span class="tooltip">' + msg +
		'&nbsp\;</span></td></table></td></table>';

		if (ns4)
		{
			toolTipSTYLE.document.write(content);
			toolTipSTYLE.document.close();
			toolTipSTYLE.visibility = "visible";
		}
	    else if (ns6)
		{
			document.getElementById("toolTipLayer").innerHTML = content;
			toolTipSTYLE.display = 'block';
		}
		else if (ie4 || ie55)
		{
			document.all("toolTipLayer").innerHTML = content;
			toolTipSTYLE.display = 'block';
		}
		else
		{
			document.all("toolTipLayer").innerHTML = content;
			toolTipSTYLE.display = 'block';
		}
	}
}

function moveToMouseLoc(e)
{
	if (ns4 || ns6)
	{
		x = e.pageX;

		if ((x + 220) > window.screen.availWidth)
		{
			x = window.screen.availWidth - 210;
		}

		y = e.pageY;
	}
	else
	{
		x = event.x + document.body.scrollLeft;

		if ((x + 220) > window.screen.availWidth)
		{
			x = window.screen.availWidth - 210;
		}

		y = event.y + document.body.scrollTop;
	}

	toolTipSTYLE.left = x + offsetX;
	toolTipSTYLE.top  = y + offsetY;


	//
	// get left, top, width, height for active dropdown
	//
	/*if (ActiveDropDown)
	{
		var aleft   = ActiveDropDown.offsetLeft;
		var awidth  = aleft + ActiveDropDown.offsetWidth;

		if (ns4 || ns6)
		{
			var atop    = ActiveDropDown.offsetTop - 20; // 18
			var aheight = atop + ActiveDropDown.offsetHeight + 20;

			x = e.pageX;
			y = e.pageY;
		}
		else
		{
			var atop    = ActiveDropDown.offsetTop - 18; // 16
			var aheight = atop + ActiveDropDown.offsetHeight + 18;
		
			x = event.x + document.body.scrollLeft;
			y = event.y + document.body.scrollTop;
		}
		
		//
		// Check if the mouse was moved outside the bound-area
		//
		if (!(x >= aleft && x <= awidth && y >= atop && y <= aheight) && !(x >= NaviHelperLeft && x >= (aleft - 25) && x <= awidth && y >= atop && y <= (atop + 18)))
		{
			ActiveDropDown.style.display = "none";

			//
			// Get id for the main navi item
			//
			id = ActiveDropDown.id.replace ("Div", "");

			//
			// Set background, color
			//
			if (document.getElementById(id).style.fontWeight == "normal" || document.getElementById(id).style.fontWeight == "")
			{
				document.getElementById(id).style.backgroundColor = "#7B7B7B";
				document.getElementById(id).style.color			  = "#CECECE";
			}

			//
			// Show form elements / flash
			//
			if (DropDownExceptions != null)
			{
				for (i = 0; i < DropDownExceptions.length; i++)
				{
					document.getElementById(DropDownExceptions[i]).style.visibility = "visible";
				}
			}
		}
	}*/

	return true;
}
