/*
    This file contains fuctions required to handle layered popups.
 */
 
// cool cross-platform object reference getter
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) {
    this.obj = document.layers[name];
    this.style = document.layers[name];
  }
}

// Displays the required div
function showImg(me, myDiv, width, height) {
	myDiv.style.visibility = "visible";
	var left = findPosX(me) + 20;
	var top = findPosY(me) - (height/2);
	myDiv.style.left = left + 'px';
	myDiv.style.top = top + 'px';
}

// Hides the object
function hide(myDiv) {
	myDiv.style.visibility = "hidden";
	myDiv.style.left = '-500px';
	myDiv.style.top = '-500px';
}

// Utility function to find the x position of the calling object for placement
function findPosX(obj) {
	var curleft = 0;
	if (obj.offsetParent) {
		while (obj.offsetParent) {
			curleft += obj.offsetLeft
			obj = obj.offsetParent;
		}
	} else if (obj.x) {
		curleft += obj.x;
	}
	return curleft;
}

// Utility function to find the y position of the calling object for placement
function findPosY(obj) {
	var curtop = 0;
	if (obj.offsetParent) {
		while (obj.offsetParent) {
			curtop += obj.offsetTop
			obj = obj.offsetParent;
		}
	} else if (obj.y) {
		curtop += obj.y;
	}
	return curtop;
}