var allisready = false;

//Sniff Browser and check for DHTML
var agt=navigator.userAgent.toLowerCase();
var is_major = parseInt(navigator.appVersion);
var is_minor = parseFloat(navigator.appVersion);
var is_nav  = (
				(agt.indexOf('mozilla')!=-1) &&
				(agt.indexOf('spoofer')==-1) &&
				(agt.indexOf('compatible')==-1) &&
				(agt.indexOf('opera')==-1) &&
				(agt.indexOf('webtv')==-1) &&
				(agt.indexOf('hotjava')==-1)
			);
var is_nav4up = (is_nav && (is_major >= 4));
var is_nav6up = (is_nav && (is_major >= 5));
var is_ie     = ((agt.indexOf("msie") != -1) && (agt.indexOf("opera") == -1));
var is_nav4 = (is_nav && (is_major == 4));	
var is_ie4up  = (is_ie && (is_major >= 4));
var is_dhtml = (is_ie4up || is_nav6up)

//alert(is_ie + '|' + is_nav + '|' + is_major + '|' + is_minor + '|' + agt);

//Set Initial Variables and Catch move Event
var tempX = 0, tempY = 0, overDiv = false, bodyWidthCenter = 0, lastOverDiv = false;
//document.onmousemove = getMouseXY

var isIE = document.all?true:false;
if (!isIE) document.captureEvents(Event.MOUSEMOVE);
document.onmousemove = getMouseXY;

/*
function getMouseXY (e)
{
	if (!e)	var e = window.event;
	if (e.pageX || e.pageY)
	{
		tempX = e.pageX;
		tempY = e.pageY;
	}
	else if (e.clientX || e.clientY)
	{
		tempX = e.clientX + document.body.scrollLeft;
		tempY = e.clientY + document.body.scrollTop;
	}
	
	//document.getElementById ('showarea').innerHTML = 'coords: ' + tempX + 'x' + tempY;
	
	return true;
}
*/

function getMouseXY (e)
{
	if (!allisready) return false;
	
	var posx = 0;
	var posy = 0;
	
	if (!e) var e = window.event;
	
	if (e.pageX || e.pageY)
	{
		posx = e.pageX;
		posy = e.pageY;
	}
	else if (e.clientX || e.clientY)
	{
		posx = e.clientX + document.body.scrollLeft + document.documentElement.scrollLeft;
		posy = e.clientY + document.body.scrollTop + document.documentElement.scrollTop;
	}
	
	tempX = posx;
	tempY = posy;
	
	// posx and posy contain the mouse position relative to the document
	// Do something with this information
}

var wait = false
var stillhover = false

function doHide() {
if (!allisready) return false;
	stillhover = false;
	clearInterval(wait)
	wait = false
	wait = setInterval("HidePopup()", 500); 
}

function HidePopup() {
	if (wait) {
		if (!stillhover){
			Popup()
		}
		clearInterval(wait)
		wait = false
	}
}

function doHover() {
if (!allisready) return false;
	stillhover = true
}

function Popup(id, hide){ 
	if (is_dhtml){
		if (id) {
			(is_ie4up) ? overDiv = document.all[id].style : overDiv = document.getElementById(id).style;

			(is_ie4up) ? bodyHeight = document.body.clientHeight : bodyHeight = window.innerHeight;
			if ((tempY + 100) < bodyHeight) {
				overDiv.top = (tempY); 
			}
			else {
				overDiv.top = (tempY - 50);
			}

			(is_ie4up) ? bodyWidth = document.body.clientWidth : bodyWidth = window.innerWidth;
			if ((tempX + 236) < bodyWidth) {
				overDiv.left = (tempX);
			}
			else {
				overDiv.left = (tempX - 215);
			}
			
			document.getElementById(id).style.top = tempY + 'px';
			document.getElementById(id).style.left = tempX + 'px';
			
			//alert (tempY + '-' + tempX);
			//alert (overDiv.top  + '-' +  overDiv.left);
			
			if ((overDiv != lastOverDiv) && lastOverDiv) {
				lastOverDiv.visibility = "hidden";
				lastOverDiv = false;
			}
			overDiv.visibility = "visible";
			lastOverDiv = overDiv
		}
		else {
			overDiv.visibility = "hidden";
			overDiv = false;
		}
	}
}

function doShow(state){
if (!allisready) return false;
	stillhover = true
	Popup(state);
}


