function js_poblarLimpiarProvincia ()
{
	selProvincia = document.getElementById ('pr');
	while (selProvincia.options [1])
	{
		selProvincia.options [1] = null;
	}
	selProvincia [0] = new Option ("- todas las comunidades -", 0, true);
}

function js_poblarProvinciaPorComunidad ()
{
	js_poblarLimpiarProvincia ()
	selComunidad = document.getElementById ('au');
	selProvincia = document.getElementById ('pr');
	pos = 1;
	for (i=0; i<provincias.length; i++)
	{
		selProvincia.options [0] = new Option ("- todas las provincias -", "0", true);
		if (provincias [i].substr (0, 2) == selComunidad.options [selComunidad.selectedIndex].value)
		{
			selProvincia.options [pos++] = new Option (provincias [i].substr (12), provincias [i].substr (3, 2));
		}
	}
	selProvincia.selectedIndex = 0;
}

function js_rellenarprovincia (prId)
{
	if (prId.length < 2) prId = '0' + prId;
	js_poblarLimpiarProvincia ()
	document.getElementById('cp').value='';
	selComunidad = document.getElementById ('au');
	selProvincia = document.getElementById ('pr');
	pos = 1;
	for (i=0; i<provincias.length; i++)
	{
		if (provincias [i].substr (3, 2) == prId)
		{
			for (j=0; j<selComunidad.options.length; j++)
			{
				if (selComunidad.options [j].value == provincias [i].substr (0, 2))
				{
					selComunidad.selectedIndex = j;
					break;
				}
			}
			js_poblarProvinciaPorComunidad ();
			prPos = 0;
			for (j=0; j<selProvincia.options.length; j++)
			{
				if (selProvincia.options [j].value == prId)
				{
					prPos = j;
					break;
				}
			}
			selProvincia.selectedIndex = prPos;
		}
	}
}

function js_acadPublTipos ()
{
	tipos = document.getElementById ('ti');
	if (tipos)
	{
		au = document.getElementById ('au');
		pr = document.getElementById ('pr');
		cp = document.getElementById ('cp');
		
		tipoSeleccionado = tipos.options [tipos.selectedIndex].value;
		if ((tipoSeleccionado == 0) || (tipoSeleccionado == 1) || (tipoSeleccionado == 4))
		{
			if (au) au.disabled = false;
			pr.disabled = false;
			cp.disabled = false;
		}
		else
		{
			if (au) au.options [0].selected = true;
			pr.options [0].selected = true;
			cp.value = '';
			if (au) au.disabled = true;
			pr.disabled = true;
			cp.disabled = true;
		}
	}
	
}