/*
 * ----------------------------------------------------------------------------
 * Copyright 2004 by The Swiss Post, PostFinance - all rights reserved
 * This software is the proprietary information of PostFinance.
 * Use is subject to license terms.
 * ----------------------------------------------------------------------------
 */
function getPosition(element) {
  position= new Object();
  position.x = findPosX(element);
  position.y = findPosY(element);
  return position;
}

function showToolTip(name) {
  var linkElement = document.getElementById("toolTipLink" + name);
  var divInfoImg = document.getElementById("toolTipLink" + name);
  var divInfoBox = document.getElementById("toolTip" + name);
  var position = getPosition(linkElement);
  
  position.x = position.x + 20;
  position.y = position.y - 5;
  
  var infoHeight = 0;
  if (divInfoBox.offsetHeight) {
    infoHeight = divInfoBox.offsetHeight;
  } else if (divInfoBox.style.pixelHeight) {
    infoHeight = divInfoBox.style.pixelHeight;
  } 

  if (divInfoImg.offsetHeight) {
    infoImgHeight = divInfoImg.offsetHeight;
  } else if (divInfoImg.style.pixelHeight) {
    infoImgHeight = divInfoImg.style.pixelHeight;
  } 

  position.y = position.y - infoHeight - infoImgHeight;

  var element = document.getElementById("toolTip" + name);
  element.style.left = "0px";
  element.style.top = position.y + "px";
  element.style.visibility = "visible";
}

function hideToolTip(name) {
  document.getElementById("toolTip" + name).style.visibility = "hidden";
}

/**
* Find X absolute position of input element
*/
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-170;
}

/**
* Find Y absolute position of input element
*/
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-110;
}