var campos_help=new Array();
campos_help['pass']=false;
campos_help['old_pass']=false;
function usuarioFoco() {
	document.getElementById("tr_verificar").style.display = "block";
}
function disponibilidadRequest(){
	document.getElementById("spanProcessing").innerHTML =" Verificando...<br>&nbsp;";
	var url = 'http://www.argentina.com/passport2/procesar/checkusr.php';
	var strName = document.form_usuario.username.value;
	var usr_captcha = document.form_usuario.usr_captcha.value;
	var strParams = "username="+strName+"&usr_captcha="+usr_captcha;
	var loader1 = new net.ContentLoader(url,CreateScript,null,"POST",strParams);
	return false;
}
function modifLoginRequest(){
	document.getElementById("spanProcessing").innerHTML =" Verificando...<br>&nbsp;";
	var url = 'http://www.argentina.com/passport2/procesar/login_usuario.php';
	var strName = document.form_login.username.value;
	var strPass = document.form_login.pass.value;	
	var strParams = "username="+strName+"&pass="+strPass;
	var loader1 = new net.ContentLoader(url,CreateScript,null,"POST",strParams);
	return false;
}
function CreateScript(){
	strText = this.req.responseText;
	eval(strText);
}
function noAlternativaChange() {
	if (document.form_usuario.no_alternativa.checked) {
		document.form_usuario.email.disabled="disabled";
		document.form_usuario.email2.disabled="disabled";
		alert("AVISO: Si no proporciona ningun E-mail no será posible recuperar su contraseña en caso de olvido de la misma.");
	}
	else {
		document.form_usuario.email.disabled="";
		document.form_usuario.email2.disabled="";
	}
}
function help(campo) {
	if (campos_help[campo]) {
		document.getElementById("help_"+campo).style.display = "none";
		campos_help[campo]=false;
	}
	else {
		document.getElementById("help_"+campo).style.display = "block";
		campos_help[campo]=true;
	}
}
function verClaveOpcionalChange() {
	if (document.form_usuario.ver_clave_opcional.checked) {
		document.getElementById("tr_opcional1").style.display = "block";
		document.getElementById("tr_opcional2").style.display = "none";
	}
	else {
		document.getElementById("tr_opcional2").style.display = "block";
		document.getElementById("tr_opcional1").style.display = "none";
	}
}
function ChangePicture(PicName, PicObject) {

	window.document.images[PicName].src = PicObject.src;

}
standard = new Image;
unsecure = new Image;
secure = new Image;
highlysecure = new Image;

standard.src = "/images/default.gif";
unsecure.src = "/images/bajo.gif";
secure.src = "/images/medio.gif";
highlysecure.src = "/images/alto.gif";



function checkInput(hilfe, picture) {
	var TestNumberOfChars = false;
	var TestUppercaseChars = false;
	var TestLowercaseChars = false;
	var TestDigits = false;
	var TestSpecialChars = false;
	var TestCounter = false;
	var TestWhiteSpaces = false;
	var TestSecondPassword = false;
	var counter = 0;
//	hilfe = window.document.form_usuario.passwd.value;
	
	/* Check if the password contains any words from personal data */
	testhilfe = hilfe.toLowerCase();
	/* Check if length of password is greather then 8 */
	
	if(hilfe.length >= 8) {
		if(!TestNumberOfChars) {		// do it only if the counter is 8, if it's greather, the TestNumberOfChars will be true and the right image is shown
			TestNumberOfChars = true;
		}
	} else {
		TestNumberOfChars = false;
	}
	
	/* Check for minimum of 2 uppercase Letters */
	if(hilfe.match(/[A-Z].*[A-Z]/)) {
		TestUppercaseChars = true;
	} else {
		TestUppercaseChars = false;
	}
	
	/* Check for minimum of 2 lowercase letters */
	if(hilfe.match(/[a-z].*[a-z]/)) {
		TestLowercaseChars = true;
	} else {
		TestLowercaseChars = false;
	}

	
	/* Check for minimum of 2 digits */
	if(hilfe.match(/[0-9].*[0-9]/)) {
		TestDigits = true;
	} else {
		TestDigits = false;
	}
	
	
	/* Check for minimum of 2 special chars */
	var specCharCounter = 0;
	if(hilfe.length > 0) {
		characters = hilfe.split("");
		for(var i = 0; i < characters.length; i++) {
			singleChar = characters[i];
			if(singleChar.match(/[^a-zA-Z0-9]/)) {
				specCharCounter++;
			}
		}
		if(specCharCounter >= 2) {
			TestSpecialChars = true;
		} else {
			TestSpecialChars = false;
		}
	}
	
	/* Check for whitespaces and ESC-Sequences */
	if(hilfe.match(/\s/)) {
		TestWhiteSpaces = true;
	} else {
		TestWhiteSpaces = false;
	}
	
	/* Check for minimum of 2 true ifs */
	if(TestUppercaseChars) { counter++;}
	if(TestLowercaseChars) { counter++;}
	if(TestDigits)         { counter++;}
	if(TestSpecialChars)   { counter++;}
	if((counter >= 2) && !TestWhiteSpaces) {
		if(!TestCounter) {
			TestCounter = true;
		}
	} else {
		TestCounter = false;
	}
var zaehler = 0;
if(TestCounter) { zaehler++;}
if(counter == 3) { zaehler++;}
if(TestNumberOfChars) { zaehler++;}

if(zaehler == 0) {
	ChangePicture(picture, standard);
}
if(zaehler == 1) {
	ChangePicture(picture, unsecure);
}
if(zaehler == 2) {
	ChangePicture(picture, secure);
}
if(zaehler == 3) {
	ChangePicture(picture, highlysecure);
}
if (zaehler > 0){ return true; }
else { return false; }
	
}
function fillDropArea(selElem) {
	if (selElem.selectedIndex>0 && selElem.selectedIndex!=selElem.options.length-1) {
		opt_Arr = ocupacion_Arr[selElem[selElem.selectedIndex].value];
		var objDDL = document.forms['form_usuario'].elements['area_sel'];
		objDDL.options.length = 0;
		objDDL.style.display="inline";		
		for (i=1;i<opt_Arr.length;i++) {
			theText = opt_Arr[i];
			theValue = String(i);
			var option = new Option(theText,theValue);
			try {
				objDDL.add(option,null);
			}
			catch (e) {
				objDDL.add(option,-1);
			}
			if (area_value!='' && theValue==area_value) {
				objDDL.options[i-1].selected=true;
			}
		}
	}
	else {
		var objDDL = document.forms['form_usuario'].elements['area_sel'].style.display="none";
	}
}
function updProvincia(pais) {
	//	Para argentina mostrar desplegable de provincias, para el resto text input
	//document.getElementById('tr_provincia').style.display='block';
	document.getElementById('ciudad_sel').style.display="none";
	mostrarCiudadTxt();
	if (pais=='54') {
		document.forms['form_usuario'].elements['provincia_sel'].style.display='inline';
		document.forms['form_usuario'].elements['provincia_txt'].style.display='none';
	}
	else {
		document.forms['form_usuario'].elements['provincia_sel'].style.display='none';
		document.forms['form_usuario'].elements['provincia_txt'].style.display='inline';
		document.forms['form_usuario'].elements['provincia_txt'].focus();
	}
}
function FillDropDown(){
	var xmlDoc = this.req.responseXML.documentElement;
	var xSel = xmlDoc.getElementsByTagName('selectElement')[0];
	var strFName = xSel.childNodes[0].firstChild.nodeValue;
	var strEName = xSel.childNodes[1].firstChild.nodeValue;
	var objDDL = document.forms[strFName].elements[strEName];
	objDDL.options.length = 0;
	var xRows = xmlDoc.getElementsByTagName('entry');
	if (xRows.length==1) {
		//	no hay elementos en la base para esta opcion
		if (document.getElementById('provincia_sel')[document.getElementById('provincia_sel').selectedIndex].value=="2") {
			document.getElementById('ciudad_txt').style.display="inline";
			document.getElementById('ciudad_txt').value="Capital Federal";
			document.getElementById('ciudad_txt').disabled="disabled";
			document.getElementById('ciudad_sel').style.display="none";
		}
		else {
			mostrarCiudadTxt();
			//document.getElementById('ciudad_txt').style.display="inline";
			//document.getElementById('ciudad_txt').disabled="";			
			//document.getElementById('ciudad_txt').value="";
		}
	}
	else {
		document.getElementById('ciudad_txt').style.display="none";
	}
	for(i=0;i<xRows.length;i++){
		var theText = xRows[i].childNodes[0].firstChild.nodeValue;
		var theValue = xRows[i].childNodes[1].firstChild.nodeValue;
		var option = new Option(theText,theValue);
		try{
			objDDL.add(option,null);
		}catch (e){
			objDDL.add(option,-1);
		}
		if ((ciudad_value!='') && (theValue==ciudad_value)) {
			objDDL.options[i].selected=true;
		}
	}
	if (ciudad_value=='') {
		objDDL.options[0].selected=true;
	}
	else if (ciudad_value=='-1') {
		//	Venia seleccionado Otra de un rebote
		 mostrarCiudadTxt();
	}
}
function mostrarCiudadTxt() {
	//	Revelar el campo de texto de ciudad y habilitarlo si la seleccionada no es Capital
	document.getElementById('ciudad_txt').style.display="inline";
	if (document.getElementById('provincia_sel')[document.getElementById('provincia_sel').selectedIndex].value!="2") {
		document.getElementById('ciudad_txt').disabled="";	
	if (document.getElementById('ciudad_txt').value=="Capital Federal") {
		//	resetear valor solo si estaba cargado Capital
		document.getElementById('ciudad_txt').value="";
	}
	}
}
function updCiudadArg(oElem, oTarget) {
	//	Provincia argentina seleccionada:
	//	llenar el campo de ciudad dinamicamente
	var strValue = oElem.options[oElem.selectedIndex].value;
	if (strValue=='NINGUNA') {
		document.getElementById('ciudad_sel').style.display="none";
	}
	else {
		var url = "procesar/get_ciudades.php";
		var strParams = "q=" + strValue + "&f=" + oTarget.form.name + "&e=" + oTarget.name;
		var loader1 = new net.ContentLoader(url,FillDropDown,null,"POST",strParams);
		document.getElementById('ciudad_sel').style.display="inline";
		document.getElementById('ciudad_txt').style.display="none";
	}
}
function updCiudadTxt(oElem) {
	var seleccionada= oElem.options[oElem.selectedIndex].value;
	if (seleccionada=='-1') {
		document.getElementById('ciudad_txt').style.display="inline";
		document.getElementById('ciudad_txt').disabled="";			
		document.getElementById('ciudad_txt').value="";
	}
	else {
		document.getElementById('ciudad_txt').style.display="none";
	}
}
