<!--
function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}
function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}
function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}
function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}
function MM_goToURL() { //v3.0
  var i, args=MM_goToURL.arguments; document.MM_returnValue = false;
  for (i=0; i<(args.length-1); i+=2) eval(args[i]+".location='"+args[i+1]+"'");
}

function MM_openBrWindow(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);
}
function MM_openBrWindowCenter(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 MM_openBrWindowCenterPainel(pk, width, height, scr) {
  window.open("detalhe_imovel.aspx?ID="+pk, "", "status=1,scrollbars="+scr+",width="+width+",height="+height+",left="+(screen.width - width) / 2+",top="+(screen.height - height) / 2);
}
function MM_openSimulacaoWindow(theURL) { //v2.0
  window.open(theURL,'','menubar=1,toolbar=1,scrollbars=1,status=1,location=1,resizable=1');
}

function flvS3(v1){ //v1.2
  var v2=MM_findObj(v1);
  if (!v2){
    this.x=this.y=this.h=this.w=0;
    return;
  }
  var v3,v4,v5,v6,v7=(document.layers)?v2:v2.style;v3=isNaN(parseInt(v7.left))?v2.offsetLeft:parseInt(v7.left);
  v4=isNaN(parseInt(v7.top))?v4=v2.offsetTop:parseInt(v7.top);
  if(v2.offsetHeight){
    v5=v2.offsetHeight;
	v6=v2.offsetWidth;
  }else if (document.layers){
	v5=v7.clip.height;
	v6=v7.clip.width;
  }else{
    v5=v6=0;
  }
  this.x=parseInt(v3);
  this.y=parseInt(v4);
  this.h=parseInt(v5);
  this.w=parseInt(v6);
}
function flvS8(v1,v2,v3){ //v1.0
  var v4=(document.layers)?v1:v1.style;var v5=flvS5();
  eval("v4.left='"+v2+v5+"'");
  eval("v4.top='"+v3+v5+"'");
}
function flvS5(){ //v1.0
  var v1=((parseInt(navigator.appVersion)>4||navigator.userAgent.indexOf("MSIE")>-1)&&(!window.opera))?"px":"";
  return v1;
}
function flvXAS1(){
  var v1=arguments,v2=v1.length,v3='AutoScrollContainer',v4='AutoScrollContent';
  var v5=MM_findObj(v3),v6=MM_findObj(v4);
  if(!v5){
    return;
  }
  if(v5.XAS1!=null){
    clearTimeout(v5.XAS1);
  }
  var v7=(v2>0)?parseInt(v1[0]):1;
  if(v7){
    var v8=(v2>1)?parseInt(v1[1]):1,v9=(v2>2)?parseInt(v1[2]):50,v10=(v2>3)?parseInt(v1[3]):1;
	var v11=new flvS3(v3),v12=new flvS3(v4);
	var v13=v12.x,v14=v12.y,v15=0,v16=0;
	if(v10==1){
	  var v17=-1*v12.h;v15=v12.x;
	  if (v14>=v17){
	    v16=v12.y-v8;
	  }else{
	    v16=v11.h;
	  }
	}else{
	  var v18=-1*v12.w;v16=v12.y;
	  if(v13>=v18){
	    v15=v12.x-v8;
	  }else{
	    v15=v11.w;
	  }
	}
	flvS8(v6,v15,v16);
	v5.XAS1=setTimeout("flvXAS1("+v7+","+v8+","+v9+","+v10+")",v9);
  }
}



function changeCursor(object) {
  object.style.cursor = 'hand';
}
function trim(string) {
  var re= /^\s*|\s*$/g;
  return string.replace(re,"");
}
function validateDate(d) {
  if (d != "") {
    var objRegExp = /^\d{2}-\d{2}-\d{4}$/;
    return objRegExp.test(d);
  } else {
	return true;
  }
}
function printWindow() {
  window.print();
}
function closeWindow() {
  window.close();
}
function backWindow() {
  history.back();
}


function changeParentImage(imagem) {
  var _url = imagem.src;
  var _pos = imagem.src.lastIndexOf("/");  
  parent.imagemPrincipal.src = _url.substring(0, _pos+1) + _url.substring(_pos + 2);
}
function numberCheckBox(f) {
  var c = 0;
  for(var i=0; i<f.elements.length-1; i++) {
    if(f.elements[i].checked) c++
  }
  return c;
}
function frmPainelNoticias_Submit(f, value) {
  f.HFprimarykey.value = value;
  f.submit();
}
function validateEmail(e) {
  if (e != "") {
    var objRegExp = /^.+@.+\..{2,3}$/;
    return objRegExp.test(e);
  } else {
    return true;
  }
}











function frmElimina_Click(f,text) {
  if(numberCheckBox(f) != 0) {
    if(confirm("Tem a certeza que deseja eliminar as " + text + " seleccionadas?")){
      f.submit();
    }
  } else {
    alert("A operação não pode ser realizada.\nSeleccione primeiro as " + text + " a eliminar.");
  }
}
function frmPesquisaImoveis_Validate(f) {
  var pL, pH;
  if(f.ddlTipologiaL.selectedIndex != 0 && f.ddlTipologiaH.selectedIndex != 0) {
    if(f.ddlTipologiaL.selectedIndex > f.ddlTipologiaH.selectedIndex){
      alert("Não é possível iniciar o processo.\nIntroduza por favor um intervalo de tipologias válido.");
	  return false;
    }
  }
  if(f.tfPrecoL.value.length > 0) {
    if(isNaN(f.tfPrecoL.value * 2)) {
      alert("Não é possível iniciar o processo.\nIntroduza por favor um intervalo de preços válido.");
	  return false;
	} else { 
	  pL = f.tfPrecoL.value;
	}
  } else { 
    pL = 0;
  }
  if(f.tfPrecoH.value.length > 0) {
    if(isNaN(f.tfPrecoH.value * 2)) {
	  alert("Não é possível iniciar o processo.\nIntroduza por favor um intervalo de preços válido.");
	  return false;
	} else {
	  pH = f.tfPrecoH.value;
	}
  } else {
    pH = 0;
  }
  if(pH > 0) {
    if(pL > pH) {
	  alert("Não é possível iniciar o processo.\nIntroduza por favor um intervalo de preços válido.");
	  return false;
    }
  }
}

function frmComprarVender_Validate(f) {
  if(trim(f.tfNome.value) == "" || trim(f.tfMorada.value) == "" || trim(f.tfHorario.value) == "" || trim(f.tfPreco.value) == ""
    || trim(f.tfCaracteristicas.value) == "" || (trim(f.tfTelefoneTelemovel.value) == "" && trim(f.tfFax.value) == "" && trim(f.tfEmail.value) == "")) {
    alert("Não é possível concluir o processo.\nPreencha os campos obrigatórios.");
    return false;
  }
  if(!validateEmail(f.tfEmail.value)) {
    alert("Não é possível iniciar o processo.\nIntroduza um endereço de e-mail válido.");
	return false;
  }
  if(isNaN(f.tfPreco.value)) {
    alert("Não é possível iniciar o processo.\nIntroduza por favor um preço válido.");
 	return false;
  }
  return true;
}


function frmNoticia_Validate(f) {
  if(trim(f.tfNome.value) == "" || trim(f.tfTitulo.value) == "" || trim(f.tfDataCriacao.value) == "" || trim(f.tfCorpo.value) == "") {
    alert ("Não é possível concluír o processo.\nPor favor introduza os campos de preenchimento obrigatório.");
    return false;
  }
  if(!validateDate(f.tfDataCriacao.value) || !validateDate(f.tfDataExpiracao.value)) {
    alert("Não é possível concluír o processo.\nIntroduza uma data válida.");
    return false;
  }
  return true;
}

function frmPergunta_Validate(f) {
  if(trim(f.tfPergunta.value) == "" || trim(f.tfResposta.value) == "") {
    alert ("Não é possível concluír o processo.\nTodos os campos são de preechimento obrigatório.");
    return false;
  }
  return true;
}
function frmAlterarPassword_Validate(f) {
  if(trim(f.tfPPOriginal.value) == "" || trim(f.tfConfirmacaoPP.value) == "" || trim(f.tfNovaPP.value) == "") {
    alert("Todos os dados são de preenchimento obrigatório.");
    return false;
  }
  if(f.tfPPOriginal.value != f.HFdatabase.value) {
    alert("A palavra-passe antiga que inseriu não está correcta.");
    return false;
  }
  if(f.tfConfirmacaoPP.value != f.tfNovaPP.value) {
    alert("As palavras-passe que inseriu não coincidem.");
    return false;
  }
  return true;
}
function frmDetalheImovel_Click(f, ID) {
  f.HFpki.value = ID;
  f.submit();
}
function frmPainelNoticias_Submit(f, intPK) {
  f.HFpkn.value = intPK;
  f.submit();
}





/*
  Método que permite redimensionar uma imagem baseado nas dimensões máximas permitidas.
*/
function resize(obj, width, height)
{  
  // Obtém a imagem a apresentar
  var _thumb = new Image();
  _thumb.src = obj.src;
  if((_thumb.width > width) || (_thumb.height > height)) {
    var _wratio = width / _thumb.width;
    var _hratio = height / _thumb.height;
    // Apresenta a imagem com a dimensão máxima permitida
    var _ratio = Math.min(_hratio, _wratio);
    obj.width = _thumb.width * _ratio;
    obj.height = _thumb.height * _ratio;
  }
}

/*
  Método que configura a imagem a apresentar quando não for possível descarregar a imagem do servidor.
*/
function preview(obj, width, height)
{
  obj.onerror = null;
  var size = width + "," + height
  switch(size) {
	default:
	  obj.src = "http://194.8.30.191:8080/186/Casactiva/NoImg-Casactiva.jpg";
	  break;
  }
}
//-->