// Gerenador de etiquetas ALT--------------------------------------------

document.write('<div id="div_tooltip"></div>') //Div del tooltip
document.write('<img id="pointer" src="http://www.que-mepongo.com/_img/ico_tooltip.gif">') //Imagen del pointer

var distancia_cursor_X = 12; //Dsitancia del div flotante respecto al cursor
var distancia_cursor_Y = 10;

var distancia_pointer_X = 10; //Dsitancia del div flotante respecto al pointer
var distancia_pointer_Y = 14; 


var ie = document.all; //variable que determina que el navegador es IE
var ns6 = document.getElementById && !document.all; //variable que determina que el navegador no es IE
var habilita_tip = false;

if (ie||ns6){
	if (document.all){
		var tipobj = document.all["div_tooltip"];
		var pointerobj = document.all["pointer"];
	} else {
		if (document.getElementById){
			var tipobj = document.getElementById("div_tooltip");
			var pointerobj = document.getElementById("pointer");
		} else {
			var tipobj = "";
			var pointer = "";
		}
	}
}



function ietruebody(){
	if ((document.compatMode) && (document.compatMode != "BackCompat")){ //Verifica si IE no se ejecuta en modo Quirks
		return document.documentElement;
	} else {
		return document.body;
	}
}

function muestra_tooltip(contenido_tooltip){
	if ((ns6)||(ie)){
		tipobj.innerHTML = contenido_tooltip;
		habilita_tip = true;
		return false;
	}
}

function posicion_tooltip(e){
	
	if (habilita_tip){
		var sin_posicion_defecto = false;
		if (ns6){ var curX = e.pageX; } else { var curX = event.clientX + ietruebody().scrollLeft; }
		if (ns6){ var curY = e.pageY; } else { var curY = event.clientY + ietruebody().scrollTop; }

		//Verificamos la distancia del ratn respecto a la esquina de la ventana
		if ((ie) && (!(window.opera))){ var ancho_ventana = ietruebody().clientWidth; } else { var ancho_ventana = window.innerWidth-20; }
		if ((ie) && (!(window.opera))){ var alto_ventana = ietruebody().clientHeight; } else { var alto_ventana = window.innerHeight-20; }

		if ((ie) && (!(window.opera))){ var borde_derecho = ancho_ventana - event.clientX - distancia_cursor_X; } else { var borde_derecho = ancho_ventana - e.clientX - distancia_cursor_X; }
		if ((ie) && (!(window.opera))){ var borde_inf = alto_ventana - event.clientY - distancia_cursor_Y; } else { var borde_inf = alto_ventana - e.clientY - distancia_cursor_Y; }
		
		if (distancia_cursor_X < 0){ var borde_izquierdo = distancia_cursor_X * (-1); } else { var borde_izquierdo = -1000; }

		//Si la distancia no es suficiente acomodamos el ancho

		if (borde_derecho < tipobj.offsetWidth){
		//Mueve la posicin horizontal del tooltip a la izuierda con su ancho
			tipobj.style.left = curX - tipobj.offsetWidth+"px";
			sin_posicion_defecto = true;
		} else if (curX < borde_izquierdo){
			tipobj.style.left = "5px";
		} else {
		//Sita la posicin horizontal del tooltip dnde el ratn est posicionado
			tipobj.style.left = curX + distancia_cursor_X - distancia_pointer_X+"px";
			pointerobj.style.left = curX + distancia_cursor_X+"px";
		}
		
		//El mismo concepto para la posicin vertical
		if (borde_inf < tipobj.offsetHeight){
			tipobj.style.top = curY - tipobj.offsetHeight - distancia_cursor_Y+"px";
			sin_posicion_defecto = true;
		} else {
			tipobj.style.top = curY + distancia_cursor_Y + distancia_pointer_Y+"px";
			pointerobj.style.top = curY + distancia_cursor_Y +"px";
		}

		tipobj.style.visibility = "visible";
		if (!(sin_posicion_defecto)){
			pointerobj.style.visibility = "visible";
		} else {
			pointerobj.style.visibility = "hidden";
		}
	
	}
}

function oculta_tooltip(){
	if ((ns6)||(ie)){
		habilita_tip = false;
		tipobj.style.visibility = "hidden";
		pointerobj.style.visibility = "hidden";
		tipobj.style.left = "-1000px";
		tipobj.style.backgroundColor = '';
		tipobj.style.width = '';
	}
}

document.onmousemove = posicion_tooltip; //Al mover el ratn ejecutamos la funcin posicion_tooltip();
//------------------------------------------------------------


