﻿// Detect if the browser is IE or not.
// If it is not IE, we assume that the browser is NS.
var IE = document.all?true:false

// If NS -- that is, !IE -- then set up for mouse capture
if (!IE) document.captureEvents(Event.MOUSEMOVE)

// Set-up to use getMouseXY function onMouseMove
document.onmousemove = getMouseXY;

// Temporary variables to hold mouse x-y pos.s
var tempX = 0;
var tempY = 0;

//Variables to hold the x and y scroll amounts
var scrOfX = 0;
var scrOfY = 0;


// Main function to retrieve mouse x-y pos.s
function getMouseXY(e) 
{
	// Check to see which browser type is being used
	if (IE) 
	{ 
		//Get the scroll values of x and y
		getScrollXY();
		// grab the x-y pos.s if browser is IE
		tempX = event.clientX + document.body.scrollLeft + scrOfX;
		tempY = event.clientY + document.body.scrollTop + scrOfY;
	} 
	else 
	{
		// grab the x-y pos.s if browser is NS
		tempX = e.pageX
		tempY = e.pageY
	}
	
	// catch possible negative X values in NS4. If not negative, add the offset
	if (tempX < 0)
	{
		tempX = 0;
	}
	else
	{
		//Add an offset
		tempX = tempX + -55;
	}
	// catch possible negative Y values in NS4. If not negative, add the offset
	if (tempY < 0)
	{
		tempY = 0;
	}
	else
	{
		//Add offset
		tempY = tempY + 20;
	}
	
	// show the position values in the form named Show
	// in the text fields named MouseX and MouseY
	//document.Show.MouseX.value = tempX;
	//document.Show.MouseY.value = tempY;
	
	//Set position of the messageBox
	document.getElementById("MessageBox").style.top = tempY + "px";
	document.getElementById("MessageBox").style.left = tempX + "px";
	
	//Return
	return true;
}


//A function to get the IE scrolling values!
function getScrollXY() 
{  
	scrOfX = 0;
	scrOfY = 0;
	
  if ( typeof( window.pageYOffset ) == 'number' ) 
  {
    //Netscape compliant
    scrOfY = window.pageYOffset;
    scrOfX = window.pageXOffset;
  }
  else 
  {
		if( document.body && ( document.body.scrollLeft || document.body.scrollTop ) ) 
		{
    //DOM compliant
    scrOfY = document.body.scrollTop;
    scrOfX = document.body.scrollLeft;
		} 
		else 
		{
			if( document.documentElement && ( document.documentElement.scrollLeft || document.documentElement.scrollTop ) ) 
			{
			//IE6 standards compliant mode
			scrOfY = document.documentElement.scrollTop;
			scrOfX = document.documentElement.scrollLeft;
			}
		}
	}
  //alert("X: " + scrOfX + " | Y: " + scrOfY );
  //return [ scrOfX, scrOfY ];
}

//This function sets the visibility of the Messagebox, and sets the message contents
function HelpShow(obj,msg)
{	
  //Get the x-y co-ords for the mouse pointer!
  document.onmousemove = getMouseXY;
  
	//Set contents of div
	document.getElementById("MessageBoxContents").innerHTML = msg +
	//"<p>" +
	//obj.href + 
	//"<br/>" +
	//tempX + " " + tempY +
	"";
	
	//Set div to display
	document.getElementById("MessageBox").style.display = "block";
}

//Function to hide the MessageBox
function HelpHide()
{
	//Set the MessageBox to not display
	document.getElementById('MessageBox').style.display='none';
}