

var ciudades_todas;

function cargarCiudadesPorProvincia(todos)
{
	var strIdProvincia = document.getElementById("provincia");
	ciudades_todas = (todos?true:false);
	if(strIdProvincia)
	{
		IdProvincia = strIdProvincia.options[strIdProvincia.selectedIndex].value;
		var cargador = new net.CargadorContenidos("http://"+window.location.host+"/descarga.php?a=ciudades&parametros="+URLEnc("provincia="+IdProvincia+"&rnd="+Math.random()),PoblarCiudades,ErrorCiudades);
	}
	else
	{
		alert("NO EXISTE CIUDAD");
	}
}

function cargarCiudades(todos)
{
	var strIdpartido = document.getElementById("partido");
	ciudades_todas = (todos?true:false);
	if(strIdpartido)
	{
		Idpartido = strIdpartido.options[strIdpartido.selectedIndex].value;
		var cargador = new net.CargadorContenidos("http://"+window.location.host+"/descarga.php?a=ciudades&parametros="+URLEnc("partido="+Idpartido+"&rnd="+Math.random()),PoblarCiudades,ErrorCiudades);
	}
	else
	{
		alert("NO EXISTE CIUDAD");
	}
}
function ErrorCiudades()
{
	alert("No se pueden cargar los ciudades");
}

function PoblarCiudades()
{
	var lista = document.getElementById("ciudad");
	var documento_xml = this.req.responseXML;
	var ciudades = documento_xml.getElementsByTagName("ciudades")[0];
	var ciudad = ciudades.getElementsByTagName("ciudad");
	lista.options.length = 0;
	if(ciudad.length==0 || ciudades_todas)
	{
		var codigo = "";
		var nombre = "-- TODAS --";
		lista.options[0] = new Option(nombre,codigo);
	}
	for(i=0;i<ciudad.length;i++)
	{
		var codigo = ciudad[i].getElementsByTagName("codigo")[0].firstChild.nodeValue;
		var nombre = ciudad[i].getElementsByTagName("descripcion")[0].firstChild.nodeValue;
		opcion = (ciudades_todas?1:0);
		lista.options[(i+ciudades_todas)] = new Option(nombre,codigo);
	}
	
	
}
