// JavaScript Document

function AJAX() {
	this.CARREGARDIV=CarregarDiv;
	function CarregarDiv (caminhoRetorno, idResposta, metodo, mensagem) {
		var conteudo = document.getElementById(idResposta)
		conteudo.innerHTML = mensagem;
		var xmlhttp = getXmlHttp();
		xmlhttp.open(metodo.toUpperCase(), caminhoRetorno,true);
		xmlhttp.onreadystatechange=function() {
			if (xmlhttp.readyState==4){
				var texto=xmlhttp.responseText;
				texto=texto.replace(/\+/g," ");
				texto=unescape(texto);
				var conteudo = document.getElementById(idResposta);
				conteudo.innerHTML = texto;
			}
		}
		xmlhttp.send(null);
	}

	this.CARREGARINPUT=CarregarInput;
	function CarregarInput (caminhoRetorno, idResposta, metodo, mensagem) {
		var conteudo = document.getElementById(idResposta)
		conteudo.innerHTML = mensagem;		
		var xmlhttp = getXmlHttp();
		xmlhttp.open(metodo.toUpperCase(), caminhoRetorno,true);
		xmlhttp.onreadystatechange=function() {
			if (xmlhttp.readyState==4){
			var texto=xmlhttp.responseText;
			texto=texto.replace(/\+/g," ");
			texto=unescape(texto);
			var conteudo = document.getElementById(idResposta);
			conteudo.value = texto;
			}
		}
		xmlhttp.send(null);
	}
}

function getXmlHttp() {
	var xmlhttp;
	try{
		xmlhttp = new XMLHttpRequest();
	}catch(ee){
		try{
			xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
		}catch(e){
			try{
				xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
			}catch(E){
				xmlhttp = false;
			}
		}
	}
	return xmlhttp;
} 

function CarregarConcelho() {

var ajax = new AJAX(); 
ajax.CARREGARDIV('inc/combos/concelho.php?distrito='+document.getElementById("dist").value,"CarregarConcelho","get",'A carregar...',false);
document.getElementById("Submit").disabled=true;
}

function VerificarPesquisa() {
	
	if (document.getElementById("conc").value == '...') {
		document.getElementById("Submit").disabled=true;
	} else {
		document.getElementById("Submit").disabled=false;
	}
	
}