// JavaScript Document

function nuevoAjax(){
	xmlhttp=false;
 	try {
 		xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
 	} catch (e) {
 		try {
 			xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
 		} catch (E) {
 			xmlhttp = false;
 		}
  	}

	if (!xmlhttp && typeof XMLHttpRequest!='undefined') {
 		xmlhttp = new XMLHttpRequest();
	}
	return xmlhttp;
}

function cargarContenido(url, idcontenedor){
	var contenedor;
	contenedor = document.getElementById(idcontenedor);
	var ajax=nuevoAjax();
	ajax.open("GET", url, false);
	ajax.onreadystatechange=function() {
		if (ajax.readyState==1) {
			contenedor.innerHTML = "<img src='/imagenes/cargando.gif' height=16 width=16 border=0 align=top>Cargando...";
		}
		if (ajax.readyState==4) {
			//alert(ajax.responseText);
			if(ajax.status==200){
					//mostramos los datos dentro de la div
					contenedor.innerHTML = ajax.responseText; 
			}else if(ajax.status==404){
					contenedor.innerHTML = "P&aacute;gina inexistente";
			}else{
					//mostramos el posible error
					contenedor.innerHTML = "Error:".ajax.status; 
			}			
	 	}
	}
	ajax.send(null);
}

