<!--

NS4 = (document.layers) ? 1 : 0;
IE4 = (document.all) ? 1 : 0;
W3C = (document.getElementById) ? 1 : 0;        

function show ( evt, name ) {

NS4 = (document.layers) ? 1 : 0;
IE4 = (document.all) ? 1 : 0;
W3C = (document.getElementById) ? 1 : 0;

  var currentX,         //mouse position on X axis
      currentY,         //mouse position on X axis
      x,                //layer target position on X axis
      y,                //layer target position on Y axis
      docWidth,         //width of current frame
      docHeight,        //height of current frame
      layerWidth,       //width of popup layer
      layerHeight,      //height of popup layer
      ele;              //points to the popup element

  // First let's initialize our variables

  if ( W3C ) {
    ele = document.getElementById(name);
    currentX = (evt.pageX || evt.clientX) + (IE4 ? document.body.scrollLeft : 0);
    currentY = (evt.pageY || evt.clientY) + (IE4 ? document.body.scrollTop : 0);
    docWidth = document.width;
    docHeight = document.height;
    layerWidth = 200;
    layerHeight = 100;

  } else if ( NS4 ) {
    ele = document.layers[name];
    currentX = evt.pageX,
    currentY = evt.pageY;
    docWidth = document.width;
    docHeight = document.height;
    layerWidth = 200;
    layerHeight = 100;

  } else {      // meant for IE4
    ele = document.all[name];
    currentX = evt.clientX + document.body.scrollLeft;
    currentY = evt.clientY + document.body.scrollTop;
    docHeight = document.body.offsetHeight;
    docWidth = document.body.offsetWidth;
    layerWidth = 200;
    layerHeight = 100;
  }

//   Then we calculate the popup element's new position
   if ( ( currentX + layerWidth ) > docWidth ) {
     x = ( currentX - layerWidth - 20);
   }
   else {
     x = currentX + 20;
   }

   y = currentY;


// (for debugging purpose) alert("docWidth " + docWidth + ", docHeight " + docHeight + "\nlayerWidth " + layerWidth + ", layerHeight " + layerHeight + "\ncurrentX " + currentX + ", currentY " + currentY + "\nx " + x + ", y " + y);
// alert("docWidth " + docWidth + ", docHeight " + docHeight + "\nlayerWidth " + layerWidth + ", layerHeight " + layerHeight + "\ncurrentX " + currentX + ", currentY " + currentY + "\nx " + x + ", y " + y);

  // Finally, we set its position and visibility

  if ( NS4 ) {
    ele.left = parseInt ( x );
    ele.top = parseInt ( y );
    ele.visibility = "show";
  } else {
    ele.style.left = parseInt ( x );
    ele.style.top = parseInt ( y );
    ele.style.visibility = "visible";
  }


}

function hide ( name ) {

NS4 = (document.layers) ? 1 : 0;
IE4 = (document.all) ? 1 : 0;
W3C = (document.getElementById) ? 1 : 0;

  if (document.getElementById) {
    document.getElementById(name).style.visibility = "hidden";
  } else if (NS4) {
    document.layers[name].visibility = "hide";
  } else {
    document.all[name].style.visibility = "hidden";
  }
}

function hide_all () {

NS4 = (document.layers) ? 1 : 0;
IE4 = (document.all) ? 1 : 0;
W3C = (document.getElementById) ? 1 : 0;

for (var i=1; i < 32; i++) {
  var xxx = "event_" + i;
  if ((W3C) && (document.getElementById(xxx))) {
    document.getElementById(xxx).style.visibility = "hidden";
  }
  if ((NS4) && (document.layers[xxx])) {
    document.layers[xxx].visibility = "hide";
  }
  if ((IE4) && (document.all[xxx])) {
    document.all[xxx].style.visibility = "hidden";
  }
}

}

//-->

