function subBackWindow() {
  history.back();
}
function subPrintWindow() {
  window.print();
}
function subImagem(image, width, height) {
  parent.document.getElementById("imagemPrincipal").src = image;
  parent.document.getElementById("imagemPrincipal").width = width;
  parent.document.getElementById("imagemPrincipal").height = height;
}
function trim(string) {
  var re= /^\s*|\s*$/g;
  return string.replace(re,"");
}
function validateEmail(e) {
  if (e != "") {
    var objRegExp = /^.+@.+\..{2,3}$/;
    return objRegExp.test(e);
  } else {
    return true;
  }
}
function frmContactos_Validate() {
  if(trim(document.getElementById("Contactos1_tfNome").value) == "" || trim(document.getElementById("Contactos1_tfEmail").value) == "" || trim(document.getElementById("Contactos1_tfTelefone").value) == "" || trim(document.getElementById("Contactos1_tfAssunto").value) == "") {
    alert ("Não é possível concluír o processo.\nTodos os campos de preenchimento obrigatório.");
    return false;
  }
  if(!validateEmail(document.getElementById("Contactos1_tfEmail").value)) {
    alert("Não é possível enviar o formulário.\nIntroduza um endereço de e-mail válido.");
    return false;
  }
  return true;
}
function frmPesquisaRapida_Validate() {
  if(document.getElementById("PesquisaRapida1_tfReferencia").value == "") {
    if(document.getElementById("PesquisaRapida1_ddlFinalidade").value == "") {
      alert("Não é possível realizar a pesquisa.\nSeleccione a finalidade.");
      return false;
    } 
    if(document.getElementById("PesquisaRapida1_ddlTipoImovel").value == "") {
      alert("Não é possível realizar a pesquisa.\nSeleccione o tipo de imóvel.");
      return false;
    }
  }
  return true;
}
function frmVender_Validate() {
  if(trim(document.getElementById("VenderImovel1_tfNome").value) == "" || trim(document.getElementById("VenderImovel1_tfMorada").value) == "" || trim(document.getElementById("VenderImovel1_tfTelefone").value) == "" || 
     trim(document.getElementById("VenderImovel1_tfEmail").value) == "" || trim(document.getElementById("VenderImovel1_tfHorario").value) == "" || trim(document.getElementById("VenderImovel1_tfPreco").value) == "" ||
	 trim(document.getElementById("VenderImovel1_tfCaracteristicas").value) == "") {
	alert ("Não é possível concluír o processo.\nTodos os campos de preenchimento obrigatório.");
	return false;
  }
  if(!validateEmail(document.getElementById("VenderImovel1_tfEmail").value)) {
    alert("Não é possível enviar o formulário.\nIntroduza um endereço de e-mail válido.");
	return false;
  }
  return true;
}
function subCenterWindow(url, width, height, scr) {
  window.open(url, "", "status=1,scrollbars="+scr+",width="+width+",height="+height+",left="+(screen.width - width) / 2+",top="+(screen.height - height) / 2);
}
function frmWebFormImovel_Validate(f) {
  if(trim(document.getElementById("tfNome").value) == "" || trim(document.getElementById("tfTelefone").value) == "" || trim(document.getElementById("tfEmail").value) == "") {
	alert ("Não é possível concluír o processo.\nIntroduza os campos de preenchimento obrigatório.");
	return false;
  }
  if(!validateEmail(document.getElementById("tfEmail").value)) {
    alert("Não é possível enviar o formulário.\nIntroduza um endereço de e-mail válido.");
	return false;
  }
  return true;
}
function frmPainelNoticias_Submit(f, intPK) {
  f.HFpkn.value = intPK;
  f.submit();
}
function frmPedidoOrcamento_Validate(f) {
  if(trim(f.tfNome.value) == "" || trim(f.tfTelefone.value) == "" || trim(f.tfEmail.value) == ""
	 || trim(f.tfNomeCondominio.value) == "" || trim(f.tfEnderecoCondominio.value) == ""
	 || (trim(f.tfHabitacoes.value) == "" && trim(f.tfGaragens.value) == ""	&& trim(f.tfManutencao.value) == ""
	 && trim(f.tfEscritorio.value) == "" && trim(f.tfArrecadacoes.value) == "" && trim(f.tfOutros.value) == "")
	 || trim(f.tfPisos.value) == "" || trim(f.tfForma.value) == "") {
    alert ("Não é possível enviar o formulário.\nIntroduza os campos são de preenchimento obrigatório.");
    return false;
  }
  if(!validateEmail(f.tfEmail.value)) {
    alert("Não é possível enviar o formulário.\nIntroduza um endereço de e-mail válido.");
	return false;
  }
  return true;
}