
var posx = 0;
var posy = 0;

var isOpera = (navigator.userAgent.indexOf('Opera') != -1);
var isIE = (!isOpera && navigator.userAgent.indexOf('MSIE') != -1)
var isFirefox = (!isOpera && navigator.userAgent.indexOf('Firefox') != -1)
var isObjectVisible = false;

var last_image = "";
var stored_image = "";
	
// we need to tell Mozilla to start listening:
//if (window.Event && document.captureEvents) {
//document.captureEvents(Event.MOUSEMOVE);
//}

// we need to assign the mouse handler in Mozilla
if (isFirefox) {
    document.onmousemove = showPopup;
    document.onmouseout = hidePopup;
}

var stored_obj;
var last_obj;

function showPopup(e, obj) {
 
  // Firefox never calls this function with both "e" and "obj" set 
  //   - so we store "obj" until "e" is set 
     
  // if we have a value for image store it for later 
  //and flag that the image is supposed to be seen
  if (obj != null) stored_obj = obj;
  if (obj != null) isObjectVisible = true;
     
  // we don't have a value for obj but we have one stored use the stored one
  if (obj == null && stored_obj != null) obj = stored_obj;

  // if the obj hasn't changed we don't need to continue
  // otherwise store the image in the last_obj variable
  if (obj != null && last_obj != null) {
    if (obj == last_obj) {
      return; 
    } else {
      last_obj = obj;
    }
  }

	if (!e) var e = window.event;  // IE, Opera
	if (!e) var e = window.Event;  // Mozilla

  if (e != null) {
  	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;
	  }
	} else {
	    // browser may be Firefox
	}
	
	var relTarg = e.relatedTarget || e.fromElement;

	
	//alert(posx + " - " + posy);
	
	if (posy > document.body.scrollHeight - 200) {
	    posy = document.body.scrollHeight - 200;
	}
	
	//window.status = isObjectVisible;
    
    // in Firefox if the obj is not meant to be seen - just exit
    if (isFirefox) {
        if (! isObjectVisible) {
        //document.getElementById(obj).style.display="none";
        return;
        }
     }

	// do what we need to do and flag that the image should be visible 
	document.getElementById(obj).style.left=(posx + 0) + "px";
	document.getElementById(obj).style.top=(posy + 30) + "px";
	
	document.getElementById(obj).style.display="block";
	isObjectVisible = true;
    //document.getElementById(obj).innerHTML = "<table class=\"popup-table\" cellpadding=15>" +
    //    "<tr><td><img src=\"" + image + "\"></td></tr></table>";
        
  //  isObjectVisible = true;
    
    return false;
}

function hidePopup(obj) {
	document.getElementById(obj).style.display="none";
	isObjectVisible = false;
}

