function handleHttpResponse() { 
	if (http.readyState == 4) { 
		if (http.status == 200) { 
			if (http.responseText.indexOf('invalid') == -1) {
            	// Armamos un array, usando la coma para separar elementos
            	results = http.responseText.split(","); 
            	document.getElementById("campoMensaje").innerHTML = results[0];
            	enProceso = false;
          	}
       	}
    }
}

function codifica() {
    if (!enProceso && http) {
       var valor = escape(document.getElementById("correo").value);
       var url = "encoder.php?correo="+ valor;
       http.open("GET", url, true);
       http.onreadystatechange = handleHttpResponse;
       enProceso = true;
       http.send(null);
    }
}

function getHTTPObject() {
    var xmlhttp;
    //if (!xmlhttp && typeof XMLHttpRequest != 'undefined') {
       	try{
			if (window.XMLHttpRequest){
				xmlhttp  = new XMLHttpRequest( );
			}else if(window.ActiveXObject){
				xmlhttp  = new ActiveXObject("Msxml2.XMLHTTP");
				if (!xmlhttp){
					xmlhttp  = new ActiveXObject("Microsoft.XMLHTTP");
				}
			}
        	//xmlhttp = new XMLHttpRequest();
       	}catch (e){ 
	   		xmlhttp = false;
		}
    //}
    return xmlhttp;
}

var enProceso = false; // lo usamos para ver si hay un proceso activo
var http = getHTTPObject(); // Creamos el objeto XMLHttpRequest
