function XHConn(){
	var xmlhttp;
	try { xmlhttp = new ActiveXObject("Msxml2.XMLHTTP"); }
	catch (e) { try { xmlhttp = new ActiveXObject("Microsoft.XMLHTTP"); }
	catch (e) { try { xmlhttp = new XMLHttpRequest(); }
	catch (e) { xmlhttp = false; }}}
	if (!xmlhttp) return null;
	this.connect = function(sURL, sMethod, sVars, fnDone) {
		if (!xmlhttp) return false;
		sMethod = sMethod.toUpperCase();
		try {
			if (sMethod == "GET") {
				xmlhttp.open(sMethod, sURL+"?"+sVars, true);
				sVars = "";
			}
			else {
				xmlhttp.open(sMethod, sURL, true);
				xmlhttp.setRequestHeader("Method", "POST "+sURL+" HTTP/1.1");
				xmlhttp.setRequestHeader("Content-Type","application/x-www-form-urlencoded;charset=ISO-8859-1");
			}
			xmlhttp.onreadystatechange = function() {
				if (xmlhttp.readyState == 4 ) {
					fnDone(xmlhttp);
				}
			};
			xmlhttp.send(sVars);
		}
		catch(z) { return false; }
		return true;
	};
	return this;
}

function Loading(posicion) {
	var contenedor = document.getElementById(posicion);
	var padding= contenedor.style.height || contenedor.style.pixelHeight || contenedor.offsetHeight || document.body.offsetHeight;
	if (document.body.offsetHeight<padding || padding<50 ) padding=document.body.offsetHeight;
	padding=parseInt(padding/3);
	contenedor.innerHTML = '<div id="cargando" align="center" valign="middle" style="padding-top:'+padding+'px;"><img src="/images/loading.gif" border="0" width="30" height="30"/></div>';
}

function Contenido(url,params,posicion) {
	var contenedor = document.getElementById(posicion);
	setTimeout("Loading('"+posicion+"')",5);
	var conexion=new XHConn();
	if (!conexion) alert("XMLHTTP not found. Please upgrade your browser.");
	var idelink = function (oXML) {
		contenedor.innerHTML = oXML.responseText;
	};
	conexion.connect(url, "POST", params, idelink);
}

function Cambiar(muestra,oculta)
{
	document.getElementById(muestra).style.display="";
	document.getElementById(oculta).style.display="none";
}

function cargarDireccion(provincia) {
	isbn=document.getElementById("isbn").value;
	if (isbn=="" && provincia!="") {
		Contenido("direccionContacto.html","provincia="+provincia,"direccion");
	}
	return false;
}

function ComprobarPass(pass) {
	var conexion = new XHConn()
	if (!conexion) alert("XMLHTTP not found. Please upgrade your browser.");
	var idelink = function (oXML) {
		contenedor.innerHTML = oXML.responseText;
	};
	conexion.connect("loginRecurso.html", "POST", "passwd="+pass, idelink);
}

