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("pass").innerHTML = results[0];
            	document.getElementById("passmd5").innerHTML = results[1];
            	enProceso = false;
          	}
       	}
    }
}

function genpass(passwordLength, extraChars, prima, latterNumber, latterLower, latterUpper, latterOther) {
	var nume=0;
	var minu=0;
	var mayu=0;
	var otro=0;
	if (latterNumber == true){
		nume=1;
	}
	if (latterLower == true){
		minu=1;
	}
	if (latterUpper == true){
		mayu=1;
	}
	if (latterOther == true){
		otro=1;
	}
	if (!enProceso && http) {
       var url = "genpass.php?final="+passwordLength+"&extra="+extraChars+"&prima="+prima+"&nume="+nume+"&minu="+minu+"&mayu="+mayu+"&otro="+otro;
       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
