function PopUpNews() {
			myWindowHandle = window.open('horarios_pascoa.html','HorariosPascoa','width=828,height=597,top=200,left=300,toolbar=no,scrollbars=yes,status=yes');
	}

function fixGodDammitPngsForIE6(){
	
	if($.browser.msie){
		divs = document.getElementsByTagName("DIV");
		for(var i=0;i<divs.length;i++){
			$(divs[i]).ifixpng();
		}
	}
}

/*
   FOTOS DO IMÓVEL
   ARQUIVO:
   detalhes_imoveis.asp
   
   DESCRIÇÃO:
   - Efeito de FadeIn nas fotos.
   - Efeito borda no onmouseover
   - Efeito borda no onclick
   
   DEPENDECIAS:
   jquery.js
*/
  // IMAGNES BACKGROUND
  var backImage = new Array();
  backImage[0] = "../img/foto800_2.jpg";
  backImage[1] = "../img/foto1024_2.jpg";
  backImage[2] = "../img/foto1280_2.jpg";
  
  
function changeBGImage(whichImage){
if (document.body){
  document.body.background = backImage[whichImage];
  document.body.style.overflow='hidden';
  }
}

function background(){
  data = new Date();
  id = data.getMinutes() + data.getSeconds();
  swfobject.embedSWF("../img/regiao.swf?id=1","regiao_flash", "275", "39", "9.0.0", "", {}, {wmode:"transparent"});
  swfobject.embedSWF("../img/banner_plantao_franquia.swf","plantao_franquia", "276", "93", "9.0.0", "", {}, {wmode:"transparent"});
  swfobject.embedSWF("../img/anima_centro.swf?id="+id, "anima_centro_flash", "400", "208", "9.0.0", "", {}, {wmode:"transparent"});
  var screenW = screen.width
  var screenH = screen.height
 //alert("largura: " + screenW + " / " + "altura: " + screenH)
  if (screenW<=800)
  {
    changeBGImage(0)
  }
  if (screenW>800 && screenW<=1024)
  {
    changeBGImage(1)
  }
  if (screenW>1024)
  {
    changeBGImage(2)
  }
}

var objSelected = false;
function over(obj){
  if(obj.getElementsByTagName('IMG')[0].src == document.getElementById('mostrafoto').src)
      return false
  obj.style.border = 'solid 1px green';
}
function out(obj){
    if(obj.getElementsByTagName('IMG')[0].src == document.getElementById('mostrafoto').src)
      return false
    obj.style.border = 'solid 1px #ffffff';
    
}
function selected(obj){
    if(objSelected == obj)
      return false;
    if(objSelected)
        if(objSelected.style.border = 'solid 1px green')
          objSelected.style.border = 'solid 1px #ffffff';
    if(objSelected != obj){
      objSelected = obj;
      document.getElementById('mostrafoto').style.display='none';
      document.getElementById('mostrafoto').src = obj.getElementsByTagName('IMG')[0].src;
      $("#mostrafoto").fadeIn("slow");
      if(document.getElementById('mostrafoto').src == objSelected.getElementsByTagName('IMG')[0].src)
        obj.style.border = 'solid 2px green';
    }else{
      
    }
}
/*
    FIM - FOTOS DO IMÓVEL
*/


//<!--

  function aviseme_alterarData(u,p){
    var divIframeAction = document.getElementById('ifrmAction');
    var req = new XMLHttpRequest();
	  if (confirm('Você irá alterar a data da ultima verificação.\n\nConfirma ?')) {
      if (req) {
        req.onreadystatechange = function() {
          if (req.readyState == 4 && (req.status == 200 || req.status == 304)) {
  //          divIframeAction.innerHTML = req.responseText;
          }
        };
        req.open('GET', 'aviseme_alteraDtVerifica.asp?u=' + u + '&p=' + p,true);
        req.send(null);
      }
    }
  }

  function removeImovelSession(inCdImovel,obj){
    var answer = confirm("Deseja remover este imovel da lista?");
    if(answer){
      obj.parentNode.parentNode.parentNode.removeChild(obj.parentNode.parentNode);
      var req = new XMLHttpRequest();
      if (req) {
        req.onreadystatechange = function() {
          if (req.readyState == 4 && (req.status == 200 || req.status == 304)) {  
             top.document.getElementById('label_erro').style.color = "blue";
             top.document.getElementById('label_erro').innerHTML = "Imovel "+ inCdImovel +" removido da lista";
            //top.document.getElementById('iframeBuscaImovel').refresh;
          }
        };
        req.open('GET', '../conteudo/newsimoveis_remove_lista.asp?inCdImovel=' + inCdImovel,true);
        req.send(null);
      }
    }
  }
  
  function newsImoveisAdicionaLista(codigo){
  top.document.getElementById('label_erro').innerHTML = "";
	var req = new XMLHttpRequest();
    if (req) {
      req.onreadystatechange = function() {
        if (req.readyState == 4 && (req.status == 200 || req.status == 304)) {
//          divIframeMinhaLista.innerHTML = req.responseText;
            top.location = 'newsimoveis_index.asp';
        }
      };
      req.open('GET', '../conteudo/newsimoveis_adiciona_lista.asp?code=' + codigo,true);
      req.send(null);
    }
  }
  
  
  function minhaLista_AdicionaLista(codigo, tipo) {
	  	minhalista_adiciona(codigo,tipo);
	  	var divMinhaLista = document.getElementById('div_btn_minhalista' + codigo);
     	divMinhaLista.innerHTML='<img src=\"../img/btn_minhalistaok.gif\" alt=\"Imóvel adicionado à lista\" title=\"Imóvel adicionado à lista\" border=\"0\" width=\"100\" height=\"22\" style=\"margin:5px 0 0 0;\" />';
  }
  
  function minhalista_adiciona(inCdImovel,inCdTipoBusca){
    var divIframeMinhaLista = document.getElementById('MinhaLista');
    var req = new XMLHttpRequest();
    if (req) {
      req.onreadystatechange = function() {
        if (req.readyState == 4 && (req.status == 200 || req.status == 304)) {
//          divIframeMinhaLista.innerHTML = req.responseText;
        }
      };
      req.open('GET', 'minhalista_adiciona_lista.asp?cod=' + inCdImovel + '&InCdTipo=' + inCdTipoBusca + '&detalhes=true',true);
      req.send(null);
    }
  }

/*
  function minhalista_adiciona_2(inCdImovel,inCdTipoBusca){
    var divIframeMinhaLista = document.getElementById('MinhaLista');
    var req = new XMLHttpRequest();
    if (req) {
      req.onreadystatechange = function() {
        if (req.readyState == 4 && (req.status == 200 || req.status == 304)) {
//          divIframeMinhaLista.innerHTML = req.responseText;
        }
      };
      req.open('POST', 'minhalista_adiciona_lista.asp?cod=' + inCdImovel + '&InCdTipo=' + inCdTipoBusca + '&detalhes=false',true);
      req.send(null);
    }
  }
*/

  function minhaauxiliadora_esqueciSenha(varObj){
    var frmLogin = document.getElementById('frmLogin');
    frmLogin.action = '';

    var divIframeAction = document.getElementById('ifrmAction');
    var objE = document.getElementById(varObj);
    if (objE.value != '') {
      var req = new XMLHttpRequest();
      var url = "minhaauxiliadora_esqueciSenha.asp";
      var params = "txEmail=" + objE.value;
      req.open("POST", url, true);
      req.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
      req.setRequestHeader("Content-length", params.length);
      req.setRequestHeader("Connection", "close");
      req.onreadystatechange = function() {
        if (req.readyState == 4 && (req.status == 200 || req.status == 304)) {
          alert(req.responseText);
        }
      }
      req.send(params);
    }
  }

  function minhaauxiliadora_login(){
    var frmLogin = document.getElementById('frmLogin');
    frmLogin.target = '_self';
    frmLogin.action = 'minhaauxiliadora_login.asp';
    frmLogin.submit();
  }

  function abrir_janela_popup(theURL,winName,features) 
  { //v2.0
    window.open(theURL,winName,features);
  }

  function MM_openBrWindow(theURL,winName,features) { //v2.0
    window.open(theURL,winName,features);
  }


  function mostrarBairros() {
    var combo = document.getElementById('codCidade').options;
    var divBairros = document.getElementById('divBairros');
    var selBairros = document.getElementById('bairros').options;
    var strDados = "";
    for (i=0; i < combo.length; i++)
      {
        if ((combo[i].selected) && (combo[i].value != ""))
          {
            strDados += combo[i].value + "#"
          }
      }
	  //alert(strDados);
    if (strDados.indexOf('07198') > -1) {
      divBairros.style.display = 'block';
    } else {
      divBairros.style.display = 'none';
      parent.document.getElementById('bairros').value = '';
      for (i=0; i< selBairros.length; i++){
        selBairros[i].selected = false;
      }
    }
  }

  function submitComboAluguel(pId,pInnerHtml){
    var objOpt = document.getElementById(pId).options;
    var strDados = "";
    for(i = 0; i < objOpt.length; i++){
      if ((objOpt[i].selected) && (objOpt[i].value != "")) {
        strDados += objOpt[i].value + "#"
      }
    }
    parent.document.getElementById(pInnerHtml).value = strDados;
  }


  function mostrarBairrosVenda(){
	//alert(document.getElementById('divBairros'));
    var combo = document.getElementById('CodCidade').options;
    var divBairros = document.getElementById('divBairros');
    var selBairros = document.getElementById('bairros').options;
	
    var strDados = "";

    for (i=0; i < combo.length; i++)
      {
        if ((combo[i].selected) && (combo[i].value != ""))
          {
            strDados += combo[i].value + "#"
          }
      }
    strDados = strDados.toUpperCase();
	
    if (strDados.indexOf('PORTO ALEGRE') > -1){
      divBairros.style.display = 'block';
    } else {
      divBairros.style.display = 'none';
      parent.document.getElementById('bairros').value = '';
      for (i=0; i< selBairros.length; i++){
        selBairros[i].selected = false;
      }
    }
  }

  function submitComboVenda(pId,pInnerHtml){
    var objOpt = document.getElementById(pId).options;
    var strDados = "";
    for(i = 0; i < objOpt.length; i++){
      if ((objOpt[i].selected) && (objOpt[i].value != "")) {
        strDados += objOpt[i].value + "#"
      }
    }
    parent.document.getElementById(pInnerHtml).value = strDados;
  }
/////////////////////////////////////
//PAGINA CONSORCIO_TABELA.ASP
/////////////////////////////////////
function BloqueiaOutros() {
	document.getElementById('divOutros').style.display = 'none'
	form1.outros.value = ''
	return true
}
function LiberaOutros() {
	document.getElementById('divOutros').style.display = 'block'
	form1.outros.focus();
	return true
}
/////////////////////////////////////
//FINAL PAGINA CONSORCIO_TABELA.ASP
/////////////////////////////////////

function MostraFoto(vFoto,w,h){
  if(w)
     document.getElementById('mostrafoto').width = w;
  if(h)
    document.getElementById('mostrafoto').height = h;
    
	document.getElementById('mostrafoto').src=vFoto;
}

/////////////////////////////////////
//PAGINA DEBITOEMCONTA.ASP
/////////////////////////////////////
function setFieldMask(field, maskType, event) {
	
	var ie = document.all;

	switch(maskType) {
		case 'caixa':
			var keySet = '0123456789';
			var maxsize = 13;
			var mask = '###/#########';
			break;
	}

	var keyCode = (ie) ? window.event.keyCode : event.which;

	if(keyCode == 8) {
		field.value = field.value.substring(-1, (field.value.length - 1));
	}

	var key = String.fromCharCode(keyCode);
	if((keySet.indexOf(key) == -1) && (keyCode != 0) && (keyCode != 13)) {
		return false;
	}
	
	var i = field.value.length;

	if((i >= maxsize) && (keyCode != 0) && (keyCode != 13)) {
		return false;
	}

	var output = mask.substring(0,1);
	var outputText = mask.substring(i);
	if(outputText.substring(0,1) != output) {
		field.value += outputText.substring(0,1);
	}

	return true;

}

function onlyNumbers(field, event) {
	
	var ie = document.all;
	var keySet = '0123456789';
	var keyCode = (ie) ? window.event.keyCode : event.which;

	if(keyCode == 8) {
		field.value = field.value.substring(-1, (field.value.length - 1));
	}

	var key = String.fromCharCode(keyCode);
	if((keySet.indexOf(key) == -1) && (keyCode != 0) && (keyCode != 13)) {
		return false;
	}

	return true;

}

function changeBanco(cod) {

	var form = document.formDebito;
	var textoAgencia = document.getElementById('textoAgencia');
	var textoContaCorrente = document.getElementById('textoContaCorrente');
	
	// altera o campo código do banco
	form.numeroBanco.value = cod;
	form.agencia.value = '';
	form.contaCorrente.value = '';

	// se foi selecionado algum banco, altera campos agência e conta corrente de acordo
	if(cod != '') {

		// libera para edição os campos
		form.agencia.disabled = false;
		form.agencia.style.backgroundColor = '#FFFFFF';
		form.contaCorrente.disabled = false;
		form.contaCorrente.style.backgroundColor = '#FFFFFF';

		// banrisul
		if(cod == '041') {
			form.agencia.size = '4';
			form.agencia.maxLength = '4';
			textoAgencia.innerHTML = 'Informe <b>4 d&iacute;gitos</b>.';
			form.contaCorrente.size = '10';
			form.contaCorrente.maxLength = '10';
			textoContaCorrente.innerHTML = 'Informe <b>10 d&iacute;gitos</b>.';
		}
		// bradesco
		if(cod == '237') {
			form.agencia.size = '4';
			form.agencia.maxLength = '4';
			textoAgencia.innerHTML = 'Informe <b>4 d&iacute;gitos</b>.';
			form.contaCorrente.size = '7';
			form.contaCorrente.maxLength = '7';
			textoContaCorrente.innerHTML = 'Informe <b>7 d&iacute;gitos</b>.';
		}
		// banco do brasil
		if(cod == '001') {
			form.agencia.size = '5';
			form.agencia.maxLength = '5';
			textoAgencia.innerHTML = 'Informe <b>5 d&iacute;gitos</b>.';
			form.contaCorrente.size = '6';
			form.contaCorrente.maxLength = '6';
			textoContaCorrente.innerHTML = 'Informe <b>6 d&iacute;gitos</b>.';
		}
		// caixa econômica federal
		if(cod == '104') {
			form.agencia.size = '4';
			form.agencia.maxLength = '4';
			textoAgencia.innerHTML = 'Informe <b>4 d&iacute;gitos</b>.';
			form.contaCorrente.size = '13';
			form.contaCorrente.maxLength = '13';
			textoContaCorrente.innerHTML = 'Informe <b>3 d&iacute;gitos</b> para o C&oacute;digo de Conta e <b>9 d&iacute;gitos</b> para o n&uacute;mero da Conta Corrente.';
		}
		// hsbc
		if(cod == '399') {
			form.agencia.size = '4';
			form.agencia.maxLength = '4';
			textoAgencia.innerHTML = 'Informe <b>4 d&iacute;gitos</b>.';
			form.contaCorrente.size = '7';
			form.contaCorrente.maxLength = '7';
			textoContaCorrente.innerHTML = 'Informe <b>7 d&iacute;gitos</b>.';
		}
		// santander meridional
		if(cod == '008') {
			form.agencia.size = '4';
			form.agencia.maxLength = '4';
			textoAgencia.innerHTML = 'Informe <b>4 d&iacute;gitos</b>.';
			form.contaCorrente.size = '9';
			form.contaCorrente.maxLength = '9';
			textoContaCorrente.innerHTML = 'Informe <b>9 d&iacute;gitos</b>.';
		}
		// real abn amro
		if(cod == '356') {
			form.agencia.size = '4';
			form.agencia.maxLength = '4';
			textoAgencia.innerHTML = 'Informe <b>4 d&iacute;gitos</b>.';
			form.contaCorrente.size = '7';
			form.contaCorrente.maxLength = '7';
			textoContaCorrente.innerHTML = 'Informe <b>7 d&iacute;gitos</b>.';
		}
	}
	else {
		// bloqueia para edição os campos
		form.agencia.disabled = true;
		form.agencia.style.backgroundColor = '#EFEFEF';
		textoAgencia.innerHTML = '';
		form.contaCorrente.disabled = true;
		form.contaCorrente.style.backgroundColor = '#EFEFEF';
		textoContaCorrente.innerHTML = '';
	}

}

function checkDebito() {

	var form = document.formDebito;
	var regexp = /^[\w-\.]+\@[\w\.-]+\.[a-z]{2,4}$/;
	var error = '';

	if(form.debitoPara.value == '')
		error += 'O campo "D&eacute;bito para" é obrigatório.<br>';
	if(form.nomeCompleto.value == '')
		error += 'O campo "Nome Completo" é obrigatório.<br>';
	if(form.telefone.value == '')
		error += 'O campo "Telefone" é obrigatório.<br>';
	if(form.correntista.value == '')
		error += 'O campo "Correntista / Titular da Conta" é obrigatório.<br>';
	if(form.cpf_cnpj.value == '')
		error += 'O campo "CPF / CNPJ" é obrigatório.<br>';
	if(form.enderecoDebito.value == '')
		error += 'O campo "Endereço do Imóvel" é obrigatório.<br>';
	if(form.enderecoCorrespondencia.value == '')
		error += 'O campo "Endereço para Correspondência" é obrigatório.<br>';
	if(form.email.value == '')
		error += 'O campo "e-mail" é obrigatório.<br>';
	if(!regexp.test(form.email.value) && form.email.value != '')
		error += 'O campo "e-mail" não contém um valor válido.<br>';
	if(form.nomeBanco.value == '')
		error += 'O campo "Nome do Banco" é obrigatório.<br>';
	if(form.nomeBanco.value != '') {
		if(form.agencia.value == '')
			error += 'O campo "Agência" é obrigatório.<br>';
		if(form.contaCorrente.value == '')
			error += 'O campo "Conta Corrente" é obrigatório.<br>';
	}
	if(!form.ciente.checked)
		error += 'É preciso concordar com os termos do regulamento.<br>';

	if(error != '') {
		error += '<br>';
		var div = document.getElementById('div_output');
		div.className = 'verdana11';
		div.style.color = '#FF0000';
		div.innerHTML = error;
		return false;
	}

	return true;

}
/////////////////////////////////////
//FINAL PAGINA DEBITOEMCONTA.ASP
/////////////////////////////////////

function ValidaFormCPF(passForm) {
	if (!(passForm.cpf.value.length == 11 || passForm.cpf.value.length == 14)) {
		alert('O campo CPF/CNPJ deve ser informado!')
		passForm.cpf.focus()
		return false }
	else {
		if (passForm.cpf.value.length == 11) {
			if (checaCPF(passForm.cpf.value)) {
				return true }
			else {
				alert('CPF invÃ¡lido, digite novamente!')
				passForm.cpf.focus()
				return false }	
			}
		else	{
			if (checaCNPJ(passForm.cpf.value)) {
				return true }
			else {
				alert('CNPJ invÃ¡lido, digite novamente!')
				passForm.cpf.focus()
				return false }	}
		}		
	return true
}

function ValidaFormLogin(passForm) {
	if (!(passForm.cpf.value.length == 11 || passForm.cpf.value.length == 14)) {
		alert('O campo CPF/CNPJ deve ser informado!')
		passForm.cpf.focus()
		return false }
	else {
		if (passForm.cpf.value.length == 11) {
			if (checaCPF(passForm.cpf.value)) {
				 }
			else {
				alert('CPF invÃ¡lido, digite novamente!')
				passForm.cpf.focus()
				return false }	
			}
		else	{
			if (checaCNPJ(passForm.cpf.value)) {
				 }
			else {
				alert('CNPJ invÃ¡lido, digite novamente!')
				passForm.cpf.focus()
				return false }	}
		}
	if (passForm.senha.value == "") {
		alert('A senha atual deve ser informada!')
		passForm.senha.focus()
		return false
		}
	if (passForm.senha1.value == "") {
		alert('A senha nova deve ser informada!')
		passForm.senha1.focus()
		return false
		}
	if (passForm.senha1.value != passForm.senha2.value) {
		alert('As senhas novas nÃ£o estÃ£o iguais, digite novamente!')
		passForm.senha1.focus()
		return false
		}
	return true
}

function MM_showHideLayers() { //v6.0
  hiddeSelectBoxesBusca();
  var i,p,v,obj,args=MM_showHideLayers.arguments;
  for (i=0; i<(args.length-2); i+=3) if ((obj=MM_findObj(args[i]))!=null) {  v=args[i+2];
    if (obj.style) { obj=obj.style; v=(v=='show')?'visible':(v=='hide')?'hidden':v; }
    obj.visibility=v; }
}

function alterar()
{ 
  x = document.imagem.width + 10;
  y = document.imagem.height + 75;
  window.resizeTo(x,y); 
}

function posiciona()
{
	x = (screen.width - document.imagem.width) / 2;
	y = (screen.height - document.imagem.height) / 2;
	window.moveTo(x,y);
}

/////////////////////////////////////
//PAGINA PESQUISA_VENDAS.ASP
/////////////////////////////////////
function MM_jumpMenu(targ,selObj,restore){ //v3.0
  eval(targ+".location='home.asp?InCdTipoBusca=1&InCdCidade="+selObj.options[selObj.selectedIndex].value+"'");
  if (restore) selObj.selectedIndex=0;
}

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 nulo() {
}

function CheckRegiao(vReg) {
	var situacao = eval('document.Pesquisa.Reg'+vReg+'.checked');
	var ok = true;
	var nok = false;
	if (situacao) {
		eval('document.Pesquisa.Reg'+vReg+'.checked=nok'); }
	else {
		eval('document.Pesquisa.Reg'+vReg+'.checked=ok'); }
}

function ValidaFormPesquisa(passForm) {
	var marcouregiao = false
	var CodCidade = document.getElementById('CodCidade').value;
	for (var i = 1; i < 7; i = i + 1) {
		var situacao = eval('document.Pesquisa.Reg'+i+'.checked');	
		if (situacao) {
			marcouregiao = true
		}
	}
	if (marcouregiao) {}
	else {
		if (CodCidade=='Porto Alegre')
		{
		alert('Pelo menos uma região deve ser selecionada!')
		return false
		}
	}	
	return true
}

function MM_reloadPage(init) {  //reloads the window if Nav4 resized
  if (init==true) with (navigator) {if ((appName=="Netscape")&&(parseInt(appVersion)==4)) {
    document.MM_pgW=innerWidth; document.MM_pgH=innerHeight; onresize=MM_reloadPage; }}
  else if (innerWidth!=document.MM_pgW || innerHeight!=document.MM_pgH) location.reload();
}

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_showHideLayers2() { //v6.0
  var sA,sB,sC,sD, SStyle;
  sA = document.getElementById('Cidade').style;
  sB = document.getElementById('valorinicial').style;
  sC = document.getElementById('valorfinal').style;
  sD = document.getElementById('codigotipoimovel').style;
  var i,p,v,obj;
  var args=MM_showHideLayers.arguments;
  for (i=0; i<(args.length-2); i+=3)
    if ((obj=MM_findObj(args[i]))!=null) {
      v=args[i+2];
      if (obj.style) {
        obj=obj.style;
        if (v == 'show'){
          v = 'visible';
          SStyle = 'hidden';
          }
          else if (v == 'hide'){
            v = 'hidden';
            SStyle = 'visible';
            }
          }
      obj.visibility = v;
      sA.visibility = SStyle;
      sB.visibility = SStyle;
      sC.visibility = SStyle;
      sD.visibility = SStyle;
    }
}

function VerificaCidade(combo)
{
  if (combo == "PORTO ALEGRE"){
    combo = "Porto Alegre";
  }
	parent.location = '../conteudo/home.asp?InCdTipoBusca=2&CodCidade=' + combo;
}
//function VerificaCidade(combo)
//{
	//parent.location = 'http://www.auxiliadorapredial.com.br/conteudo/home.asp?InCdTipoBusca=2&CodCidade=' + combo;
//}

/////////////////////////////////////
//FINAL PAGINA PESQUISA_VENDAS.ASP
/////////////////////////////////////

  function limpaForm(){
    var Formulario = document.forms.form1;
    Formulario.reset();
    return false;
  }

  
  function ValidaFormVista(passForm) {
	var marcouregiao = false
	for (var i = 1; i < 7; i = i + 1) {
		var situacao = eval('document.Pesquisa.Reg'+i+'.checked');	
		if (situacao) {
			marcouregiao = true
		}
	}
	if (marcouregiao) {}
	else {
		alert('Pelo menos uma região deve ser selecionada!')
		return false
	}	
	return true
}


/////////////////////////////////////
//PAGINA INC_BUSCA.ASP
/////////////////////////////////////


function ValidaFormHome(passForm) {
  var marcouregiao = false;
  var codOk = false;
	var CodCidade = document.getElementById('CodCidade').value;
	var CodigoImovel = document.getElementById('CodigoImovel').value;
	
  if (CodigoImovel != '') {
    codOk = true;
  }
  
  if (!codOk) {
    if (CodCidade=='home.asp?InCdTipoBusca=2') {
  	  alert('Você deve escolher uma cidade!');
  		return false
  	}
  
    if (CodCidade=='07198'){
  	  for (var i = 1; i < 7; i = i + 1) {
    		var situacao = eval('document.forms[\'Pesquisa\'].Reg'+i+'.checked');	
    		if (situacao) {
      		marcouregiao = true;
    		}
    	}
      if (!marcouregiao){
        alert('Pelo menos uma região deve ser selecionada!');
   	    return false;
      }
    }
  }

  return true
}

function MM_jumpMenu(targ,selObj,restore,InCdTipoBusca){ //v3.0
  eval(targ+".location='home.asp?InCdTipoBusca="+InCdTipoBusca+"&InCdCidade="+selObj.options[selObj.selectedIndex].value+"'");
  if (restore) selObj.selectedIndex=0;
}


/////////////////////////////////////
//FIM PAGINA INC_BUSCA.ASP
/////////////////////////////////////

function getObj(sName){
	if (document.getElementById)
		return document.getElementById(sName); 
	else if (document.all)
		return document.all[sName];
	else if (document.layers)
		return document.layers[sName];
	else
		return false;
}

// CLEAR OR COMPLETE FIELDS
function valueField(e){
	var oObj = myNavigator() ? getObj(e.srcElement.id) : getObj(e.target.id);

	if (e.type.indexOf('focus') != -1 && isTitle(oObj))
		oObj.value = '';
	else if (e.type.indexOf('blur') != -1 && isEmpty(oObj.value) || (isDefaultValue(oObj) || isTitle(oObj)))
		oObj.value = oObj.title;
}

function trocaImg(objBt,boTroca,imgBt){
  if (boTroca) {
		  getObj(objBt).src = '../img/'+ imgBt + '_off.gif';
	} else {
		getObj(objBt).src = '../img/'+ imgBt + '_on.gif';
  }
}

function trocaImg1(objBt,boTroca,imgBt){
  if (boTroca) {
		 getObj(objBt).src = '../img/'+ imgBt + '_off.jpg';
	} else {
		getObj(objBt).src = '../img/'+ imgBt + '_on.jpg';
  }
}

function trocaLista(objUl,ulTroca,objUl2){
  try{
  if (ulTroca) {
		 getObj(objUl).style.display = 'block';
     getObj(objUl2).style.display = 'none'
	} else {
		getObj(objUl).style.display = 'none';
    getObj(objUl2).style.display = 'block'
  }
  }catch(e){}
}


function tipoBusca(pValue){
var divIframe = document.getElementById('divIframe');
var divCodigo = document.getElementById('divCodigo');
var divTexto = document.getElementById('divTexto');

var req = new XMLHttpRequest();
if (req) {
  req.onreadystatechange = function() {
    if (req.readyState == 4 && (req.status == 200 || req.status == 304)) {
      removeContent('divIframe');
      divIframe.innerHTML = req.responseText;
    }
  };
  if (pValue == "1"){
    divTexto.style.display = 'none';
    divIframe.style.display = 'block';
    divCodigo.style.display = 'block';
    req.open('GET', 'busca_avancada_alugueis.asp',true);
    req.send(null);
  }
  else if (pValue == "2"){
    divTexto.style.display = 'none';
    divIframe.style.display = 'block';
    divCodigo.style.display = 'block';
    req.open('GET', 'busca_avancada_vendas.asp',true);
    req.send(null);
  }
}

document.getElementById('InCdTipoBusca').value = pValue;
document.getElementById('codCidade').value = "";
document.getElementById('valor').value = "";
document.getElementById('codigotipoimovel').value = "";
document.getElementById('bairros').value = "";
}

function removeContent(divId) {
  var objDiv = document.getElementById(divId);
  while (objDiv.hasChildNodes()) {
    objDiv.removeChild(objDiv.firstChild);
  }
}


function submitBusca(){
var formOk;
formOk = false;
var codCidade = document.getElementById('codCidade').value;
var rad1 = document.getElementById('radTipo1').checked;
var rad2 = document.getElementById('radTipo2').checked;
if ((rad1) || (rad2)) {
  formOk = true;
}
 else {
  alert('Por favor, selecione o tipo de busca.');
  formOk = false;
}

if (formOk){
  document.form.frmPesquisa.submit();
}
}

function desmarcarRadio(){
document.getElementById('radTipo1').checked = false;
document.getElementById('radTipo2').checked = false;
}

function marcarRadio(radNum){
if (radNum == "1"){
  document.getElementById('radTipo2').checked = false;
  document.getElementById('radTipo1').checked = true;
}
else if (radNum == "2") {
  document.getElementById('radTipo1').checked = false;
  document.getElementById('radTipo2').checked = true;
}
}

function abreIframe(radValue){
if (radValue == "1"){
  divTexto.style.display = 'none';
  divIframe.style.display = 'block';
  divCodigo.style.display = 'block';
  ifrmBusca.location = 'busca_avancada_alugueis.asp';
}
else if (radValue == "2"){
  divTexto.style.display = 'none';
  divIframe.style.display = 'block';
  divCodigo.style.display = 'block';
  ifrmBusca.location = 'busca_avancada_vendas.asp';
}
}

function trocaDiv(num){
	if (num == 1){
			getObj('obox1').style.display = 'none';
			getObj('obox2').style.display = 'block';
			getObj('obox3').style.display = 'none';
			tipoBusca(2);
		
	}
	if (num == 2){
			getObj('obox1').style.display = 'none';
			getObj('obox2').style.display = 'none';
			getObj('obox3').style.display = 'block';
			tipoBusca(1);
	}	
}

function abreDiv(num){
	if (num == 1){
			getObj('esqueci_senha').style.display = 'block';
			getObj('recuperar').style.display = 'block';
			
	}
}


function PopUpHorarioCarnaval() {
		myWindowHandle = window.open('horarios_carnaval.html','Horários','width=734,height=900,top=2,left=300,toolbar=no,scrollbars=yes,status=yes');
}

function ValidaFormVendas(passForm) {
	var marcouregiao = false;
  var codOk = false;
	var CodCidade = document.getElementById('CodCidade').value;
	var CodigoImovel = document.getElementById('CodigoImovel').value;

  if (CodigoImovel != '') {
    codOk = true;
  }
  
  if (!codOk) {
    if (CodCidade=='') {
  	  alert('Você deve escolher uma cidade!');
  		return false
  	}

    if (CodCidade.toLowerCase()=='porto alegre') {
    	for (var i = 1; i < 7; i = i + 1) {
	    	var situacao = eval('document.forms[\'Pesquisa\'].Reg' + i + '.checked');
		    if (situacao) {
  			  marcouregiao = true
    		}
  	  }
  	  if (!marcouregiao) {
    	  alert('Pelo menos uma região deve ser selecionada!')
	    	return false
    	}
    }	
  }

  return true
}


function ValidaForm(passForm) {
  var marcouregiao = false;
  var codOk = false;
	var CodCidade = document.getElementById('CodCidade').value;
	var CodigoImovel = document.getElementById('CodigoImovel').value;
	
  if (CodigoImovel != '') {
    codOk = true;
  }
  
  if (!codOk) {
    if (CodCidade=='home.asp?InCdTipoBusca=2') {
  	  alert('Você deve escolher uma cidade!');
  		return false
  	}
  
    if (CodCidade=='07198'){
  	  for (var i = 1; i < 7; i = i + 1) {
    		var situacao = eval('document.forms[\'Pesquisa\'].Reg'+i+'.checked');	
    		if (situacao) {
      		marcouregiao = true;
    		}
    	}
      if (!marcouregiao){
        alert('Pelo menos uma região deve ser selecionada!');
   	    return false;
      }
    }
  }

  return true
}

function hiddeSelectBoxesBusca(){
	if(document.all){
		document.getElementById("select_boxes").style.display = 'none';
	}
}
function showSelectBoxesBusca(){
 if(document.all){
	document.getElementById("select_boxes").style.display = '';
  }
}



function carregaBuscaAvancada(){
var divIframe = document.getElementById('divIframe');
var divCodigo = document.getElementById('divCodigo');
//var divTexto = document.getElementById('divTexto');
var req = new XMLHttpRequest();
if (req) {

  req.onreadystatechange = function() {
		
    if (req.readyState == 4 && (req.status == 200 || req.status == 304)) {
		//alert("debug");
		removeContent('divIframe');
		divIframe.innerHTML = req.responseText;
    }
  };
  
  //divTexto.style.display = 'none';
  divIframe.style.display = 'block';
  divCodigo.style.display = 'block';
  req.open('GET', 'busca_avancada_alugueis.asp',true);
  req.send(null);
}
document.getElementById('InCdTipoBusca').value = 1;
document.getElementById('codCidade').value = "";
document.getElementById('valor').value = "";
document.getElementById('codigotipoimovel').value = "";
document.getElementById('bairros').value = "";
}

function submitBuscaAvancada(){
var formOk;
formOk = false;
var codCidade = document.getElementById('codCidade').value;
var codTipo = document.getElementById('codigotipoimovel').checked;
if (codCidade != "") {
  formOk = true;
}
 else {
  alert('Por favor, selecione uma ou mais localidades.');
  formOk = false;
}

if (formOk){
	//document.form.frmPesquisa.action = "resultado_busca_avancada.asp"; 
	document.form.frmPesquisa.submit();
}
}

