function MuestraTip(id,contenido)
{
	if(document.all)
	{
		document.write("<div style='width: 10px;' id=\"" + id + "\" onMouseOver=\"Tip_" + id + ".Show();\" onMouseOut=\"Tip_" + id + ".HideIE();\"><nobr>" + contenido + "</nobr></div>")
	}
	else
	{
		document.write("<ilayer id=\"" + id + "\"><layer onMouseOver=\"Tip_" + id + ".Show();\">" + contenido + "</layer></ilayer>")
	}
}

function Tip(id,xoff,yoff,contenido)
{
	this.id = id;
	this.xoff = xoff;
	this.yoff = yoff;
	this.contenido = contenido;

	this.Init = TipInit;
	this.Show = ShowTip;
	this.Hide = HideTip;
	this.HideIE = HideTipIE;
}

function TipCalcula_posX(padre)
{
	var x, padre;
	
	x = 0;
	while(padre!=null)
	{
		x = x + padre.offsetLeft;
		padre = padre.offsetParent;
	}
	return x;
}

function TipCalcula_posY(padre)
{
	var x, padre;
	
	x = 0;
	while(padre!=null)
	{
		x = x + padre.offsetTop;
		padre = padre.offsetParent;
	}
	return x;
}

function TipInit()
{
	var x,y;
	
	if(document.all)
	{
		// Calculamos la posición de la capa		
		x = TipCalcula_posX(eval("document.all." + this.id)) - 2;
		y = TipCalcula_posY(eval("document.all." + this.id)) - 2;
		
		// Creamos la capa
		document.body.insertAdjacentHTML("BeforeEnd","<div id='tip_" + this.id + "' onMouseOut=\"Tip_" + this.id + ".HideIE();\" style='position: absolute; top: " + y + "px; left: " + x + "px; visibility: hidden;'><table border=0 cellspacing=0 cellpadding=0><tr><td width='" + this.xoff + "' height='" + this.yoff + "'></td><td></td></tr><tr><td></td><td>" + this.contenido + "</td></tr></table></div>");
	}
	else
	{
		// Calculamos la posición de la capa
		x = document.layers[this.id].pageX - 2;
		y = document.layers[this.id].pageY - 2;
				
		// Creamos la capa
		var lyr = document.layers["tip_nt_" + this.id] = new Layer(0);
		lyr.name = "tip_nt_" + this.id;
		lyr.left = x;
		lyr.top = y;
		lyr.visibility = "hide";
		lyr.document.open();
		lyr.document.write("<layer id='tip_" + this.id + "' onMouseOut=\"Tip_" + this.id + ".Hide();\"><table border=0 cellspacing=0 cellpadding=0><tr><td width='" + this.xoff + "' height='" + this.yoff + "'></td><td></td></tr><tr><td></td><td>" + this.contenido + "</td></tr></table></layer>");
		lyr.document.close();
	}
}

function ShowTip()
{
	if(document.all)
	{
		eval("document.all.tip_" + this.id + ".style.visibility = 'visible'");
	}
	else
	{
		document.layers["tip_nt_" + this.id].visibility= "show";
	}
}

function HideTip()
{
	if(document.all)
	{
		eval("document.all.tip_" + this.id + ".style.visibility = 'hidden'");
	}
	else
	{
		document.layers["tip_nt_" + this.id].visibility= "hide";
	}
}

function HideTipIE()
{
	id = "tip_" + this.id;
	
  toElement=window.event.toElement;
  if (toElement)
  {
    if (toElement.id!=id)
    { 
      inside = eval(id + ".contains(toElement)");
      if (!inside) 
      { 
        this.Hide();
      }
    }
  }
  else 
  { 
    this.Hide();
  } 
}
