// JavaScript Document

function checkeaCodigoCaptcha(codigo){
	//alert(codigo);
	var oXmlHttp = zXmlHttp.createRequest();
	oXmlHttp.open("get", "includes/ajax/comprueba_codigo_captcha.php?codigo=" + codigo, true);
	oXmlHttp.onreadystatechange = function () {
		if (oXmlHttp.readyState == 4) {
			if (oXmlHttp.status == 200) {
				//alert(oXmlHttp.responseText);
				if (oXmlHttp.responseText == 'existe') {
					alert('El código no es correcto. Por favor verifíquelo.');
					document.getElementById('codigo_captcha').focus();
					return false;
				} else {
					document.getElementById('comprueba_captcha').value= 'Si';
				}
			} else {
				alert(oXmlHttp.statusText);
			}
		}            
	};
	oXmlHttp.send(null);
}

function compruebaExistenciaDato(campo,dato) {
	var oXmlHttp = zXmlHttp.createRequest();
	oXmlHttp.open("get", "includes/ajax/comprueba_existencia_dato.php?campo=" + campo + "&dato=" + dato, true);
	oXmlHttp.onreadystatechange = function () {
		if (oXmlHttp.readyState == 4) {
			if (oXmlHttp.status == 200) {
				//alert(oXmlHttp.responseText);
				if (oXmlHttp.responseText == 'existe') {
					alert('Este ' + campo + ' ya existe. Por favor elija otro.');
					document.getElementById(campo).focus();
				}
			} else {
				//alert(oXmlHttp.statusText);
			}
		}            
	};
	oXmlHttp.send(null);
}


