/* FUNCIONES PARA MOSTRAR LA VENTANA DONDE ESTÁ EL PUNTERO */
var IE = document.all ? true : false;
if (!IE) {
    document.captureEvents(Event.MOUSEDOWN);
}
document.onmousedown = getMouseXY;
var tempX = 0;
var tempY = 0;

function getMouseXY(e){
	var IE = document.all ? true : false;
	if (!IE) {
		document.captureEvents(Event.MOUSEDOWN);
	}
	if (IE) { //para IE
		tempX = event.clientX + document.body.scrollLeft;
		tempY = event.clientY + document.body.scrollTop;
	}
	else { //para netscape
		tempX = e.pageX;
		tempY = e.pageY;
	}
	tempX = tempX - 20;
	tempY = tempY - 20;
	if (tempX < 0) {
		tempX = 0;
	}
	if (tempY < 0) {
		tempY = 0;
	}
	return true;
}

function mostrarCapaEnRaton(capa)
{
	//alert("tempX = " + tempX + " - tempY = " + tempY);

	if((parseInt(tempX) + eval(Refcapa+capa+Refwidth)) > parseInt(document.body.clientWidth))
		tempX = parseInt(document.body.clientWidth) - eval(Refcapa+capa+Refwidth) - 10
	eval(Refcapa+capa+Refestilo+Reftop+'='+parseInt(tempY)+';')
	eval(Refcapa+capa+Refestilo+Refleft+'='+parseInt(tempX)+';')
}

function moverCapaCentro(capa)
{
	eval(Refcapa+capa+Refestilo+Reftop+'='+parseInt(document.body.clientHeight/2 - eval(Refcapa+capa+Refheight)/2)+';')
	eval(Refcapa+capa+Refestilo+Refleft+'='+parseInt(document.body.clientWidth/2 - eval(Refcapa+capa+Refwidth)/2)+';')
}

/* FUNCIONES PARA AJAX */
XHR= new Array;

function cXHR(){
	var XHR=false;
	if(typeof XMLHttpRequest!='undefined'){ /*Vemos si el objeto window(la base de la ventana del navegador) posee el método XMLHttpRequest(Navegadores como Mozilla y Safari). */
		return new XMLHttpRequest(); //Si lo tiene, crearemos el objeto con este método.
	}
	else if(typeof ActiveXObject!='undefined'){ /*Sino tenía el método anterior, debería ser el Internet Exp. un navegador que emplea objetos ActiveX, lo mismo, miramos si tiene el método de creación. */
		/*Hay diferentes versiones del objeto, creamos un array, que contiene los diferentes tipos desde la
		versión mas reciente, hasta la mas antigua */
		var versionesObj = new Array(
			'Msxml2.XMLHTTP.7.0',
			'Msxml2.XMLHTTP.6.0',
			'Msxml2.XMLHTTP.5.0',
			'Msxml2.XMLHTTP.4.0',
			'Msxml2.XMLHTTP.3.0',
			'Msxml2.XMLHTTP',
			'Microsoft.XMLHTTP');
		for (var i = 0; i < versionesObj.length; i++)
		{
			try
			{
				/*Intentamos devolver el objeto intentando crear las diferentes versiones se puede intentar crear uno que no existe y se producirá un error. */
				return new ActiveXObject(versionesObj[i]);
			}
			catch (errorControlado) //Capturamos el error, ya que podría crearse otro objeto.
			{
			}
		}
	}
	if(XHR)
		return XHR;
	else
		alert("Error: AJAX no funciona en su navegador. Actualícelo.");
}

function ajax(id_div,URL_a_cargar) {
	var n=XHR.length;
	var fecha = new Date();
	if(URL_a_cargar.indexOf("?") > -1)
		URL_a_cargar = URL_a_cargar + "&fechaVar=" + fecha;
	else
		URL_a_cargar = URL_a_cargar + "?fechaVar=" + fecha;
	XHR[n]=cXHR(); 
	XHR[n].open( "GET", URL_a_cargar , true );
	XHR[n].onreadystatechange=function()
	{
		if (XHR[n].readyState==4)
        	if (XHR[n].status==200)
			{
				//alert(XHR[n].responseText);
				document.getElementById(id_div).innerHTML=XHR[n].responseText;
				XHR[n]="";
			}
            else if(XHR[n].status==400) alert("Error: Error de sintaxis");
            else if(XHR[n].status==401) alert("Error: Acceso no autorizado, el usuario debe autentificarse");
            else if(XHR[n].status==403) alert("Error: Acceso Prohibido");
            else if(XHR[n].status==404) alert("Error: No Encontrado");
            else if(XHR[n].status==405) alert("Error: Modo no permitido");
            else if(XHR[n].status==500) alert("Error: Error Interno");
            else if(XHR[n].status==501) alert("Error: No Implementado");
            else if(XHR[n].status==502) alert("Error: Sobrecargado");
            else if(XHR[n].status==503) alert("Error: Servicio no disponible");
            else if(XHR[n].status==504) alert("Error: Gateway Fuera de Tiempo");
            else if(XHR[n].status==505) alert("Error: Versión de HTTP no Soportada");
            else alert("Error "+XHR[n].status+": "+XHR[n].statusText);
			
			/*if (XHR[n].responseText.substring(0, 9) == "redirect:")
			{
				window.location = XHR[n].responseText.substr(9);
			}*/
		else if (XHR[n].readyState==3)	
			// mostramos imágen de carga AJAX
			document.getElementById(id_div).innerHTML='<center><img src=/imagenes/loading.gif alt="Cargando..." title="Cargando..." /><br>Cargando...</center>';
	}
    XHR[n].send(null);
}

if(document.getElementById){  // si se trata de Netscape 6
	Refcapa='document.getElementById("'
	Refestilo='").style'
	Refwidth='").offsetWidth'
	Refheight='").offsetHeight'
	Reftop='.top'
	Refleft='.left'
}
else if(document.layers){  // si se trata de Netscape 4
	Refcapa='document.'
	Refestilo=''
	Refwidth='.offsetWidth'
	Refheight='.offsetHeight'
	Reftop='.top'
	Refleft='.left'
}
else if(document.all){ // si se trata de Internet Explorer 4
	Refcapa=''
	Refestilo='.style'
	Refwidth='.offsetWidth'
	Refheight='.offsetHeight'
	Reftop='.pixelTop'
	Refleft='.pixelLeft'
}

<!-- FUNCIONES AUXILIARES -->
function movercapa(capa){
	//eval(Refcapa+capa+Refestilo+Refleft+'='+parseInt(x))
	if ((document.body.clientHeight/2) < 200)
	{
		var limiteSup = document.body.scrollTop + (document.body.clientHeight/2) + 50
	}
	else
	{
		var limiteSup = document.body.scrollTop + (document.body.clientHeight/2)
	}
	eval(Refcapa+capa+Refestilo+Reftop+'='+parseInt(limiteSup)+';')
}

function hacerVisible(capa)
{
	eval(Refcapa+capa+Refestilo+".visibility='visible'");
}

function Cerrar(div)
{
	document.getElementById(div).innerHTML='';
	eval(Refcapa+div+Refestilo+".visibility='hidden'");
	//document.getElementById(div).style.visibility = "hidden";
}