    var activo = null;
    function activa(id, link)
    {
        if (id != activo)
        {
            ocultaActual();            
            muestra(id, link);
        }
    }    
    
    function muestra(id, link)
    {
        var elem = document.getElementById(id);
        var anchoTotal = elem.offsetWidth;
        var altoTotal = elem.offsetHeight;
	    var coors = findPos(link, anchoTotal, altoTotal);
	    elem.style.top = coors[1] + 'px';
	    elem.style.left = coors[0] + 'px';
        elem.style.visibility = "visible";
        activo = id;
        bucleMuestra(id, 0, 1);
    }
    
    
    function bucleMuestra(id, valor, incr)
    {
        if (valor > 100)
            valor = 100;
        var elem = document.getElementById(id);
        elem.style.opacity = valor / 100;
        elem.style.filter = "alpha(opacity='" + valor + "')";
        valor += incr;
        incr = incr + 3;
        if (valor != 100)
            setTimeout("bucleMuestra('" + id + "', " + valor + ", " + incr + ")", 10);
    }
    
    function ocultaActual()
    {
        if (activo != null)
        {
            var elem = document.getElementById(activo);
            elem.style.visibility = "hidden";           
            activo = null;
        }
                
    }
    
    function findPos(obj, anchoTotal, altoTotal)
    {
	    var curleft = 0;
	    var curtop = 0;
	    if (obj.offsetParent) {
	        var altura = obj.offsetHeight;
		    curleft = obj.offsetLeft;
		    curtop = obj.offsetTop;
		    while (obj = obj.offsetParent) 
		    {
			    curleft += obj.offsetLeft;
			    curtop += obj.offsetTop;
		    }
		    
		    var altoVentana, anchoVentana;
		    if (document.compatMode && document.compatMode != "BackCompat")
		    {
               altoVentana = document.documentElement.clientHeight;
               anchoVentana = document.documentElement.clientWidth;
            }
            else
            {
               altoVentana = document.body.clientHeight;
               anchoVentana = document.body.clientWidth;
            }

		    if (curtop + altura + altoTotal > altoVentana)
		    {
		        curtop = curtop - altoTotal;
		    }
		    else
    	        curtop += altura;
    	    
    	    if (curleft + anchoTotal > anchoVentana)
    	    {
    	        curleft = anchoVentana - anchoTotal;
    	    }
	    }
	    return [curleft,curtop];
    }


