var posX=0;
var posY=0;
var allSupport = (document.all!=null || window.sidebar!=null);

function getElement(elName) {
// Get an element from its ID
if (allSupport)
  return document.getElementById(elName);
else
  return document.layers[elName]
}

function writeContents(el, tip) {
// Replace the contents of the tooltip
if (allSupport)
  el.innerHTML = tip
else {
  // In NS, insert a table to work around
  // stylesheet rendering bug.
  // NS fails to apply style sheets when writing
  // contents into a positioned element.
  el.document.open()
  el.document.write("<TABLE WIDTH=300 BORDER=1 bordercolor=black cellpadding=3 cellspacing=0><TR><TD WIDTH=100% BGCOLOR=#CED7E7>")
  el.document.write(tip)
  el.document.write("</TD></TR></TABLE>")
  el.document.close()
}
}

function getOffset(el, which) {
// Function for IE to calculate position
// of an element.
var amount = el["offset"+which]
if (which=="Top")
  amount+=el.offsetHeight
el = el.offsetParent
while (el!=null) {
  amount+=el["offset"+which]
  el = el.offsetParent
}
return amount
}

function setPosition(el, src) {
// Set the position of an element
//src = window.event.srcElement
if (allSupport) {
  el.style.pixelTop = getOffset(src, "Top") + posY
  el.style.pixelLeft = getOffset(src, "Left") + posX
  //alert(el.style.pixelTop);
  //mozilla
  el.style.top = getOffset(src, "Top") + posY + "px";
  el.style.left = getOffset(src, "Left")+ posX + "px";
  //alert(el.style.top);
} else
{
  el.top = src.y + 20 + posY
  el.left = src.x + posX
  //alert(el.top);
}
}

function setVisibility(el, bDisplay) {
// Hide or show to tip
if (bDisplay)
  if (allSupport)
	el.style.visibility = "visible"
  else
	el.visibility = "show";
else
  if (allSupport)
	el.style.visibility = "hidden"
  else
	el.visibility = "hidden"
}

function displayContents(srcObj, tip) {
// Display the tooltip.
var el = getElement("tipBox")
writeContents(el, tip)
setPosition(el, srcObj)
setVisibility(el, true)
}

function tip(srcObj, tip) {
	displayContents(srcObj, tip);
}

function nukeTip() {
  setVisibility(getElement("tipBox"), false);
}