var isIE = (document.all)?true:false
var isNN = (document.getElementById && !isIE)?true:false
var isMAC = (navigator.userAgent.toLowerCase().indexOf("mac")!=-1)?true:false
var onNow = "Row0";
var x = 0;
var y = 0;
var scrollX = 0;
var scrollY = 0;
var divWidth = 0;
var divHeight = 0;
var marginWidth = 5;
var marginHeight = 3;

function ChooseRow(RowID)
{
 if ((RowID != onNow))
 {
  if (onNow != "Row0") 
  {
   document.getElementById(onNow).style.backgroundColor = "#ffffff";
   HideDiv('MyDiv');
  }
  onNow = RowID;
  if (onNow != "Row0") document.getElementById(onNow).style.backgroundColor = "#E7EEF7";
 }
}

//-------------------------------------------------

if (isNN) document.captureEvents(Event.MOUSEMOVE);
document.onmousemove = mouseMove;


//-------------------------------------------------

function mouseMove(e)
{
 if (isIE) 
 {
  if ((navigator.userAgent.indexOf('MSIE 5')>0) || (navigator.userAgent.indexOf('MSIE 6')>0))
  {
   scrollX = document.body.scrollLeft;
   scrollY = document.body.scrollTop;
  } 
  x = event.x + scrollX; 
  y = event.y + scrollY;
 }
 else
 {
  x = e.pageX; 
  y = e.pageY;
 }
}

//-------------------------------------------------

function ShowDiv(divName)
{
 
 if (isNN) 
 {
  winWidth = window.innerWidth; 
  winHeight = window.innerHeight;
  divWidth = document.getElementById(divName).offsetWidth;
  divHeight = document.getElementById(divName).offsetHeight;
 }
 
 if (isIE) 
 {
  winWidth = document.body.clientWidth;
  winHeight = document.body.clientHeight;
  divWidth = document.getElementById(divName).clientWidth;
  divHeight = document.getElementById(divName).clientHeight;
 } 
 
 if ((x + divWidth + 10) > winWidth) x -= (divWidth + marginWidth);
 else x += marginWidth;
 
 if ((y + divHeight) > winHeight)
 {
  if (y < divHeight) y = y / 2;
  else y -= (divHeight + marginHeight);
 } 
 else y += marginHeight;

 document.getElementById(divName).style.left = x;
 document.getElementById(divName).style.top = y;
 document.getElementById(divName).style.visibility = "visible";
}

//-------------------------------------------------

function HideDiv(divName)
{
 document.getElementById(divName).style.visibility = "hidden";
}

//-------------------------------------------------

function WriteHTML(divName, html)
{
  document.getElementById(divName).innerHTML = html;
}

