function validaPesquisa(){

	if(document.getElementById('tipo_id').selectedIndex <= 0) {
    alert("Por favor, seleccione o tipo de imóvel que pretende pequisar.");
    document.getElementById('tipo_id').focus();
    return false;
  }


  if(document.getElementById('concelho_id').selectedIndex <= 0) {
    alert("Por favor, seleccione o concelho que pretende pequisar.");
    document.getElementById('concelho_id').focus();
    return false;
  }

	
	if(document.getElementById('preco1').selectedIndex > document.getElementById('preco2').selectedIndex && document.getElementById('preco2').selectedIndex != 0) {
    alert("Por favor, seleccione preço máximo igual ou superior\nao preço mínimo.");
    document.getElementById('preco2').focus();
    return false;
  }
  
  if((document.getElementById('preco1').selectedIndex != 0) && document.getElementById('operacao').selectedIndex == 0) {
    alert("Por favor, seleccione a Transacção.");
    document.getElementById('operacao').focus();
    return false;
  }
  if((document.getElementById('preco2').selectedIndex != 0) && document.getElementById('operacao').selectedIndex == 0) {
    alert("Por favor, seleccione a Transacção.");
    document.getElementById('operacao').focus();
    return false;
  }
  
  return true;
}	

function validaPesquisaRapida(){
	if(document.getElementById('tipo_id').selectedIndex <= 0) {
    alert("Por favor, seleccione o Tipo de imóvel que pretende pequisar.");
    document.getElementById('tipo_id').focus();
    return false;
  }
  
  if(document.getElementById('concelho_id').selectedIndex <= 0) {
    alert("Por favor, seleccione o Concelho que pretende pequisar.");
    document.getElementById('concelho_id').focus();
    return false;
  }    	
  return true;
}	

function submitPesq(){	
	document.getElementById('origempesq').value = "pesquisa";
	document.getElementById('MostraEmpreend').value = "true";
	document.getElementById('escFormPesquisa').submit();
}


function OnChangeTipoid(strFirstOptionText) {
	valor = 3; //parseInt(document.getElementById('tipo_id').value);	
	var fileJs="";
	
	switch (valor){
		case 3:     //Escritorio
			fileJs ="escritorios";
			break;
		case 5:     //Armazem
			fileJs ="armazem";
			break;
		case 6:     //Loja
			fileJs ="lojas";
			break;
		case 7:     //Terreno
			fileJs ="terreno";
			break;
	}	
	
	/*if(document.getElementById('tipo_id').options[document.getElementById('tipo_id').selectedIndex].value == 0) {
		populateSelectEscritorios(document.getElementsByName("concelho_id")[0], new Array(), new Array(), strFirstOptionText);
	}
	else {	*/
		var head    = document.getElementsByTagName("head").item(0);
		var old     = document.getElementById("lastLoadedConcelhos");
		if(old)
			head.removeChild(old);

		script = document.createElement("script");
		script.src = "/js/fraccoesconcelhos/" + fileJs + ".js";	
		script.type = "text/javascript";
		script.defer = true;
		script.id = "lastLoadedConcelhos";
		void(head.appendChild(script));
	//}	
}



