// Obj, the html element object.
// force, are we forcing "SHOW" or "NOSHOW"? If neither, just leave blank.

function toggle(obj, force){
  var el = document.getElementById(obj);

  // Check to see if we're forcing it to be on or off...
  if(force == undefined || force == null || force == "")
    el.style.display = (el.style.display == "none" ? "" : "none");
  else if(force == "SHOW" || force == "show" || force == "Show")
    el.style.display = "";
  else if(force == "NOSHOW" || force == "noshow" || force == "NoShow")
    el.style.display = "none";
  else
    el.style.display = (el.style.display == "none" ? "" : "none");

}

/***********************************************************************************************************/
/***********************************************************************************************************/
/** BORROWED FROM http://www.codelifter.com/main/javascript/capturemouseposition1.html. Awesome function. **/
/***********************************************************************************************************/
/***********************************************************************************************************/
// 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

function getMouseXY(e, obj) {
  if (IE) { // grab the x-y pos.s if browser is IE
    tempX = event.clientX + document.body.scrollLeft;
    tempY = event.clientY + document.body.scrollTop;
  } else {  // grab the x-y pos.s if browser is NS
    tempX = e.pageX;
    tempY = e.pageY;
  }  
  // catch possible negative values in NS4
  if (tempX < 0){tempX = 0}
  if (tempY < 0){tempY = 0}  
  // show the position values in the form named Show
  // in the text fields named MouseX and MouseY

  if(obj != undefined)
  {
    var el = document.getElementById(obj);
    el.style.left = tempX - 335; // - 335;
    el.style.top = tempY - 220; // + 25;
    toggle(obj, "Show");
  }
}
/***********************************************************************************************************/
/***********************************************************************************************************/
/** BORROWED FROM http://www.codelifter.com/main/javascript/capturemouseposition1.html. Awesome function. **/
/***********************************************************************************************************/
/***********************************************************************************************************/





function getMousePos(oEvent, obj){
 // Get the id of obj and then use event to get the mouse pos and set obj's position. 
 var el = document.getElementById(obj);
 el.style.left = oEvent.screenX - 350;
 el.style.top = oEvent.screenY - 420; 
 toggle(obj, "Show");
}