function NuevoAjax(){
	var 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 Mostrar_Form_submit(url,id,valores){
	var contenido;
	contenido = document.getElementById(id);

	ajax=NuevoAjax();
	ajax.open("POST", url,true);
	ajax.onreadystatechange=function(){
		if(ajax.readyState==1){
			contenido.innerHTML = "Cargando...";
			contenido.style.background = "url('img/indicator.gif') center center no-repeat";
		}else if(ajax.readyState==4){
			if(ajax.status==200){
				contenido.innerHTML = ajax.responseText;
				contenido.style.background = "url('loaded.gif') center center no-repeat";
			}else if(ajax.status==404){
				contenido.innerHTML = "La p&aacute;gina no existe";
				contenido.style.background = "url('loaded.gif') center center no-repeat";
			}else{
				contenido.innerHTML = "Error:".ajax.status;
				contenido.style.background = "url('loaded.gif') center center no-repeat";
			}
		}
	}
    ajax.setRequestHeader('Content-Type','application/x-www-form-urlencoded');
    ajax.send(valores);
}


function Cargar(url,id,image,ide){
	var contenido;
	var header;
	contenido = document.getElementById(id);
	header = document.getElementById(ide);

	ajax=NuevoAjax();
	ajax.open("GET",url,true);
	ajax.onreadystatechange=function(){
		if(ajax.readyState==1){
			contenido.innerHTML = "Cargando...";
			header.innerHTML = "";
			contenido.style.background = "url('images/indicator.gif') center center no-repeat";
			contenido.style.height = "50";
		}else if(ajax.readyState==4){
			if(ajax.status==200){
				contenido.up = false;
				contenido.down = false;
				contenido.fast = false;
				contenido.style.top = "0";
				contenido.innerHTML = ajax.responseText;
				contenido.style.height = "auto";
				if (url == "contenido/puzzle.php") {
					header.innerHTML = "";
					header.style.height = "0";
					header.style.display = "none";
					document.getElementById('contenido').style.height = "430px";
					document.getElementById('contenido').style.marginLeft = "0";
					document.getElementById('contenido').style.width = "auto";
					document.getElementById('myContent').style.width = "auto";
					document.getElementById('easyscroll').style.height = "430px";
					document.getElementById('scroll').style.display = "none";
					document.getElementById('logos').style.display = "none";
				} else {
					header.innerHTML = "<img src='" + image + "'>";
					header.style.height = "29";
					header.style.display = "";
					document.getElementById('contenido').style.height = "330px";
					document.getElementById('contenido').style.marginLeft = "85px";
					document.getElementById('contenido').style.width = "335px";
					document.getElementById('myContent').style.width = "335px";
					document.getElementById('easyscroll').style.height = "330px";
					document.getElementById('scroll').style.display = "";
					document.getElementById('logos').style.display = "";
				}
				contenido.style.background = "url('loaded.gif') center center no-repeat";
			}else if(ajax.status==404){
				contenido.innerHTML = "La p&aacute;gina no existe.";
				contenido.style.background = "url('loaded.gif') center center no-repeat";
			}else{
				contenido.innerHTML = "Error:".ajax.status;
				contenido.style.background = "url('loaded.gif') center center no-repeat";
			}
		}
	}
	ajax.send(null);
}

