var currentLayerName = '';
var currentTimeoutID = null;

var isIE = (navigator.userAgent.indexOf("MSIE") != -1) ? true : false;
var isFireFox = (navigator.userAgent.indexOf("Firefox") != -1) ? true : false;

//============================ Obj Position ============================//
// IE has .offsetLeft and NS has .x, not sure about Opera + others, But it seems to work well.
// these funtions find ABSOLUTE or REAL postions to the left of the program windows
	function RLFindPosX(obj)
	{
		var objLeft = 0;
		if (document.getElementById || document.all)	{
			while (obj.offsetParent)	{
				objLeft += obj.offsetLeft
				obj = obj.offsetParent;
			}
		}
		else if (document.layers)
			objLeft += obj.x;
		return objLeft;
	}

	function RLFindPosY(obj)
	{
		var objTop = 0;
		if (document.getElementById || document.all)	{
			while (obj.offsetParent)	{
				objTop += obj.offsetTop
				obj = obj.offsetParent;
			}
		}
		else if (document.layers)
			objTop += obj.y;
		return objTop;
	}
	
//===========================================================//
// top-left of the layer is at top-left of the image ImageName, offset by delta. 
function RLShowLayer_withImagePos(inLayerName,ImageName,no_timeout,delta)
{
	if (inLayerName == '')    return;
	if (ImageName == '')    return;
		
	// first hide the existing layer 
	RLHideLayerNow();
	
	// then show the required layer	
	var layer;
	currentLayerName = inLayerName;
	objImage = document.images[ImageName];
	// --- Don't have to set position of DIV : image positon + delta (offset) ---
	// --- because set DIV position : relative // Comment by Oh 22/05/2007 -----
	//LayerLeft = RLFindPosX(objImage)+delta; 
	//LayerTop = RLFindPosY(objImage)+10;	

	if (document.layers) {		// Netscape type
		layer =  document.layers[currentLayerName];
		// --- Comment by Oh 22/05/2007 -----
		//layer.left = LayerLeft;	//+'px';
		//layer.top = LayerTop;	//+'px';
		layer.visibility = 'show';
	}
	else { 	// IE type	
		layer = document.all[currentLayerName];
		// --- Comment by Oh 22/05/2007 -----
		//layer.style.left = LayerLeft+'px';
		//layer.style.top = LayerTop+'px';
		if (isFireFox)	layer.style.left = '25px'; // --- Comment by Oh 22/05/2007 ----- 
   	layer.style.visibility = 'visible';
 	}
	
	// set time out to hide layer // unless clear time out later.
	if(no_timeout) {
		clearTimeout(currentTimeoutID);
	} else {
		currentTimeoutID = setTimeout('RLHideLayer()',1500);
	}
}

//===========================================================//
// Hide it after mouse out (normally)
	function RLTimeOutHide(inLayerName,amount)
	{
		currentLayerName = inLayerName;
		if(currentTimeoutID != null)
			clearTimeout(currentTimeoutID);	
		currentTimeoutID = setTimeout('RLHideLayerNow()',amount);
	}
	
//===========================================================//
// Hide it now ! work with current Id, current layer
	function RLHideLayerNow()
	{
		if(currentTimeoutID != null)
			clearTimeout(currentTimeoutID);
		RLHideLayer();
	}
	
	function RLHideLayer()
	{
		// if no current layer
		if(currentLayerName == '')
			return;
			
		var layer;
		if (document.layers) { 	// Netscape
			layer = document.layers[currentLayerName];
			layer.visibility = 'hide';
		}
		else { 	// IE 
			layer = document.all[currentLayerName];
			layer.style.visibility = 'hidden';
		}
	}

//********************************************************************************//
/* extra function
 * given layer name, show that layer
 */
 
	function RLShowLayer(inLayerName)
	{	
		if(inLayerName == '')
			return;

		// delete time out
		if(TimeOutID != null)
			clearTimeout(TimeOutID);

		var layer;	
		if (document.layers) { 	// Netscape
			layer = document.layers[inLayerName];
			layer.visibility =  'show';
		}
		else { 	// IE 
			layer = document.all[inLayerName];
	    	layer.style.visibility = 'visible';
		}
	}