function cargar_ciudad(select, ruta){
	if (select.value > 0){
		document.getElementById('img_ajax').style.display = 'block';

		createXMLHttpRequest();
		xmlHttp.onreadystatechange = handle_cargar_ciudad;
		xmlHttp.open('GET', ruta+'?Id='+select.value, true);
		xmlHttp.send(null);
	} else {
		var mselect = document.getElementById('ciudad');
		mselect.options.length = null;
		mselect.options[0] = new Option('--- ciudad ---');
		mselect.options[0].value = 0;
	}
}
//--------------------------------------------------------
function handle_cargar_ciudad(){
	if(xmlHttp.readyState == 4){
		if(xmlHttp.status == 200){
			accion_cargar_ciudad();
		} else {
			alert("Error mientras se realizaba el proceso.");
		}
	}
}
//--------------------------------------------------------
function accion_cargar_ciudad(){
	var response = xmlHttp.responseXML;

	if(response){
		document.getElementById('img_ajax').style.display = 'none';

		var results = response.getElementsByTagName('resultado');
		var valores = results[0].getElementsByTagName('valor');
		var codigos = results[0].getElementsByTagName('id');
		var sciudad = document.getElementById('ciudad');

		sciudad.options.length = null;
		if (codigos.length > 0){
			for(i=0;i<codigos.length;i++){
				sciudad.options[i] = new Option(valores[i].firstChild.nodeValue);
				sciudad.options[i].value = codigos[i].firstChild.nodeValue;
			}
		} else {
			sciudad.options[0] = new Option('--- ciudad ---');
			sciudad.options[0].value = 0;
		}
	}
}