// $Id: popUp.js,v 1.3 2002/11/05 16:18:57 rl Exp $

function show_props(obj, obj_name) {
   var result = "";
   for (var i in obj)
      result += obj_name + "." + i + " = " + obj[i] + "\n";
   return result;
}

function findPosX(obj)
{
	var curleft = 0;
	if (document.getElementById || document.all)
	{
		while (obj.offsetParent)
		{
			curleft += obj.offsetLeft
			obj = obj.offsetParent;
		}
	}
	else if (document.layers)
		curleft += obj.x;
	return curleft;
}

function findPosY(obj)
{
	var curtop = 0;
	var printstring = '';
	if (document.getElementById || document.all)
	{

		while (obj.offsetParent)
		{
			//printstring += ' element ' + obj.tagName + ' has ' + obj.offsetTop;
		curtop += obj.offsetTop
			obj = obj.offsetParent;
		}
	}
	else if (document.layers)
		curtop += obj.y;
	//window.status = printstring;
	return curtop;
}


function getObj(name)
{
 if (document.getElementById)
 {
	   this.obj = document.getElementById(name);
	   this.style = document.getElementById(name).style;
 
 }
 else if (document.all)
 {
	   this.obj = document.all[name];
	   this.style = document.all[name].style;
 }
 else if (document.layers)
 {
	   if (document.layers[name])
	   {
	   	this.obj = document.layers[name];
	   	this.style = document.layers[name];
	   }
	   else
	   {
	    this.obj = document.layers.testP.layers[name];
	    this.style = document.layers.testP.layers[name];
	   }
 }
}

function popUp(obj,currElem,doThis){
	var newX = findPosX(obj);
	var newY = findPosY(obj);
	var x = new getObj(currElem);
	if (doThis == 'show') {
		x.style.visibility = "visible";

	} else if (doThis == 'hide'){
		x.style.visibility = "hidden";
	}


	//alert(currElem + ':' + x.style.left + ',' + x.style.top);
	// Netscape 4 doesn't allow units
	// to be set for .top and .left
	// Netscape 7 in Standards Compliant Mode requires them
	//alert(newX + ',' + newY);

	if ((newX - 30) < 0)
		newX = 30;
	if (document.getElementById || document.all){
		x.style.top = (newY + 35 + 'px');
		x.style.left = (newX - 30 + 'px');
	}else{
		x.style.top = (newY + 35);
		x.style.left = (newX - 30);

	}
	//alert(x.style.left + ',' + x.style.top);
}

