function pt_distritos_update_concelhos(path, nome, distrito, update_freguesias)
	{
	var func = 'pt_distritos_update_concelhos_exec("'+path+'", "'+nome+'", "'+update_freguesias+'");';
	var script = path+"pt_distritos_concelhos.js.php?d="+distrito+"&nc="+Math.random(0, 10000);
	include_runtime_javascript(script, func) ;
	}

function pt_distritos_update_concelhos_exec(path, nome, update_freguesias)
	{
	var html = "";
	var concelhos = pt_distritos_concelhos_arr();
	
	var m = "";
	if(update_freguesias=='1') 
		{
		m = 'onchange="pt_distritos_update_freguesias(\''+path+'\', \''+nome+'\', this.value);"';
		pt_distritos_update_freguesias(path, nome, 0);
		}
	
	html += "<select name='"+nome+"_d_c' "+m+">";
	for (c in concelhos)	
		html += "<option value='"+c+"'>"+concelhos[c]+"</option>";
	html += "</select>";
	document.getElementById(nome+"_span_d_c").innerHTML = html;
	}
	
function pt_distritos_update_freguesias(path, nome, concelho)
	{
	var func = 'pt_distritos_update_freguesias_exec("'+nome+'");';
	var script = path+"pt_distritos_freguesias.js.php?c="+concelho+"&nc="+Math.random(0, 10000);
	include_runtime_javascript(script, func) ;
	}

function pt_distritos_update_freguesias_exec(nome)
	{
	var html = "";
	var freguesias = pt_distritos_freguesias_arr();
	html += "<select name='"+nome+"_d_f'>";
	for (c in freguesias)	
		html += "<option value='"+c+"'>"+freguesias[c]+"</option>";
	html += "</select>";
	document.getElementById(nome+"_span_d_f").innerHTML = html;
	}