//-------- set up global variables for browser-specific handling -------
var visible, hidden;

if(document.layers) { visible = 'show'; hidden = 'hide'; }
else if(document.all) { visible = 'visible'; hidden = 'hidden'; }


//---------- useful general purpose layer functions ----

function getItem(item)
{
 if(document.layers)
       {
	 return document.layers[item];
       }
   else if(document.all)
       {
	   return document.all(item).style;
       }
} 

function showLayer(name)
{
 getItem(name).visibility = visible;
}

/**Move the given layer to the given coordinates, then make it visible.*/
function showLayerAt(name, x, y)
{
 moveLayer(name, x, y);
 showLayer(name);
}

/**Move the given layer to the given coordinates.*/
function moveLayer(name, x, y)
{
  var theLayer = getItem(name);
  theLayer.top = y;
  theLayer.left = x;
} 

function hideLayer(name) { getItem(name).visibility = hidden; }

/**Show the given layer at the cursor location.*/
function popupLayer(name, evt)
{
 var x, y;
 if(document.all) //TO DO: adjust for IE's scrolling co-ordinate scheme!
 { 
 	evt = window.event; 
	x = evt.clientX + document.body.scrollLeft; 
	y = evt.clientY + document.body.scrollTop; 
 } 
 else if(document.layers) { x = evt.pageX; y = evt.pageY; }

 //alert(x + ", " + y);
 showLayerAt(name, x - 10, y - 20);
}