function doInstrumentosQuimica(on){
	if (on==1)
	{
		document.getElementById('laboral1_instrumentos').disabled=false;
	} else {
		document.getElementById('laboral1_instrumentos').disabled=true;
		document.getElementById('laboral1_instrumentos').value='0';
	}
}

function doHemato(on){
	if (on==1)
	{
		document.getElementById('laboral1_hemato1').disabled=false;
	} else {
		document.getElementById('laboral1_hemato1').disabled=true;
		document.getElementById('laboral1_hemato1').value='0';
	}
}



function doInfoLab(on){
	if (on==1)
	{
		document.getElementById('soft1').style.display="";
		document.getElementById('soft2').style.display="";
	} else {
		document.getElementById('soft1').style.display="none";
		document.getElementById('soft2').style.display="none";
	}
}


function doProvincia(prov){
	if(prov.value=='1'){
		document.getElementById('prov2').style.display='table-row';
		document.getElementById('input-prov2').focus();
	}else{
		document.getElementById('prov2').style.display='none';
	}
}
	

function displayPersonal(){
	document.getElementById('personal').style.display='block';
	document.getElementById('laboral').style.display='none';
	document.getElementById('observaciones').style.display='none';		
	document.getElementById('leng1').style.backgroundColor='#fefefe';
	document.getElementById('leng2').style.backgroundColor='#efefef';
	document.getElementById('leng3').style.backgroundColor='#efefef';
	document.getElementById('link-leng1').style.fontWeight='bold';
	document.getElementById('link-leng2').style.fontWeight='normal';
	document.getElementById('link-leng3').style.fontWeight='normal';		
}



function displayLaboral(){
	if (validatorStep1.exec()) {
		var paises = document.getElementById("idpaisresidencia");
		var ciudad = document.getElementById("ciudad");
		if(paises.options[paises.selectedIndex].text == "Argentina" || paises.options[paises.selectedIndex].text == "México") {
			if (document.getElementById("provincia").value == ""){
					alert('"Provincia" es un campos requerido');
					document.getElementById("provincia").focus();			
					return false;
			} else if (document.getElementById("ciudad").value == "" && document.getElementById("ciudad").options[ciudad.selectedIndex].text == "Otra" && document.getElementById("ciudad_texto").value == ""){
					alert('"Otra Ciudad" es un campos requerido');
					document.getElementById("ciudad_texto").focus();			
					return false;
			} else if (document.getElementById("ciudad").value == "" && document.getElementById("ciudad").options[ciudad.selectedIndex].text != "Otra"){
					alert('"Ciudad" es un campos requerido');
					document.getElementById("ciudad").focus();			
					return false;
			}
		} else {
			if (document.getElementById("provincia_texto").value == "" || document.getElementById("ciudad_texto").value == "") {
				alert('"Provincia" y "Ciudad" son campos requeridos');
				document.getElementById("provincia_texto").focus();			
				return false;
			} 
		}
		document.getElementById('personal').style.display='none';
		document.getElementById('laboral').style.display='block';
		document.getElementById('observaciones').style.display='none';
		document.getElementById('leng2').style.backgroundColor='#fefefe';
		document.getElementById('leng1').style.backgroundColor='#efefef';
		document.getElementById('leng3').style.backgroundColor='#efefef';
		document.getElementById('link-leng2').style.fontWeight='bold';
		document.getElementById('link-leng1').style.fontWeight='normal';
		document.getElementById('link-leng3').style.fontWeight='normal';
	}
}

function displayObs(){
	if (validatorStep2.exec()) {
		var paises = document.getElementById("idpaislaboral1");
		var ciudad = document.getElementById("idciudad1");
		//var tipoLaboral = document.getElementById("laboral1_tipo");
		if(paises.options[paises.selectedIndex].text == "Argentina" || paises.options[paises.selectedIndex].text == "México") {
			if (document.getElementById("idprovincia1").value == ""){
				alert('"Provincia" es un campos requerido');
				document.getElementById("idprovincia1").focus();			
				return false;
			} else if (document.getElementById("idciudad1").value == "" && document.getElementById("idciudad1").options[ciudad.selectedIndex].text == "Otra" && document.getElementById("ciudad_laboral_texto").value == ""){
				alert('"Otra Ciudad" es un campos requerido');
				document.getElementById("ciudad_laboral_texto").focus();			
				return false;
			} else if (document.getElementById("idciudad1").value == "" && document.getElementById("idciudad1").options[ciudad.selectedIndex].text != "Otra"){
				alert('"Ciudad" es un campos requerido');
				document.getElementById("idciudad1").focus();			
				return false;
			}
		} else {
			if (document.getElementById("provincia_laboral_texto").value == "" || document.getElementById("ciudad_laboral_texto").value == "") {
				alert('"Provincia" y "Ciudad" son campos requeridos');
				document.getElementById("provincia_laboral_texto").focus();			
				return false;
			} 
		}

		if (document.getElementById("laboral1_tipo").value == '1' || document.getElementById("laboral1_tipo").value == '2'){
			if (document.getElementById("laboral1_glicemias").value == ""){
				alert('"Glicemias" es campo requerido');
				document.getElementById("laboral1_glicemias").focus();			
				return false;					
			}
		} else if (document.getElementById("laboral1_tipo").value == '3' || document.getElementById("laboral1_tipo").value == '4'){
			if (document.getElementById("laboral1_sangre").value == ""){
				alert('"Bolsas de Sangre" es campo requerido');
				document.getElementById("laboral1_sangre").focus();			
				return false;					
			}
		}

		document.getElementById('personal').style.display='none';
		document.getElementById('laboral').style.display='none';
		document.getElementById('observaciones').style.display='block';
		document.getElementById('leng2').style.backgroundColor='#efefef';
		document.getElementById('leng1').style.backgroundColor='#efefef';
		document.getElementById('leng3').style.backgroundColor='#fefefe';
		document.getElementById('link-leng2').style.fontWeight='normal';
		document.getElementById('link-leng1').style.fontWeight='normal';
		document.getElementById('link-leng3').style.fontWeight='bold';
	}
}

function doBloquesLab(tipo){
	switch(tipo.value){
		case '1':
			document.getElementById('div_teclab').style.display='block';
			document.getElementById('div_tecsangre').style.display='none';
			document.getElementById('div_techemato').style.display='block';
			document.getElementById('div_infolab').style.display='block';
			document.getElementById('div_comerc').style.display='block';
			break;
		case '2':
			document.getElementById('div_teclab').style.display='block';
			document.getElementById('div_tecsangre').style.display='none';
			document.getElementById('div_techemato').style.display='block';
			document.getElementById('div_infolab').style.display='block';
			document.getElementById('div_comerc').style.display='block';
			break;
		case '3':
			document.getElementById('div_teclab').style.display='none';
			document.getElementById('div_tecsangre').style.display='block';
			document.getElementById('div_techemato').style.display='none';
			document.getElementById('div_infolab').style.display='none';
			document.getElementById('div_comerc').style.display='none';
			break;
		case '4':
			document.getElementById('div_teclab').style.display='none';
			document.getElementById('div_tecsangre').style.display='block';
			document.getElementById('div_techemato').style.display='none';
			document.getElementById('div_infolab').style.display='none';
			document.getElementById('div_comerc').style.display='none';
			break;
		default:
			document.getElementById('div_teclab').style.display='none';
			document.getElementById('div_tecsangre').style.display='none';
			document.getElementById('div_techemato').style.display='none';
			document.getElementById('div_infolab').style.display='none';
			document.getElementById('div_comerc').style.display='none';
	}
}

function changeProvinciaTextoResidencia () {
	document.getElementById('provincia_laboral_texto').value = document.getElementById('provincia_texto').value;
}

function changeCiudadTextoResidencia () {
	document.getElementById('ciudad_laboral_texto').value = document.getElementById('ciudad_texto').value;
}




function getActualizarEventos(){
	var paises= document.getElementById("idpaisresidencia");
	var paisesLaborales= document.getElementById("idpaislaboral1");
	var ciudad= document.getElementById("ciudad");
	var ciudadLaborales= document.getElementById("idciudad1");
	ciudad.onchange=function(e) {changeCiudadLaboral();};
    ciudadLaborales.onchange= function(e){change();};
	// provincia, ciudad texto onchange
	document.getElementById("provincia_texto").onchange=function(e) {changeProvinciaTextoResidencia();};
	document.getElementById("ciudad_texto").onchange=function(e) {changeCiudadTextoResidencia();};
	if(paises.options[paises.selectedIndex].text != "Argentina" && paises.options[paises.selectedIndex].text != "México" && paises.options[paises.selectedIndex].value != "") {
		document.getElementById('provinciaTexto').style.display="";
		document.getElementById('ciudadTexto').style.display="";
		document.getElementById("provinciaCombo").style.display="none"; 
		document.getElementById("ciudadCombo").style.display="none";
		document.getElementById("provinciaComboError").style.display="none"; 
		document.getElementById("ciudadComboError").style.display="none";	
	}
	else{
		document.getElementById('provinciaTexto').style.display="none";
		document.getElementById("provinciaCombo").style.display=""; 
		document.getElementById("ciudadCombo").style.display="";
		document.getElementById("provinciaComboError").style.display=""; 
		document.getElementById("ciudadComboError").style.display="";  
		if (document.getElementById("ciudad").options[ciudad.selectedIndex].text == "Otra") {
			document.getElementById('ciudadTexto').style.display="";
		}
		else {
		  document.getElementById('ciudadTexto').style.display="none";
		}  
	}


	if(paisesLaborales.options[paisesLaborales.selectedIndex].text != "Argentina" &&  paisesLaborales.options[paisesLaborales.selectedIndex].text != "México" &&  paisesLaborales.options[paisesLaborales.selectedIndex].value != "") {
		document.getElementById('provinciaLaboral_Texto').style.display="";
		document.getElementById('ciudadLaboral_Texto').style.display="";
		document.getElementById("idprovincia1Combo").style.display="none"; 
		document.getElementById("idciudad1Combo").style.display="none";	
		document.getElementById("idprovincia1ComboError").style.display="none"; 
		document.getElementById("idciudad1ComboError").style.display="none";	
	}
	else {
		document.getElementById('provinciaLaboral_Texto').style.display="none";
		document.getElementById('ciudadLaboral_Texto').style.display="";
		document.getElementById("idprovincia1Combo").style.display=""; 
		document.getElementById("idciudad1Combo").style.display="";
		document.getElementById("idprovincia1ComboError").style.display=""; 
		document.getElementById("idciudad1ComboError").style.display="";  
	}



//     Seteo para cuando ingresa por primera vez
	var	provincia= document.getElementById("provincia");
	var selectedIndexProvinciaResidencia = provincia.selectedIndex;
	provincia.options[0] = new Option("Seleccione un Pais ..","");
	provincia.selectedIndex = selectedIndexProvinciaResidencia;

	var provincialaboral1= document.getElementById("idprovincia1");
	var selectedIndexProvinciaLaboral = provincialaboral1.selectedIndex;
	provincialaboral1.options[0] = new Option("Seleccione un Pais ..","");
	provincialaboral1.selectedIndex = selectedIndexProvinciaLaboral;

 	var ciudad= document.getElementById("ciudad");
 	var selectedIndexCiudadResidencia = ciudad.selectedIndex;
 	ciudad.options[0] = new Option("Seleccione una Provincia ..","");
	ciudad.selectedIndex = selectedIndexCiudadResidencia;

	var ciudadlaboral1= document.getElementById("idciudad1");
	var selectedIndexCiudadLaboral = ciudadlaboral1.selectedIndex;
	ciudadlaboral1.options[0] = new Option("Seleccione una Provincia ..","");
	ciudadlaboral1.selectedIndex = selectedIndexCiudadLaboral;

	document.getElementById("idpaisresidencia").onchange=function(e) {getProvincias();}; 
	document.getElementById("idpaislaboral1").onchange=function(e) {getProvinciasLaborales();}; 
	provincia.onchange=function(e) {getCiudades();};
	provincialaboral1.onchange=function(e) {getCiudadesLaborales();};
	document.getElementById("laboral1_tipo").onchange=function(e) {doBloquesLab(this);}; 
	document.frmBuscar.laboral1_quimica[0].onchange=function(e) {doInstrumentosQuimica(this.value);}; 
	document.frmBuscar.laboral1_quimica[1].onchange=function(e) {doInstrumentosQuimica(this.value);}; 
	document.frmBuscar.laboral1_hemato[0].onchange=function(e) {doHemato(this.value);};
	document.frmBuscar.laboral1_hemato[1].onchange=function(e) {doHemato(this.value);};  
	document.frmBuscar.laboral1_info[1].onchange=function(e) {doInfoLab(this.value);}; 
	document.frmBuscar.laboral1_info[0].onchange=function(e) {doInfoLab(this.value);}; 
// 	document.frmBuscar.laboral1_comercial[0].onchange=function(e) {doComercial(this.value);};
// 	document.frmBuscar.laboral1_comercial[1].onchange=function(e) {doComercial(this.value);};
	document.getElementById("laboral1_glicemias").options[0] = new Option("Seleccione..","");
	document.getElementById("laboral1_instrumentos").options[0] = new Option("Seleccione un Instrumento..","");
	document.getElementById("laboral1_hemato1").options[0] = new Option("Seleccione..","");
// 	document.getElementById("laboral1_comercial1").options[0] = new Option("Seleccione..","");
	document.getElementById("laboral1_glicemias").selectedIndex = 0;
	document.getElementById("laboral1_instrumentos").selectedIndex = 0;
	document.getElementById("laboral1_hemato1").selectedIndex = 0;
}



// Vista de actualización
function getViewUpdateForm(flagUpdate){
    var comboTipo=document.getElementById('laboral1_tipo');
    if(comboTipo.options[comboTipo.selectedIndex].value == 1 || comboTipo.options[comboTipo.selectedIndex].value == 2){
		document.getElementById('div_comerc').style.display="block";
		document.getElementById('div_infolab').style.display="block";
		document.getElementById('div_techemato').style.display="block";
		document.getElementById('div_teclab').style.display="block";

		if(document.frmBuscar.laboral1_quimica[1].checked == true || document.frmBuscar.laboral1_quimica[0].checked == false) {
			document.getElementById('laboral1_instrumentos').disabled=true;
		}
		if(document.frmBuscar.laboral1_hemato[1].checked == true || document.frmBuscar.laboral1_hemato[0].checked == false){
			document.getElementById('laboral1_hemato1').disabled=true;
		}
		if(document.frmBuscar.laboral1_info[0].checked == true){
			document.getElementById('soft1').style.display="";
			document.getElementById('soft2').style.display="";
		}
// 		if(document.frmBuscar.laboral1_comercial[1].checked == true || document.frmBuscar.laboral1_comercial[0].checked == false){
// 			document.getElementById('laboral1_comercial1').disabled=true;
// 		}
    }
    if(comboTipo.options[comboTipo.selectedIndex].value == 3 || comboTipo.options[comboTipo.selectedIndex].value == 4){
		document.getElementById('div_tecsangre').style.display="block";
    }
}



function getProvincias(){
  var paises= document.getElementById("idpaisresidencia");
  var pais=document.getElementById("idpaisresidencia").options[paises.selectedIndex].value;
  var paisesLaboral= document.getElementById("idpaislaboral1");
  var paisLaboralSeleccionado=document.getElementById("idpaislaboral1").options[paisesLaboral.selectedIndex].value;
  paisesLaboral.selectedIndex = paises.selectedIndex;
  if (document.getElementById("idpaisresidencia").options[paises.selectedIndex].text == "Argentina" || document.getElementById("idpaisresidencia").options[paises.selectedIndex].text == "México"){
		// Datos personales
	    document.getElementById('provinciaTexto').style.display="none";
		document.getElementById('ciudadTexto').style.display="none";
        document.getElementById('provincia_texto').value="";
		document.getElementById('ciudad_texto').value="";
		document.getElementById("provinciaCombo").style.display=""; 
		document.getElementById("ciudadCombo").style.display="";
		document.getElementById("provinciaComboError").style.display=""; 
		document.getElementById("ciudadComboError").style.display="";

		// Datos laborales
	    document.getElementById('provinciaLaboral_Texto').style.display="none";
		document.getElementById('ciudadLaboral_Texto').style.display="none";
        document.getElementById('provincia_laboral_texto').value="";
		document.getElementById('ciudad_laboral_texto').value="";
		document.getElementById("idprovincia1Combo").style.display=""; 
		document.getElementById("idciudad1Combo").style.display="";
		document.getElementById("idprovincia1ComboError").style.display=""; 
		document.getElementById("idciudad1ComboError").style.display="";

//          Inicializo los combos
	  	 var provincia= document.getElementById("provincia");
		 var ciudad = document.getElementById("ciudad");
         var provinciaLaborales= document.getElementById("idprovincia1");
		 var ciudadLaborales= document.getElementById("idciudad1");
		 provincia.options.length = 0;
		 provincia.selectedIndex = 0;
		 ciudad.options.length = 0;
         ciudad.options[0] = new Option("Seleccione Provincia ..","");
		 ciudad.selectedIndex = 0;
         provinciaLaborales.options.length = 0;
		 provinciaLaborales.selectedIndex = 0;
		 ciudadLaborales.options.length = 0;
		 ciudadLaborales.options[0] = new Option("Seleccione Provincia ..","");
		 ciudadLaborales.selectedIndex = 0;

		dojo.xhrGet({
				url: "/index.pl?_c=frontRegistracion&_t=registroFront&_a=getProvincia&pais="+pais,
				  timeout: 8000,
				  preventCache:true,
				  load: function(json_response, ioArgs) {
					json_response = eval('(' + json_response + ')');
					  if (json_response.status == 'ok') {
							 var arrayProvincia=json_response.provincias;
							 if(arrayProvincia.length >0){ 
									var cont=0;
									arrayProvincia.unshift({'id':"",'name':"Seleccione"});
									while( cont < arrayProvincia.length){ 
										  provincia.options[cont] = new Option(arrayProvincia[cont].name, arrayProvincia[cont].id); 
										  provinciaLaborales.options[cont] = new Option(arrayProvincia[cont].name, arrayProvincia[cont].id);  
										   cont++;  
										  }
							  }
					}       		
				  else {
					  if(json_response.status == 'error'){
						alert(json_response.descStatus);
						}
					  console.error("Error de sistema: ", json_response.status);
				  }
				},
				  error: function(err, ioArgs) {
				  console.info("HTTP status code: "+ ioArgs.xhr.status+" - err: " + err);
					return response;
				  }
			  });
		}
	else{
		// Datos personales
		document.getElementById("ciudad_texto").value="";
		document.getElementById("provincia_texto").value="";
	    document.getElementById('provinciaTexto').style.display="";
		document.getElementById('ciudadTexto').style.display="";
		document.getElementById("provinciaCombo").style.display="none"; 
		document.getElementById("ciudadCombo").style.display="none";
		document.getElementById("provinciaComboError").style.display="none"; 
		document.getElementById("ciudadComboError").style.display="none";
		document.getElementById("provincia").options.length = 0;
		document.getElementById("ciudad").options.length = 0;

		// Datos laborales
		document.getElementById("ciudad_laboral_texto").value = "";
		document.getElementById("provincia_laboral_texto").value = "";
	    document.getElementById('provinciaLaboral_Texto').style.display="";
		document.getElementById('ciudadLaboral_Texto').style.display="";
		document.getElementById("idprovincia1Combo").style.display="none"; 
		document.getElementById("idciudad1Combo").style.display="none";
		document.getElementById("idprovincia1ComboError").style.display="none"; 
		document.getElementById("idciudad1ComboError").style.display="none";
		document.getElementById("idprovincia1").options.length = 0;
		document.getElementById("idciudad1").options.length = 0;
  }
}


function getCiudades() {
	var provincia = document.getElementById("provincia");
	var provinciaSeleccionada = document.getElementById("provincia").options[provincia.selectedIndex].value;
	var provinciaLaboral = document.getElementById("idprovincia1");
	provinciaLaboral.selectedIndex = provincia.selectedIndex;

	var ciudades= document.getElementById("ciudad");
	var ciudadesLaborales= document.getElementById("idciudad1");
	 ciudades.options.length = 0
	 ciudades.selectedIndex = 0;
	 ciudadesLaborales.options.length = 0;
	 ciudadesLaborales.selectedIndex = 0;
	 document.getElementById('ciudadTexto').style.display="none";
     document.getElementById('ciudadLaboral_Texto').style.display="none";
     document.getElementById('ciudad_texto').value="";
	 document.getElementById('ciudad_laboral_texto').value="";
	dojo.xhrGet({
			  url: "/index.pl?_c=frontRegistracion&_t=registroFront&_a=getCiudad&provincia="+provinciaSeleccionada,
			  timeout: 8000,
   			  preventCache:true,
   			  load: function(json_response, ioArgs) {
   				 json_response = eval('(' + json_response + ')');
   				  if (json_response.status == 'ok') {
						var arrayCiudades=json_response.ciudades;
 						 if(arrayCiudades.length >0){ 
 								var cont=0;
								arrayCiudades.unshift({'id':"",'name':"Seleccione"});
 								while( cont < json_response.ciudades.length){ 
								  ciudades.options[cont] = new Option(arrayCiudades[cont].name, arrayCiudades[cont].id);  
								  ciudadesLaborales.options[cont] = new Option(arrayCiudades[cont].name, arrayCiudades[cont].id);
								  cont++;  
 								}
 						  }
				  }
   			  else {
 				  if(json_response.status == 'error'){
    					alert(json_response.descStatus);
				  }
   				  console.error("Error de sistema: ", json_response.status);
   			  }
 			},
			error: function(err, ioArgs) {
			console.info("HTTP status code: "+ ioArgs.xhr.status+" - err: " + err);
			  return response;
			}
   		  });
}



function changeCiudadLaboral() {
  	var ciudad= document.getElementById("ciudad");
	var ciudadSeleccionada=ciudad.selectedIndex;
    var ciudadLaboral=document.getElementById("idciudad1");
	ciudadLaboral.selectedIndex = ciudadSeleccionada;
	if (document.getElementById("ciudad").options[ciudad.selectedIndex].text == "Otra"){
		  document.getElementById('ciudadTexto').style.display="";
          document.getElementById('ciudadLaboral_Texto').style.display="";
	  }	
	else{
		document.getElementById('ciudadTexto').style.display="none";
		document.getElementById('ciudadLaboral_Texto').style.display="none";
		document.getElementById('ciudad_texto').value="";
		document.getElementById('ciudad_laboral_texto').value="";
       }
}



function change() {
  var ciudadLaboral=document.getElementById("idciudad1");
  var ciudadLaboralSeleccionada = ciudadLaboral.selectedIndex;
  if (document.getElementById("idciudad1").options[ciudadLaboral.selectedIndex].text == "Otra"){
	 document.getElementById('ciudadLaboral_Texto').style.display="";
  }
  else{
	  document.getElementById('ciudadLaboral_Texto').style.display="none";
	   document.getElementById('ciudad_laboral_texto').value="";
  }
}


function getProvinciasLaborales(){
var paises= document.getElementById("idpaislaboral1");
  var pais=document.getElementById("idpaislaboral1").options[paises.selectedIndex].value;
  if (document.getElementById("idpaislaboral1").options[paises.selectedIndex].text == "Argentina" || document.getElementById("idpaislaboral1").options[paises.selectedIndex].text == "México"){
	    document.getElementById('provinciaLaboral_Texto').style.display="none";
		document.getElementById('ciudadLaboral_Texto').style.display="none";
		document.getElementById('provincia_laboral_texto').value="";
		document.getElementById('ciudad_laboral_texto').value="";
		document.getElementById("idprovincia1Combo").style.display=""; 
		document.getElementById("idciudad1Combo").style.display="";
		document.getElementById("idprovincia1ComboError").style.display=""; 
		document.getElementById("idciudad1ComboError").style.display="";  
			  //          Inicializo los combos
         var provinciaLaborales= document.getElementById("idprovincia1");
		 var ciudadLaborales= document.getElementById("idciudad1");
         provinciaLaborales.options.length = 0;
		 provinciaLaborales.selectedIndex = 0;
		 ciudadLaborales.options.length = 0;
         ciudadLaborales.options[0] = new Option("Seleccione Provincia ..","");
		 ciudadLaborales.selectedIndex = 0;
		 dojo.xhrGet({
 			 url: "/index.pl?_c=frontRegistracion&_t=registroFront&_a=getProvincia&pais="+pais,
 			  timeout: 8000,
  			  preventCache:true,
  			  load: function(json_response, ioArgs) {
  				 json_response = eval('(' + json_response + ')');
  				  if (json_response.status == 'ok') {
					var arrayProvinciasLaborales=json_response.provincias;
					if(arrayProvinciasLaborales.length >0){
					    var cont=0;
						arrayProvinciasLaborales.unshift({'id':"",'name':"Seleccione"});
						while(arrayProvinciasLaborales.length > cont){
						  provinciaLaborales.options[cont] = new Option(arrayProvinciasLaborales[cont].name, arrayProvinciasLaborales[cont].id);
						   cont++;  
						}
					}
				}
  			  else {
				  if(json_response.status == 'error'){
					alert(json_response.descStatus);
					}
  				  console.error("Error de sistema: ", json_response.status);
  			  }
			},
  			  error: function(err, ioArgs) {
			  console.info("HTTP status code: "+ ioArgs.xhr.status+" - err: " + err);
  				return response;
  			  }
  		  });
		}
	else{
		  document.getElementById("provincia_laboral_texto").value="";
		  document.getElementById("ciudad_laboral_texto").value="";
		  document.getElementById('provinciaLaboral_Texto').style.display="";
		  document.getElementById('ciudadLaboral_Texto').style.display="";
		  document.getElementById("idprovincia1Combo").style.display="none"; 
		  document.getElementById("idciudad1Combo").style.display="none";
		  document.getElementById("idprovincia1ComboError").style.display="none"; 
		  document.getElementById("idciudad1ComboError").style.display="none";
		  document.getElementById("idprovincia1").options.length = 0;
		  document.getElementById("idciudad1").options.length = 0; 
  }
}




function getCiudadesLaborales(){
  var provincia= document.getElementById("idprovincia1");
  var provinciaSeleccionada=document.getElementById("idprovincia1").options[provincia.selectedIndex].value;
  var ciudades= document.getElementById("idciudad1");
  ciudades.options.length = 0
  ciudades.selectedIndex = 0;
	document.getElementById('ciudadLaboral_Texto').style.display="none";
    document.getElementById('ciudad_laboral_texto').value=""
	dojo.xhrGet({
 			 url: "/index.pl?_c=frontRegistracion&_t=registroFront&_a=getCiudad&provincia="+provinciaSeleccionada,
  			  timeout: 8000,
   			  preventCache:true,
   			  load: function(json_response, ioArgs) {
   				 json_response = eval('(' + json_response + ')');
   				  if (json_response.status == 'ok') {
						 var arrayCiudadesLaborales= json_response.ciudades;
 						 if(arrayCiudadesLaborales.length >0){ 
 								 var cont=0;
								arrayCiudadesLaborales.unshift({'id':"",'name':"Seleccione"});
 								while(arrayCiudadesLaborales.length > cont){
								  ciudades.options[cont] = new Option(arrayCiudadesLaborales[cont].name, arrayCiudadesLaborales[cont].id);  
								   cont++; 
 								}
 						  }
				  }
   			  else {
 				  if(json_response.status == 'error'){
 					alert(json_response.descStatus);
 					}
   				  console.error("Error de sistema: ", json_response.status);
   			  }
 			},
   			  error: function(err, ioArgs) {
 			  console.info("HTTP status code: "+ ioArgs.xhr.status+" - err: " + err);
   				return response;
   			  }
   		  });
}

