/*#############################################################*/
/*# Written by YourWeb (Web-Technologies & Solutions)         #*/
/*# You're welcome at our site http://www.your-web-service.de #*/
/*#############################################################*/

var MouseX  = 0;
var MouseY  = 0;

if(window.Event) document.captureEvents(Event.MOUSEMOVE);
window.onload        = SaveMouseXY;
document.onmousemove = SaveMouseXY;

function SaveMouseXY (e) {
  if(navigator.appName.substring(0,1) == "N") {
    MouseX = e.pageX;
    MouseY = e.pageY;
  }
  else {
    MouseX = document.body.scrollLeft + window.event.x;
    MouseY = document.body.scrollTop  + window.event.y;
  }
}

function ShowInfoBox (HTMLObject, YOffset, XOffset, WindowWidth, WindowHeight) {
  Obj = HTMLObject.id + '_InfoBox';
  document.getElementById(Obj).style.visibility = "visible";

  if (! WindowWidth ) WindowHeight = 0;
  if (! WindowHeight) WindowHeight = 0;

  var PosLeft = MouseX + 20 + (XOffset ? XOffset : 0);
  if (window.document.body.offsetWidth - (MouseX-document.body.scrollLeft+XOffset+40) < WindowWidth) {
    PosLeft = Math.max(PosLeft - WindowWidth-25, document.body.scrollLeft);
  }
  else {
    PosLeft = Math.min(PosLeft,window.document.body.offsetWidth+document.body.scrollLeft-WindowWidth-20);
  }
  document.getElementById(Obj).style.left = PosLeft;

  var PosTop  = MouseY + YOffset;
  if (window.document.body.offsetHeight - (MouseY-document.body.scrollTop+YOffset+20) < WindowHeight) {
    PosTop = Math.max(PosTop - WindowHeight-30, document.body.scrollTop);
  }
  else {
    PosTop  = Math.min(PosTop,window.document.body.offsetHeight+document.body.scrollTop-WindowHeight);
  }
  document.getElementById(Obj).style.top = PosTop;
}

function ShowInfoBox_OLD (HTMLObject, YOffset, XOffset) {
  Obj = HTMLObject.id + '_InfoBox';
  document.getElementById(Obj).style.visibility = "visible";
  document.getElementById(Obj).style.left = MouseX + 20 + (XOffset ? XOffset : 0);
  document.getElementById(Obj).style.top  = MouseY + YOffset;
}

function HideInfoBox (HTMLObject) {
  document.getElementById(HTMLObject.id + '_InfoBox').style.visibility = "hidden";
}

function ShowMouseOverBox (HeaderString, CellString, YOffset, XOffset, WindowWidth, WindowHeight) {
  document.getElementById('OnMouseOverBox_Title').innerHTML = HeaderString;
  document.getElementById('OnMouseOverBox_Cell').innerHTML  = CellString;
  document.getElementById('OnMouseOverBox').style.visibility = "visible";

  if (! WindowWidth ) WindowHeight = 0;
  if (! WindowHeight) WindowHeight = 0;

  var PosLeft = MouseX + 20 + (XOffset ? XOffset : 0);
  if (window.document.body.offsetWidth - (MouseX-document.body.scrollLeft+XOffset+40) < WindowWidth) {
    PosLeft = Math.max(PosLeft - WindowWidth-25, document.body.scrollLeft);
  }
  else {
    PosLeft = Math.min(PosLeft,window.document.body.offsetWidth+document.body.scrollLeft-WindowWidth-20);
  }
  document.getElementById('OnMouseOverBox').style.left = PosLeft;
/*  document.getElementById('OnMouseOverBox').style.left = MouseX + 20 + (XOffset ? XOffset : 0);*/
/*  document.getElementById('OnMouseOverBox').style.top  = MouseY + YOffset;*/

  var PosTop  = MouseY + YOffset;
  if (window.document.body.offsetHeight - (MouseY-document.body.scrollTop+YOffset+20) < WindowHeight) {
    PosTop = Math.max(PosTop - WindowHeight-30, document.body.scrollTop);
  }
  else {
    PosTop  = Math.min(PosTop,window.document.body.offsetHeight+document.body.scrollTop-WindowHeight);
  }
  document.getElementById('OnMouseOverBox').style.top = PosTop;

/*  var PosTop  = MouseY + YOffset;*/
/*      PosTop  = Math.min(PosTop,window.document.body.offsetHeight+document.body.scrollTop-WindowHeight);*/
/*  document.getElementById('OnMouseOverBox').style.top  = PosTop;*/
}

function HideMouseOverBox (HTMLObject) {
  document.getElementById('OnMouseOverBox').style.visibility = "hidden";
}
