// JavaScript Document
function LlenarCombo(json, combo){
	combo.options[0] = new Option('Seleccione uno','0');
	for (var i=0; i<json.length; i++){
		texto= json[i][1];
		
		texto = texto.replace(/&aacute;/g,"á");
		texto = texto.replace(/&eacute;/g,"é");
		texto = texto.replace(/&iacute;/g,"í");
		texto = texto.replace(/&oacute;/g,"ó");
		texto = texto.replace(/&uacute;/g,"ú");
		texto = texto.replace(/&ntilde;/g,"ñ");
		texto = texto.replace(/&Ntilde;/g,"N");
		
		combo.options[combo.length] = new Option(texto, json[i][0] )
	}
}

function carga_pais(id, comboDestino){
	combo2 = document.getElementById(comboDestino);
	combo2.disabled=true;
	limpiaCombo(combo2);
	$.ajax({
		type: 'get',
		dataType: 'json',
		url: '/generajsCiudad.php',
		data: {pais: id},
		success: function (datos){
			LlenarCombo(datos, combo2);
			combo2.disabled=false;
		},
		error: function(request,error){
			alert("Se generó un error de tipo\n" + error);
			}
	})
}

function limpiaCombo(combo){
	while(combo.length>0) {
		combo.remove(combo.length-1);
	}
}
