	var naciones = new Array();
	var provincias = new Array();
	var municipios = new Array();


		function rellenar_nacion(posicion, id, nombre){
			var linea_nacion = new Array(2);
			linea_nacion[0] = id;
			linea_nacion[1] = nombre;
			naciones[posicion] = linea_nacion;
		}

		function rellenar_provincias(posicion, id, nombre, arrayMunicipios){
			linea_provincia = new Array(3);
			linea_provincia[0] = id;
			linea_provincia[1] = nombre;
			linea_provincia[2] = arrayMunicipios;
			municipios[posicion] = linea_provincia;
		}

		function rellenar_municipios_provincia(posicion, id, nombre){
			var linea_municipio = new Array(2);
			linea_municipio[0] = id;
			linea_municipio[1] = nombre;
			municipios_provincia[posicion] = linea_municipio;
		}

		function inicializa_municipio(idMunicipio){
			municipioSelect = document.getElementById("selectCity");
			ciudadText = document.getElementById("textCity");

			var tam = municipioSelect.length;
			for (var j = 1; j < tam ; j++){
				if(municipioSelect.options[tam-j].value == idMunicipio){
						municipioSelect.options[tam-j].selected=true;
						break;							
				}
			}
			ciudadText.disabled=true; 				
		}

		function inicializa_provincia(idProvincia){
			provinciaSelect = document.getElementById("selectState");
			ciudadSelect = document.getElementById("selectCity");
			ciudadText = document.getElementById("textCity");

			var tam = provinciaSelect.length;
			for (var j = 1; j < tam ; j++){
				if(provinciaSelect.options[tam-j].value == idProvincia){
						provinciaSelect.options[tam-j].selected=true;
						break;							
				}
			}
					
			ciudadSelect.disabled=false; 				
			ciudadText.disabled=true; 				
		}


		function inicializa_pais(idPais){
			
			 $("selectCountry").value = idPais ;
			provinciaSelect = document.getElementById("selectState");
			provinciaText = document.getElementById("textState");
			ciudadSelect = document.getElementById("selectCity");
			ciudadText = document.getElementById("textCity");
			if ( idPais == 69 ) {
				provinciaSelect.disabled=false; 				
				provinciaText.disabled=true; 				
				ciudadSelect.disabled=true; 				
				ciudadText.disabled=true; 		
			
			} else {
				provinciaSelect.disabled=true; 				
				provinciaText.disabled=false; 				
				ciudadSelect.disabled=true; 				
				ciudadText.disabled=false; 	
			}
			return;
		}


		function establece_fecha(dia,mes,anho){
			daySelect = document.getElementById("selectDay");
			monthSelect = document.getElementById("selectMonth");
			yearSelect = document.getElementById("selectYear");

			var tam = daySelect.length;
			for (var j = 1; j < tam ; j++){
				if(daySelect.options[tam-j].value == dia){
						daySelect.options[tam-j].selected=true;
						break;							
				}
			}
					
			tam = monthSelect.length;
			for (var j = 1; j < tam ; j++){
				if(monthSelect.options[tam-j].value == mes){
						monthSelect.options[tam-j].selected=true;
						break;							
				}
			}
					
			tam = yearSelect.length;
			for (var j = 1; j < tam ; j++){
				if(yearSelect.options[tam-j].value == anho){
						yearSelect.options[tam-j].selected=true;
						break;							
				}
			}
		}		


		function inicializa_fechas(){
			daySelect = document.getElementById("selectDay");
			monthSelect = document.getElementById("selectMonth");
			yearSelect = document.getElementById("selectYear");

			for(var i=1;i<=31;i++){
					var opt = new Option (i);
					daySelect.options[i] = opt;
					daySelect.options[i].value = i;
			}

			for(var i=1;i<=12;i++){
					var opt = new Option (i);
							
					switch(i){
						case 1: opt= new Option ("Enero"); break;
						case 2: opt= new Option ("Febrero"); break;
						case 3: opt= new Option ("Marzo"); break;
						case 4: opt= new Option ("Abril"); break;
						case 5: opt= new Option ("Mayo"); break;
						case 6: opt= new Option ("Junio"); break;
						case 7: opt= new Option ("Julio"); break;
						case 8: opt= new Option ("Agosto"); break;
						case 9: opt= new Option ("Septiembre"); break;
						case 10: opt= new Option ("Octubre"); break;
						case 11: opt= new Option ("Noviembre"); break;
						case 12: opt= new Option ("Diciembre"); break;
					}
									
					monthSelect.options[i] = opt;
					monthSelect.options[i].value = i;
			}

			for(var i=1900;i<=2005;i++){
					var opt = new Option (i);
					yearSelect.options[i-1899] = opt;
					yearSelect.options[i-1899].value = i;
			}

		}

	function selectRadioByName(radioGroup, name)
	{
		if (typeof(radioGroup.length) == "undefined")
			return radioGroup.checked = true;
	
		for (var i = 0; i < radioGroup.length; i++)
		{
			if (radioGroup[i].value == name)
				return radioGroup[i].checked = true;
		}
	
		return false;
	}	

function actualiza_municipios(){
 	if ($F('selectState' ) > '0' ) {
		$('selectState' ).disabled = false;
		$('selectCity' ).disabled = false;		
		var objDrz = new drzJs() ;
		objDrz.changeSelectContent(  $("selectCity") ,'0:-- Cargando Municipios --' ) ;
		$('ajWaitF').innerHTML= ' <img src="/imagenes/wait.gif" height="16" width="16" style="vertical-align: middle;"/>' ;		
		var myAjax = new Ajax.Request(
		 '/ajax/ajax.php', 
		{
			method: 'post', 
			parameters: 'accion=municipios&id=' + $F("selectState"), 
			onComplete: function( valor) {
 				var objDrz = new drzJs() ;
				objDrz.changeSelectContent(  $("selectCity") , valor.responseText , function() { $('ajWaitF').innerHTML= ''  }) ; 
				
			
			}
		});
	} else {
		$('selectState' ).disabled = true;
		$('selectCity' ).disabled = true;			
	}
	
	

	
	
	
	
	
	return ;
	
	 

	

}

	function onChangeListener(source){

		if(source=="selectPais"){
			paisSelect = document.getElementById("selectCountry");
			provinciaSelect = document.getElementById("selectState");
			municipioSelect = document.getElementById("selectCity");
			provinciaText = document.getElementById("textState");
			municipioText = document.getElementById("textCity");
			
		   if (paisSelect.value != 0 && paisSelect.value==idPaisDefecto){
				provinciaSelect.disabled=false;
				provinciaSelect.value = '0';
				provinciaText.value=""; 				
				provinciaText.disabled=true; 				
				municipioText.value=""; 				
				municipioText.disabled=true; 				
				municipioSelect.value = '0';
		   }
			else{
				provinciaSelect.disabled=true;
				provinciaSelect.options[0].selected=true;
				provinciaText.disabled=false;
										
				municipioSelect.disabled=true;
				municipioSelect.options[0].selected=true;
				municipioText.disabled=false;
			}
		}

		if(source=="selectProvincia"){
			actualiza_municipios();
		}
	}
