var ns = (navigator.userAgent.toLowerCase().indexOf('netscape') > 0)? true:false
var ie = (navigator.userAgent.toLowerCase().indexOf('msie') > 0)? true:false
var ff = (navigator.userAgent.toLowerCase().indexOf('firefox') > 0)? true:false
var currentId=null;
var vpos=new Array(15);

// Calculate the position of the drop downs depending on the 
// number of the link being hovered over
//
for(cnt=1; cnt < 25; cnt++) {
	if (ie) {
		vpos[cnt] = 268 + ( cnt * 28 );
	} else {
		// assume mozilla browsers
		vpos[cnt] = 258 + ( cnt * 31 );
	}
}


if (ns) {
	document.captureEvents(Event.MOUSEMOVE);
}
document.onmousemove = captureMousePosition;

// Global variables
xMousePos = 0; // Horizontal position of the mouse on the screen
yMousePos = 0; // Vertical position of the mouse on the screen
xMousePosMax = 0; // Width of the page
yMousePosMax = 0; // Height of the page

function captureMousePosition(e) {
    if (ns) {
        // When the page scrolls in Netscape, the event's mouse position
        // reflects the absolute position on the screen. innerHight/Width
        // is the position from the top/left of the screen that the user is
        // looking at. pageX/YOffset is the amount that the user has 
        // scrolled into the page. So the values will be in relation to
        // each other as the total offsets into the page, no matter if
        // the user has scrolled or not.
        xMousePos = e.pageX;
        yMousePos = e.pageY;
        xMousePosMax = window.innerWidth+window.pageXOffset;
        yMousePosMax = window.innerHeight+window.pageYOffset;
    } else if (ie) {
        // When the page scrolls in IE, the event's mouse position 
        // reflects the position from the top/left of the screen the 
        // user is looking at. scrollLeft/Top is the amount the user
        // has scrolled into the page. clientWidth/Height is the height/
        // width of the current page the user is looking at. So, to be
        // consistent with Netscape (above), add the scroll offsets to
        // both so we end up with an absolute value on the page, no 
        // matter if the user has scrolled or not.
        xMousePos = window.event.x+document.body.scrollLeft;
        yMousePos = window.event.y+document.body.scrollTop;
        xMousePosMax = document.body.clientWidth+document.body.scrollLeft;
        yMousePosMax = document.body.clientHeight+document.body.scrollTop;
    } else {
        // Netscape 6 behaves the same as Netscape 4 in this regard 
        xMousePos = e.pageX;
        yMousePos = e.pageY;
        xMousePosMax = window.innerWidth+window.pageXOffset;
        yMousePosMax = window.innerHeight+window.pageYOffset;
    }
}


// dim will either be "width" or "height"
//
function getWindowSize(dim) {
  var myWidth = 0, myHeight = 0;
  if( typeof( window.innerWidth ) == 'number' ) {
    //Non-IE
    myWidth = window.innerWidth;
    myHeight = window.innerHeight;
  } else if( document.documentElement &&
      ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
    //IE 6+ in 'standards compliant mode'
    myWidth = document.documentElement.clientWidth;
    myHeight = document.documentElement.clientHeight;
  } else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
    //IE 4 compatible
    myWidth = document.body.clientWidth;
    myHeight = document.body.clientHeight;
  }

  if ( dim == "width" ) {
  	return myWidth;
  } else {
  	return myHeight;
  }
}


function showMenu(id, offset) {

	linkId = 'LINK' + id;

	// ypos=(parseInt((yMousePos - 15) / 40 ) * 40) + 10;
	// defaultStatus="yMousePos " + yMousePos + " : " + ypos;

	document.getElementById(linkId).style.visibility="visible";
	document.getElementById(linkId).style.position="absolute";
	document.getElementById(linkId).style.top=vpos[id];
	width=getWindowSize("width");

	// Default.css has set width of table to 850
	//
	if ( width > 850) {
		document.getElementById(linkId).style.left=(width - 850)/2 + 100;
	} else {
		document.getElementById(linkId).style.left=110;
	}


	// document.getElementById(linkId).style.left=200;
	// height=getWindowSize("height");

	currentId=id;
}

function hideMenu(id) {
	// We need this conveluted time delay to stop flickering in IE 6
	// What a drag!
	//
	currentId=null;
	setTimeout('hideMenu2(' + id + ')', 100);
}

function hideMenu2(id) {
	// Hide the component when leaving unless we entered the div
	//
	// defaultStatus="id is" + id + " : " + currentId;
	if (currentId != id) {
		if (id != null) {
				linkId = 'LINK' + id;
				// defaultStatus="hide menu link id : " + linkId;
				document.getElementById(linkId).style.visibility="hidden";
		}
	}
}


function showDiv(id) {
	// If we enter the div, then unhide it
	//
	currentId=id;
	linkId = 'LINK' + id;
	document.getElementById(linkId).style.visibility="visible";
}

function hideAll() {
		document.getElementById('LINK10').style.visibility="hidden";
		document.getElementById('LINK20').style.visibility="hidden";
		document.getElementById('LINK30').style.visibility="hidden";
		document.getElementById('LINK40').style.visibility="hidden";
}

function hideDiv(id) {
	hideMenu(id);
}

