 

var netscape = "";
ver = navigator.appVersion; len = ver.length;
for(iln = 0; iln < len; iln++) if (ver.charAt(iln) == "(") break;
  netscape = (ver.charAt(iln+1).toUpperCase() != "C");

function $(id) {
  return document.getElementById(id);
}

function display(obj, v) {
  obj.style.display = v;
}

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 Numeros(e) {
	tecla = (netscape) ? e.which : event.keyCode;
	if (tecla == 17)
	return false;

	if (tecla > 47 && tecla < 58)
	return true;
	else {
		if (tecla == 8 || tecla == 9 || tecla == 0)
		return true;
		else
		return false;
	}
}

function Letras(e) {
	
	tecla = (netscape) ? e.which : event.keyCode;
	ctrl = (netscape) ? e.ctrlKey : event.ctrlKey;

	if ((tecla >= 65 && tecla <= 90) || (tecla > 96 && tecla < 123))
		return true;
	else {
		if (tecla == 8 || tecla == 9 || tecla == 0)
			return true;
		else
			return false;	
	}
}

function antiCtrl(e) {
	ctrl = (netscape) ? e.ctrlKey : event.ctrlKey;
	if (ctrl)
	return false;
	else
	return true;
}

function formata_reais(fld, milSep, decSep, n, e) {
	if (fld.value.length < n) {
		var sep = 0;
		var key = '';
		var i = j = 0;
		var len = len2 = 0;
		var strCheck = '0123456789';
		var aux = aux2 = '';
		var whichCode = (window.Event) ? e.which : event.keyCode;
		if (whichCode == 13 || whichCode == 0) return true;
		key = String.fromCharCode(whichCode);// Valor para o cï¿½digo da Chave
		if (strCheck.indexOf(key) == -1) return false; // Chave invï¿½lida
		len = fld.value.length;
		for (i = 0; i < len; i++)
			if ((fld.value.charAt(i) != '0') && (fld.value.charAt(i) != decSep)) break;
				aux = '';

		for(; i < len; i++)
			if (strCheck.indexOf(fld.value.charAt(i))!=-1) aux += fld.value.charAt(i);
				aux += key;

		len = aux.length;
		if (len == 0) fld.value = '';
		if (len == 1) fld.value = '0'+ decSep + '0' + aux;
		if (len == 2) fld.value = '0'+ decSep + aux;
		if (len > 2) {
			aux2 = '';
			for (j = 0, i = len - 3; i >= 0; i--) {
				if (j == 3) {
					aux2 += milSep;
					j = 0;
				}
			aux2 += aux.charAt(i);
			j++;
			}
			fld.value = '';
			len2 = aux2.length;
			for (i = len2 - 1; i >= 0; i--)
				fld.value += aux2.charAt(i);
				
			fld.value += decSep + aux.substr(len - 2, len);
		}
	return false;
	}
}

function apagaCampo(e)
{
 	var obj = (netscape) ? e.target : event.srcElement;
 	var tecla = (netscape) ? e.which : event.keyCode;
	var ctrl = (netscape) ? e.ctrlKey : event.ctrlKey;

	if (ctrl)
	{
 		if (netscape)
 			e.preventDefault();
 		else
 			event.returnValue = false;
	}

	if (tecla == 46 || tecla == 8)
	{
 		obj.value = "";
	}
}

function antiPaste(e)
{
	var ctrl = (netscape) ? e.ctrlKey : event.ctrlKey;

	if (ctrl)
	{
 		if (netscape)
 			e.preventDefault();
 		else
 			event.returnValue = false;
	}
}

// Detalhes do Imóvel
 
function DetalhesImovel(idimovel,url) 
{
	window.location = url + '/detalhe/detalhe/idimovel/' + idimovel;

}

function formata_reais(fld, milSep, decSep, n, e) {
	if (fld.value.length < n) {
		var sep = 0;
		var key = '';
		var i = j = 0;
		var len = len2 = 0;
		var strCheck = '0123456789';
		var aux = aux2 = '';
		var whichCode = (window.Event) ? e.which : event.keyCode;
		if (whichCode == 13 || whichCode == 0) return true;
		key = String.fromCharCode(whichCode);// Valor para o cï¿½digo da Chave
		if (strCheck.indexOf(key) == -1) return false; // Chave invï¿½lida
		len = fld.value.length;
		for (i = 0; i < len; i++)
			if ((fld.value.charAt(i) != '0') && (fld.value.charAt(i) != decSep)) break;
				aux = '';

		for(; i < len; i++)
			if (strCheck.indexOf(fld.value.charAt(i))!=-1) aux += fld.value.charAt(i);
				aux += key;

		len = aux.length;
		if (len == 0) fld.value = '';
		if (len == 1) fld.value = '0'+ decSep + '0' + aux;
		if (len == 2) fld.value = '0'+ decSep + aux;
		if (len > 2) {
			aux2 = '';
			for (j = 0, i = len - 3; i >= 0; i--) {
				if (j == 3) {
					aux2 += milSep;
					j = 0;
				}
			aux2 += aux.charAt(i);
			j++;
			}
			fld.value = '';
			len2 = aux2.length;
			for (i = len2 - 1; i >= 0; i--)
				fld.value += aux2.charAt(i);
				
			fld.value += decSep + aux.substr(len - 2, len);
		}
	return false;
	}
}

function trim(str, charlist) {
    var whitespace, l = 0, i = 0;
    str += '';
    
    if (!charlist) {
        // default list
        whitespace = " \n\r\t\f\x0b\xa0\u2000\u2001\u2002\u2003\u2004\u2005\u2006\u2007\u2008\u2009\u200a\u200b\u2028\u2029\u3000";
    } else {
        // preg_quote custom list
        charlist += '';
        whitespace = charlist.replace(/([\[\]\(\)\.\?\/\*\{\}\+\$\^\:])/g, '\$1');
    }
    
    l = str.length;
    for (i = 0; i < l; i++) {
        if (whitespace.indexOf(str.charAt(i)) === -1) {
            str = str.substring(i);
            break;
        }
    }
    
    l = str.length;
    for (i = l - 1; i >= 0; i--) {
        if (whitespace.indexOf(str.charAt(i)) === -1) {
            str = str.substring(0, i + 1);
            break;
        }
    }
    return whitespace.indexOf(str.charAt(0)) === -1 ? str : '';
}

/**
  Classe com métodos estáticos
*/

function Util() {
}

Util.pesquisar = function(obj, url)
{
  var tag = trim(obj.form.elements['txt_busca'].value);
  var categoria = obj.form.elements['categoria'].value;
  
  if (tag == "")
    window.location = url;
  else
     window.location = url + '/categoria/' + categoria + '?tag=' + tag;
}

Util.noSubmit = function(e)
{
  var tecla = (netscape) ? e.which : event.keyCode;
  var obj = (netscape) ? e.target : event.srcElement;
  
  if (tecla == 13)
  {
    obj.form.elements['pesquisar'].click();
    if (netscape)
      e.preventDefault();
    else
      event.returnValue = false;
  }
}

function organizeList()
{
	var tr = $('listcontent').getElementsByTagName("TR");
	for (var i=0; i<tr.length; i++)
	{
		var td = tr[i].getElementsByTagName("TD");
		for (var x=0; x<td.length; x++)
		{
			if (!td[x].firstChild)
				break;

			var str_msg = td[x].firstChild.nodeValue;
			var int_strlen = (str_msg != null) ? str_msg.length : 0;
			
			td[x].innerHTML = '<span></span>';
			for (var y=0; y<int_strlen; y++) {
				td[x].firstChild.innerHTML += str_msg.substring(y, y+1);
				var limite = td[x].offsetWidth - 30;

				if (td[x].firstChild.offsetWidth > limite) {
					if (td[x].firstChild.innerHTML.toString().length < int_strlen)	// new line
						td[x].firstChild.innerHTML += "...";
					break;
				}
			}
		}
	}
}
	
var Xoffset = -140;   
var Yoffset = 10;
var yyy = -1000;


function get_mouse(e){	
	if (netscape) {
		var x = e.pageX;
		var y = e.pageY;
	}
	else {
		var x = event.x+document.body.scrollLeft;
		var y = event.y+document.body.scrollTop;
	}	
	document.getElementById('extra').style.left = x + Xoffset;
	document.getElementById('extra').style.top = y + yyy;
}
	

function popup(nom, msg){
	var content=
	"<TABLE WIDTH=240 BORDER=0 CELLPADDING=5 CELLSPACING=0 class='DescricaoImovel'>"+
	"<TR>"+
	"<TD ALIGN=left class=DescricaoTexto>"+
	"<b>"+nom+"</b>"+
	"<hr>"+
	" "+msg+" "
	"</TD>"+
	"</TR>"+
	"</TABLE>";

	yyy = Yoffset;
	document.getElementById('extra').innerHTML = content;
	document.getElementById('extra').style.display = "block";
}

function kill(){
	yyy = -1000;
	document.getElementById('extra').style.display = "none";
}

function Imobiliaria() {}

Imobiliaria.buscar = function()
{
  // Abertura de janela
  var listView = new ListView();
  listView.open('Localizar Imobiliárias');
  
  // Eventos
  listView.submit.onclick = function()
  {
    listView.addLoading();
    
    var parametros = 'nome=' + escape(listView.textBox.value);
    Ajax.doPost("../admin/imobiliaria/json", parametros, function()
    {
      if (Ajax.getInstance().readyState == 4)
      {
        if (Ajax.getInstance().status == 200)
        {
          /** 
          * Largura total 394px
          * Dividir entre as colunas abaixo
          */
          var cabecalho = [
                    {value: 'nomefantasia', label: 'Nome fantasia', width: '184'},
                    {value: 'bairro', label: 'Bairro', width: '130'},
                    {value: 'cidade', label: 'Cidade', width: '80'},
                ];
          
          var jsonData = eval('(' + Ajax.getInstance().responseText + ')');
          listView.montarGrid(cabecalho, jsonData, "idimobiliaria", function() {
            var idimobiliaria = this.parentNode.getElementsByTagName("INPUT")[0].value;
            var nomefantasia = this.parentNode.getElementsByTagName("TD")[0].getElementsByTagName("SPAN")[0].firstChild.nodeValue;
            document.forms[0].elements["idimobiliaria"].value = idimobiliaria;
            $('imobiliaria').innerHTML = nomefantasia;
            listView.close();
          });
        }
        listView.addFieldsHeader();
        Ajax.next();
      }
    });
  }
  
  listView.submit.click();	// Ao abrir, puxar informações
}

function liberaImobiliaria(valor)
{
    if ((valor == "Administrador") || (valor == ""))
    {
        display($('containerImobiliaria'), 'none');
        document.forms[0].elements['idimobiliaria'].value = 0;
    }
    else
    {
        display($('containerImobiliaria'), 'block');
    }
}

function buscarForm()
{
	document.form1.action = url + '/index/buscar';
	document.form1.submit();
}

function FormataNumeroMoeda(pValor, SiglaMoeda)
{
	pValor = parseFloat(RetiraCaracterNumeroMoeda(pValor))
	pValor = (Math.round(pValor * 100))/100;
	pValor = pValor.toString();

	tamanho = pValor.length;	
	if (pValor.indexOf(".") > -1) 
	{
	    decimal = pValor.indexOf(".");		
	    pValor = pValor.replace(".", ",");         
	    casadecimal = pValor.substring(decimal)
	}
	else
	{
		decimal = tamanho;
		casadecimal = ',00'
	}
		
	casadosmil = pValor.substring(decimal-3, decimal);
	if (casadosmil == '')
		casadosmil = '0';
		
	casadosmilhao = pValor.substring(decimal-6, decimal-3);
	if (casadosmilhao != '')
		casadosmilhao = casadosmilhao + '.';
	
	casadosbilhao = pValor.substring(decimal-9, decimal-6);
	if (casadosbilhao != '')
		casadosbilhao = casadosbilhao + '.';
		
	casadostrilhao = pValor.substring(decimal-12, decimal-9);
	if (casadostrilhao != '')
		casadostrilhao = casadostrilhao + '.';

	if (SiglaMoeda != '')
		SiglaMoeda = SiglaMoeda + ' ';
	
	ValorFormatado = SiglaMoeda + casadostrilhao + casadosbilhao + casadosmilhao + casadosmil + casadecimal;
	return ValorFormatado;    
}

function AddFavoritos(idimovel,url)
{
	window.frames['iframefake'].location.href = url + '/preferencia/addfavoritos/idimovel/'+ idimovel;
	
}


function ExibeImovel(tipoimovel){
	if(tipoimovel == 'residenciais'){
		document.getElementById('residenciais').style.display="block";
		document.getElementById('residenciais').style.textDecoration="underline";
		document.getElementById('comerciais').style.display="none";
		document.getElementById('comerciais').style.textDecoration="none";
		
	}
	
	if(tipoimovel == 'comerciais'){
		document.getElementById('comerciais').style.display="block";
		document.getElementById('comerciais').style.textDecoration="underline";
		document.getElementById('residenciais').style.display="none";
		document.getElementById('residenciais').style.textDecoration="none";
		
		
	}

}

function MascaraCep(e,src,mask) {        
	if(window.event) { _TXT = e.keyCode; }
	else if(e.which) { _TXT = e.which; }        
	
	if(_TXT > 47 && _TXT < 58) {   
		var i = src.value.length; 
		var saida = mask.substring(0,1); 
		var texto = mask.substring(i)  
			if (texto.substring(0,1) != saida) { 
				src.value += texto.substring(0,1); 
			}      
		
			return true; 
	} else { 
		if (_TXT != 8) { return false; }   
		else { return true; }        
	}
}

function RetiraCaracterCep(pValor){
	pValor = pValor.replace('-', '');
	return pValor;
}


function formataMoeda(objTextBox, SeparadorMilesimo, SeparadorDecimal, e){
    var sep = 0;
    var key = '';
    var i = j = 0;
    var len = len2 = 0;
    var strCheck = '0123456789';
    var aux = aux2 = '';
    var whichCode = (window.Event) ? e.which : e.keyCode;    
    // 13=enter, 8=backspace as demais retornam 0(zero)
    // whichCode==0 faz com que seja possivel usar todas as teclas como delete, setas, etc    
    if ((whichCode == 13) || (whichCode == 0) || (whichCode == 8))
    	return true;
    key = String.fromCharCode(whichCode); // Valor para o código da Chave
 
 
    if (strCheck.indexOf(key) == -1) 
    	return false; // Chave inválida
    len = objTextBox.value.length;
    for(i = 0; i < len; i++)
        if ((objTextBox.value.charAt(i) != '0') && (objTextBox.value.charAt(i) != SeparadorDecimal)) 
        	break;
    aux = '';
    for(; i < len; i++)
        if (strCheck.indexOf(objTextBox.value.charAt(i))!=-1) 
        	aux += objTextBox.value.charAt(i);
    aux += key;
    len = aux.length;
    if (len == 0) 
    	objTextBox.value = '';
    if (len == 1) 
    	objTextBox.value = '0'+ SeparadorDecimal + '0' + aux;
    if (len == 2) 
    	objTextBox.value = '0'+ SeparadorDecimal + aux;
    if (len > 2) {
        aux2 = '';
        for (j = 0, i = len - 3; i >= 0; i--) {
            if (j == 3) {
                aux2 += SeparadorMilesimo;
                j = 0;
            }
            aux2 += aux.charAt(i);
            j++;
        }
        objTextBox.value = '';
        len2 = aux2.length;
        for (i = len2 - 1; i >= 0; i--)
        	objTextBox.value += aux2.charAt(i);
        objTextBox.value += SeparadorDecimal + aux.substr(len - 2, len);
    }
    return false;
}

function IsNumeric(strString){
	var strValidChars = "0123456789.,-";
	var strChar;
	var blnResult = true;

	if (strString.length == 0) return false;
	for (i = 0; i < strString.length && blnResult == true; i++){
		strChar = strString.charAt(i);
		if (strValidChars.indexOf(strChar) == -1){
			blnResult = false;
		}
	}
	
	return blnResult;
}

function Validar(){
	
	if(document.form2.nome.value == ''){
		document.form2.nome.focus();
		alert('Preencha o campo nome');
		return false;
	}
	
	if(document.form2.email.value == ''){
		document.form2.email.focus();
		alert('preencha o campo email');
		return false;
	} else {
		if((document.form2.email.value.indexOf('@') < 1) || (document.form2.email.value.indexOf('.') < 2)){
			document.form2.email.focus();
			alert('Email incorreto');
			return false;
		}
	}
	
	if(document.form2.telefone.value == ''){
		document.form2.telefone.focus();
		alert('Preencha o campo telefone');
		return false;
	} else {
		var er = /[0-9]{3,4}-?[0-9]{4}/;
		if (!document.form2.telefone.value.match (er)) {
		  document.form2.telefone.focus();	
		  alert ("Formato de telefone inválido!");
		  return false;
		}		
	}
		
	if(document.form2.telefonecomercial.value == ''){
		document.form2.telefonecomercial.focus();
		alert('Preencha o campo telefone comercial');
		return false;
	} else {
		var er = /[0-9]{3,4}-?[0-9]{4}/;
		if (!document.form2.telefonecomercial.value.match (er)) {
		  document.form2.telefonecomercial.focus();	
		  alert ("Formato de telefone Comercial inválido!");
		  return false;
		}		
	}	
	
	if(document.form2.qtdedormitorios.value == ''){
		document.form2.qtdedormitorios.focus();
		alert('informe quantos dormitórios há no imovel');
		return false;
	} else {
		if(isNaN(document.form2.qtdedormitorios.value)) {
			document.form2.qtdedormitorios.focus();	
			alert('Número de dormitórios Inválido!');
			return false;
		}
	}
	
	if(document.form2.qtdebanheiros.value == ''){
		document.form2.qtdebanheiros.focus();
		alert('informe quantos banheiros existem no imovel');
		return false;
	} else {
		if(isNaN(document.form2.qtdebanheiros.value)) {
			document.form2.qtdebanheiros.focus();	
			alert('Número de banheiros Inválido!');
			return false;
		}
	}
	
	if(document.form2.qtdesuites.value == ''){
		document.form2.qtdesuites.focus();
		alert('informe quantas suites existem no imóvel');
		return false;
	}  else {
		if(isNaN(document.form2.qtdesuites.value)) {
			document.form2.qtdesuites.focus();	
			alert('Número de suites Inválido!');
			return false;
		}
	}
	if(document.form2.qtdevagas.value == ''){
		document.form2.qtdevagas.focus();
		alert('informe quantas vagas há no local');
		return false;
	} else {
		if(isNaN(document.form2.qtdevagas.value)) {
			document.form2.qtdevagas.focus();	
			alert('Número de vagas Inválido!');
			return false;
		}
	}
	
	
	if(document.form2.areatotal.value != ''){
		if(IsNumeric(document.form2.areatotal.value) == false){
			document.form2.areatotal.focus();
			alert('Número de Área total Inválido!');
			return false;
		}
	}
	
	if(document.form2.areaterrenoutil.value != ''){
		if(IsNumeric(document.form2.areaterrenoutil.value) == false){
			document.form2.areaterrenoutil.focus();	
			alert('Número da Área útil Inválido!');
			return false;
		}
	}
	
	if(document.form2.valorimovel.value == ''){
		document.form2.valorimovel.focus();
		alert('informe o valor do imóvel');
		return false;
	}

	if(document.form2.referencialocal.value == ''){
		document.form2.referencialocal.focus();
		alert('preencha uma referência do local do imóvel');
		return false;
	}		
	
	if(document.form2.endereco.value == ''){
		document.form2.endereco.focus();
		alert('preencha o endereço do imóvel');
		return false;
	}
	
	if(document.form2.numero.value != ''){
		if(isNaN(document.form2.numero.value)) {
			document.form2.numero.focus();	
			alert('Número do imóvel Inválido!');
			return false;
		}
	}

	if(document.form2.bairro.value == ''){
		document.form2.bairro.focus();
		alert('preencha em que bairro o imóvel está');
		return false;
	}
	
	if(document.form2.cidade.value == ''){
		document.form2.cidade.focus();
		alert('preencha a cidade do imóvel');
		return false;
	}

	if(document.form2.cep.value == ''){
		document.form2.cep.focus();
		alert('informe o cep do imóvel');
		return false;
	} else {
			pValor = RetiraCaracterCep(document.form2.cep.value);			
			if (parseInt(pValor.length,10) < 8)
			{
				alert('O Campo cep está inválido, tem menos de 8 números.');
				document.form2.cep.focus();	
                return false;
			}	
			
	}
	
	if(document.form2.estado.value == ''){
		document.form2.estado.focus();
		alert('preencha o estado do imóvel');
		return false;
	}	
	
	if(document.form2.observacao.value == ''){
		document.form2.observacao.focus();
		alert('preencha uma observação para o imóvel');
		return false;	
	}
		document.form2.submit();
}


function ValidaContato(){
	if(document.formcontato.nome.value == ''){
		document.formcontato.nome.focus();
		alert('Preencha o campo nome');
		return false;
	}
	
	if(document.formcontato.email.value == '' && document.formcontato.telefone.value == '' && document.formcontato.telefonecomercial.value == '' && document.formcontato.telefonecelular.value == ''){
		
		document.formcontato.email.focus();
		alert('Preencha algum telefone ou seu e-mail para entrarmos em contato !');
		return false;
	} else {

		if(document.formcontato.email.value != ''){
			if((document.formcontato.email.value.indexOf('@') < 1) || (document.formcontato.email.value.indexOf('.') < 2)){
				document.formcontato.email.focus();
				alert('Email incorreto');
				return false;
			}
		}		
		
		if(document.formcontato.telefonecelular.value != ''){
			var er = /[0-9]{3,4}-?[0-9]{4}/;
			if (!document.formcontato.telefone.value.match (er)) {
			  document.formcontato.telefone.focus();
			  alert ("Formato de telefone inválido!");
			  return false;
			}	
		}
		
			
		if(document.formcontato.telefonecomercial.value != ''){
			var er = /[0-9]{3,4}-?[0-9]{4}/;
			if (!document.formcontato.telefonecomercial.value.match (er)) {
			  document.formcontato.telefonecomercial.focus();
			  alert ("Formato de telefone Comercial inválido!");
			  return false;
			}
		}
			
		if(document.formcontato.telefonecelular.value != ''){
			var er = /[0-9]{3,4}-?[0-9]{4}/;
			if (!document.formcontato.telefonecelular.value.match (er)) {
			  document.formcontato.telefonecelular.focus();
			  alert ("Formato de telefone Celular inválido!");
			  return false;
			}			
		}
		
	}
			
	if(document.formcontato.mensagem.value == ''){
		document.formcontato.mensagem.focus();
		alert('Preencha o campo mensagem');
		return false;
	}		
	
		document.formcontato.submit();
}

function Imprimir(idimovel,url){

	var width  = 990;
	var height = 650;

	var left = ((screen.width)/2)-(width/2);
	var top = ((screen.height)/2)-(height/2);

	window.open(url + '/detalhe/imprimir/idimovel/'+idimovel,'Imprimir','width='+width+', height='+height+', top='+top+', left='+left+', scrollbars=no, status=no, toolbar=no, location=no, directories=no, menubar=no, resizable=no, fullscreen=no');
	
	
}


function Ordenar(tipo,campos,url,negocio){
	if(negocio == 2){
		if(tipo == 'maior'){
			tipo = '&campo=im.valorimovelaluguel desc ';
		} 
		if(tipo == 'menor'){
			tipo = '&campo=im.valorimovelaluguel ';
		}	
	} else {
		if(tipo == 'maior'){
			tipo = '&campo=im.valorimovel desc ';
		} 
		if(tipo == 'menor'){
			tipo = '&campo=im.valorimovel ';
		}	
	}
	
		
	window.location = url + '/index/buscar/'+ campos + tipo;	
		
}

function Paginacao(pagina,campos,totalregistros,url){
	window.location = url + '/index/buscar/'+ campos + '&pagina=' + pagina + '&totalregistros=' + totalregistros;	
}

function visitaabre(){
 	document.getElementById('iframevisita').style.display='block';
}


function mascara_data(data){ 

  var mydata = ''; 
  mydata = mydata + data; 
  if (mydata.length == 2){ 
      mydata = mydata + '/'; 
      document.formvisita.data.value = mydata; 
  } 
  if (mydata.length == 5){ 
      mydata = mydata + '/'; 
      document.formvisita.data.value = mydata; 
  } 
  if (mydata.length == 10){ 
      verifica_data(); 
  } 
} 

function verifica_data () { 

dia = (document.formvisita.data.value.substring(0,2)); 
mes = (document.formvisita.data.value.substring(3,5)); 
ano = (document.formvisita.data.value.substring(6,10)); 


hoje  = new Date()
dia_hoje   = hoje.getDate()
mes_hoje   = hoje.getMonth()
ano_hoje   = hoje.getYear()


// verifica se e ano bissexto 


situacao = ""; 

// verifica se o dia e um numero
if (isNaN(dia)){ 
    situacao = "falsa"; 
} 

// verifica se o mes e um numero
if (isNaN(mes)){ 
    situacao = "falsa"; 
} 

// verifica se o ano e um numero
if (isNaN(ano)){ 
    situacao = "falsa"; 
} 


// verifica o dia valido para cada mes 
if ((dia < 01)||(dia < 01 || dia > 30) && (  mes == 04 || mes == 06 || mes == 09 || mes == 11 ) || dia > 31) { 
    situacao = "falsa"; 
} 

// verifica se o mes e valido 
if (mes < 01 || mes > 12 ) { 
    situacao = "falsa"; 
} 

// verifica se e ano bissexto 
if (mes == 2 && ( dia < 01 || dia > 29 || ( dia > 28 && (parseInt(ano / 4) != ano / 4)))) { 
    situacao = "falsa"; 
} 

// verifica se a data é menor que a data atual
if(ano < ano_hoje){
	situacao = "falsa"; 
} else {
	if(((mes == mes_hoje) || (mes < mes_hoje)) && (ano == ano_hoje)){
		situacao = "falsa";
	} else {
		if((dia < dia_hoje) &&(mes <= mes_hoje) && (ano <= ano_hoje)){
			situacao = "falsa";
		}
	}
}


if (document.formvisita.data.value == "") { 
    situacao = "falsa"; 
} 

if (situacao == "falsa") { 
    alert("Data inválida!"); 
    document.formvisita.data.focus(); 
    document.formvisita.data.value = ''; 
} 
} 

function mascara_data2(data){ 

  var mydata = ''; 
  mydata = mydata + data; 
  if (mydata.length == 2){ 
      mydata = mydata + '/'; 
      document.formproposta.datanascimento.value = mydata; 
  } 
  if (mydata.length == 5){ 
      mydata = mydata + '/'; 
      document.formproposta.datanascimento.value = mydata; 
  } 
  if (mydata.length == 10){ 
      verifica_data2(); 
  } 
} 

function verifica_data2 () { 

dia = (document.formproposta.datanascimento.value.substring(0,2)); 
mes = (document.formproposta.datanascimento.value.substring(3,5)); 
ano = (document.formproposta.datanascimento.value.substring(6,10)); 


hoje  = new Date()
dia_hoje   = hoje.getDate()
mes_hoje   = hoje.getMonth()
ano_hoje   = hoje.getYear()


// verifica se e ano bissexto 


situacao = ""; 

// verifica se o dia e um numero
if (isNaN(dia)){ 
    situacao = "falsa"; 
} 

// verifica se o mes e um numero
if (isNaN(mes)){ 
    situacao = "falsa"; 
} 

// verifica se o ano e um numero
if (isNaN(ano)){ 
    situacao = "falsa"; 
} 


// verifica o dia valido para cada mes 
if ((dia < 01)||(dia < 01 || dia > 30) && (  mes == 04 || mes == 06 || mes == 09 || mes == 11 ) || dia > 31) { 
    situacao = "falsa"; 
} 

// verifica se o mes e valido 
if (mes < 01 || mes > 12 ) { 
    situacao = "falsa"; 
} 

// verifica se e ano bissexto 
if (mes == 2 && ( dia < 01 || dia > 29 || ( dia > 28 && (parseInt(ano / 4) != ano / 4)))) { 
    situacao = "falsa"; 
} 

if (document.formproposta.datanascimento.value == "") { 
    situacao = "falsa"; 
} 

if (situacao == "falsa") { 
    alert("Data inválida!"); 
    document.formproposta.datanascimento.focus(); 
    document.formproposta.datanascimento.value = ''; 
} 
} 

function mascara_data3(data){ 

  var mydata = ''; 
  mydata = mydata + data; 
  if (mydata.length == 2){ 
      mydata = mydata + '/'; 
      document.formproposta.datanascimentoconjunge.value = mydata; 
  } 
  if (mydata.length == 5){ 
      mydata = mydata + '/'; 
      document.formproposta.datanascimentoconjunge.value = mydata; 
  } 
  if (mydata.length == 10){ 
      verifica_data3(); 
  } 
} 

function verifica_data3 () { 

dia = (document.formproposta.datanascimentoconjunge.value.substring(0,2)); 
mes = (document.formproposta.datanascimentoconjunge.value.substring(3,5)); 
ano = (document.formproposta.datanascimentoconjunge.value.substring(6,10)); 


hoje  = new Date()
dia_hoje   = hoje.getDate()
mes_hoje   = hoje.getMonth()
ano_hoje   = hoje.getYear()


// verifica se e ano bissexto 


situacao = ""; 

// verifica se o dia e um numero
if (isNaN(dia)){ 
    situacao = "falsa"; 
} 

// verifica se o mes e um numero
if (isNaN(mes)){ 
    situacao = "falsa"; 
} 

// verifica se o ano e um numero
if (isNaN(ano)){ 
    situacao = "falsa"; 
} 


// verifica o dia valido para cada mes 
if ((dia < 01)||(dia < 01 || dia > 30) && (  mes == 04 || mes == 06 || mes == 09 || mes == 11 ) || dia > 31) { 
    situacao = "falsa"; 
} 

// verifica se o mes e valido 
if (mes < 01 || mes > 12 ) { 
    situacao = "falsa"; 
} 

// verifica se e ano bissexto 
if (mes == 2 && ( dia < 01 || dia > 29 || ( dia > 28 && (parseInt(ano / 4) != ano / 4)))) { 
    situacao = "falsa"; 
} 


if (document.formproposta.datanascimentoconjunge.value == "") { 
    situacao = "falsa"; 
} 

if (situacao == "falsa") { 
    alert("Data inválida!"); 
    document.formproposta.datanascimentoconjunge.focus(); 
    document.formproposta.datanascimentoconjunge.value = ''; 
} 
} 


function mascara_hora(hora){ 
  var myhora = ''; 
  myhora = myhora + hora; 
  if (myhora.length == 2){ 
      myhora = myhora + ':'; 
      document.formvisita.hora.value = myhora; 
  } 
  if (myhora.length == 5){ 
      verifica_hora(); 
  } 
} 

function verifica_hora(){ 
  hrs = (document.formvisita.hora.value.substring(0,2)); 
  min = (document.formvisita.hora.value.substring(3,5)); 
 
  situacao = ""; 
  // verifica data e hora 
  if ((hrs < 00 ) || (hrs > 23) || ( min < 00) ||( min > 59)){ 
      situacao = "falsa"; 
  } 
   
  if (document.forms[0].hora.value == "") { 
      situacao = "falsa"; 
  } 

  if (situacao == "falsa") { 
      alert("Hora inválida!"); 
      document.formvisita.hora.focus(); 
      document.formvisita.hora.value = '';
  } 
} 

function ValidaVisita(){
	if(document.formvisita.nome.value == ''){
		document.formvisita.nome.focus();
		alert('preencha o campo nome');
		return false;
	}
	
	if(document.formvisita.email.value == ''){
		document.formvisita.email.focus();
		alert('preencha o campo email');
		return false;
	} else {
		if((document.formvisita.email.value.indexOf('@') < 1) || (document.formvisita.email.value.indexOf('.') < 2)){
			document.formvisita.email.focus();
			alert('Email incorreto');
			return false;
		}
	}		
	
	if(document.formvisita.telefone.value != ''){
		var er = /[0-9]{3,4}-?[0-9]{4}/;
		if (!document.formvisita.telefone.value.match (er)) {
		  document.formvisita.telefone.focus();
		  alert ("Formato de telefone inválido!");
		  return false;
		}			
	} else {
		  document.formvisita.telefone.focus();
		  alert ("preencha o campo telefone");
		  return false;
	}
	
	if(document.formvisita.data.value == ''){
		document.formvisita.data.focus();
		alert('insira a data na qual quer agendar a visita');
		return false;
	}		
	
	if(document.formvisita.hora.value == ''){
		document.formvisita.hora.focus();
		alert('insira a hora na qual quer agendar a visita');
		return false;
	}	
		
	
	if(document.formvisita.mensagem.value == ''){
		document.formvisita.mensagem.focus();
		alert('Escreva alguma mensagem');
		return false;
	}		
	
	if(document.formvisita.idimovel.value == ''){
		alert('Você precisa estar em algum imóvel para agendar uma visita');
		return false;
	}
	document.formvisita.submit();
 	

}

function ValidaProposta(){
	if(document.formproposta.nome.value == ''){
		document.formproposta.nome.focus();
		alert('preencha o campo nome');
		return false;
	}
	

	if(document.formproposta.email.value == ''){
		document.formproposta.email.focus();
		alert('preencha o campo email');
		return false;
	} else {
		if((document.formproposta.email.value.indexOf('@') < 1) || (document.formproposta.email.value.indexOf('.') < 2)){
			document.formproposta.email.focus();
			alert('Email incorreto');
			return false;
		}
	}	
	
	if(document.formproposta.telefone.value == ''){
		document.formproposta.telefone.focus();
		alert('Preencha o seu telefone');
		return false;
	} else {
		var er = /[0-9]{3,4}-?[0-9]{4}/;
		if (!document.formproposta.telefone.value.match (er)) {
		  document.formproposta.telefone.focus();
		  alert ("Formato de telefone inválido!");
		  return false;
		}		
	}

	if(document.formproposta.celular.value == ''){
		document.formproposta.celular.focus();
		alert('Preencha o seu celular');
		return false;
	} else {
		var er = /[0-9]{3,4}-?[0-9]{4}/;
		if (!document.formproposta.celular.value.match (er)) {
		  document.formproposta.celular.focus();
		  alert ("Formato de celular inválido!");
		  return false;
		}		
	}	

	if(document.formproposta.telefonecomercial.value == ''){
		document.formproposta.telefonecomercial.focus();
		alert('Preencha o seu telefone comercial');
		return false;
	} else {
		var er = /[0-9]{3,4}-?[0-9]{4}/;
		if (!document.formproposta.telefonecomercial.value.match (er)) {
		  document.formproposta.telefonecomercial.focus();
		  alert ("Formato de telefone Comercial inválido!");
		  return false;
		}		
	}	
	
	if(document.formproposta.cpf.value != ''){
		if(!valida_cpfcnpj(document.formproposta.cpf.value) == true){
			alert('CPF Invalido');
			document.formproposta.cpf.focus();
			return false;
		}
	}	

	if(document.formproposta.cpfconjunge.value != ''){
		if(!valida_cpfcnpj(document.formproposta.cpfconjunge.value) == true){
			alert('CPF Invalido');
			document.formproposta.cpfconjunge.focus();
			return false;
		}
	}	
	
	if(document.formproposta.emailconjunge.value != ''){
		if((document.formproposta.emailconjunge.value.indexOf('@') < 1) || (document.formproposta.emailconjunge.value.indexOf('.') < 2)){
			document.formproposta.emailconjunge.focus();
			alert('Email do conjunge incorreto');
			return false;
		}
	}	
		
	if(document.formproposta.celularconjunge.value != ''){
		var er = /[0-9]{3,4}-?[0-9]{4}/;
		if (!document.formproposta.celularconjunge.value.match (er)) {
		  document.formproposta.celularconjunge.focus();
		  alert ("Formato de celular do conjunge inválido!");
		  return false;
		}		
	}	
		
	document.formproposta.submit();
}

function DadosConjunge(civil){
	if(civil == 'casado'){
		document.getElementById('conjunge').style.width = '100%';	
		document.getElementById('conjunge').style.display = 'block';
	} else {
		document.getElementById('conjunge').style.display = 'none';	
	}
}



function ValidaNewsletter(){
	
	if(document.formemail.email.value == ''){
		document.formemail.email.focus();
		alert('preencha o campo email');
		return false;
	} else {
		if((document.formemail.email.value.indexOf('@') < 1) || (document.formemail.email.value.indexOf('.') < 2)){
			document.formemail.email.focus();
			alert('Email incorreto');
			return false;
		}
	}
		
	if(document.formnewsletter.nome.value == ''){
		document.formnewsletter.nome.focus();
		alert('Preencha o seu nome');
		return false;
	}
	
	if(document.formnewsletter.telefone.value == ''){
		document.formnewsletter.telefone.focus();
		alert('Preencha o seu telefone');
		return false;
	} else {
		var er = /[0-9]{3,4}-?[0-9]{4}/;
		if (!document.formnewsletter.telefone.value.match (er)) {
		  alert ("Formato de telefone inválido!");
		  return false;
		}		
	}	

	if(document.formnewsletter.telefonecomercial.value == ''){
		document.formnewsletter.telefonecomercial.focus();
		alert('Preencha o seu telefone comercial');
		return false;
	} else {
		var er = /[0-9]{3,4}-?[0-9]{4}/;
		if (!document.formnewsletter.telefonecomercial.value.match (er)) {
		  alert ("Formato de telefone Comercial inválido!");
		  return false;
		}		
	}		
	
	if(document.formnewsletter.celular.value == ''){
		document.formnewsletter.celular.focus();
		alert('Preencha o seu celular');
		return false;
	} else {
		var er = /[0-9]{3,4}-?[0-9]{4}/;
		if (!document.formnewsletter.celular.value.match (er)) {
		  alert ("Formato de Celular inválido!");
		  return false;
		}		
	}
	
	
	
	document.formnewsletter.email.value = document.formemail.email.value;
	document.formnewsletter.submit();
}

	function showAddress(address){
		var map = new GMap2(document.getElementById("map_canvas"));
		var geocoder = new GClientGeocoder();
		var mapTypeControl = new GMapTypeControl();
		var topRight = new GControlPosition(G_ANCHOR_TOP_RIGHT, new GSize(10,10));
		var bottomRight = new GControlPosition(G_ANCHOR_BOTTOM_RIGHT, new GSize(10,10));
			map.addControl(mapTypeControl, topRight);
			GEvent.addListener(map, "dblclick", function() {
				map.removeControl(mapTypeControl);
         		map.addControl(new GMapTypeControl(), bottomRight);
        	});
        		map.addControl(new GSmallMapControl());

        if (geocoder) {
        	geocoder.getLatLng(address,
				function(point){
					if (!point) {
						alert("Endereco nao encontrado!");
					} else {
						map.setCenter(point, 15);
            		}
          		}
        	);
      	}
    }
    
    function EmailVerifica(){
    	document.formemail.submit();
    }
    

	function MudarValor(valor){
		if(valor == 1){
			document.getElementById('aluguelmin').style.display = 'none';	
			document.getElementById('aluguelmax').style.display = 'none';	
			document.getElementById('valormin').style.display = 'block';	
			document.getElementById('valormax').style.display = 'block';	
			document.formBusca.tiponegocio.value = valor;
		} else if(valor == 2){
			document.getElementById('aluguelmin').style.display = 'block';	
			document.getElementById('aluguelmax').style.display = 'block';	
			document.getElementById('valormin').style.display = 'none';	
			document.getElementById('valormax').style.display = 'none';	
			document.formBusca.tiponegocio.value = valor;
		}
	
	}
	
	function TipoArea(tipoimovel){
		if(tipoimovel == 1){
			document.getElementById('areautil').style.display = 'block';
			document.getElementById('areaconstruida').style.display = 'none';
			document.getElementById('textoarea').innerHTML = 'Área Útil';
		} else if(tipoimovel == 2){
			document.getElementById('areautil').style.display = 'none';
			document.getElementById('areaconstruida').style.display = 'block';
			document.getElementById('textoarea').innerHTML = 'Área Construida';
		}
	}
	
	function BuscaNegocioImovel(idcategoria){
		window.frames['Busca'].BuscaNegocioImovel(idcategoria);
	}
	
	function BuscaBairro(idcategoria, idsubcategoria){	
		window.frames['Busca'].BuscaBairro(idcategoria, idsubcategoria);	
	}
	
	function MontaNegocio(ArrNegocios){
		var tiponegocio = document.formBusca.tiponegocio;
		tiponegocio.options.length = 0;
		for(i=0;i<ArrNegocios.length;i+=2)
		{
			tiponegocio.options[i/2] = new Option(ArrNegocios[i],ArrNegocios[i+1]);
		}
	}
	
	function MontaBairro(ArrBairro){
		var Bairro = document.formBusca.bairro;
		Bairro.options.length = 0;
		for(i=0;i<ArrBairro.length;i+=2)
		{
			Bairro.options[i/2] = new Option(ArrBairro[i],ArrBairro[i+1]);
		}
	}
	
	function BuscaTipoImovel(idcategoria, negocio){
		window.frames['Busca'].BuscaTipoImovel(idcategoria, negocio);
	}
	
	function MontaTipo(ArrTipo){
		var Tipo = document.formBusca.idsubcategoria;
		Tipo.options.length = 0;
		for(i=0;i<ArrTipo.length;i+=2)
		{
			Tipo.options[i/2] = new Option(ArrTipo[i],ArrTipo[i+1]);
		}
	}
		
	function BuscaValor(){
		window.frames['Busca'].BuscaValor(arguments[0], arguments[1], arguments[2], arguments[3]);
	}
	
	function MontaValor(ArrValor, nomevalor){
		var SelectValor = eval('document.formBusca.' + nomevalor);
		SelectValor.options.length = 0;
		for(i=0;i<ArrValor.length;i+=2)
		{
			SelectValor.options[i/2] = new Option(ArrValor[i],ArrValor[i+1]);
		}
	}	
	
	function showHide(ID,IDSPAN){
		if (document.getElementById(ID).style.display == 'none') {
			document.getElementById(ID).style.display = 'block';
			document.getElementById(IDSPAN).innerHTML = '';

		} else {  
			document.getElementById(ID).style.display = 'none';
			document.getElementById(IDSPAN).innerHTML = ' Selecione ';
		}
	}
	
	function HideBairro(ID){
		if (document.getElementById(ID).style.display == 'none') {
			document.getElementById(ID).style.display = 'block';
		} else {  
			document.getElementById(ID).style.display = 'none';
		}
	}	

	function showHideFavoritos(ID,IDSPAN){
		if (document.getElementById(ID).style.display == "none") {
			
			if(document.getElementById('imoveis').value != 1){
				alert('Você ainda não adicionou nenhum imóvel a sua lista de favoritos para poder compara-los !')	
				return false;
			} else {
					document.getElementById(ID).style.display = "block";
					document.getElementById(IDSPAN).innerHTML = "<img src='../public/imagens/bt_compare_esconder.gif' style='cursor:pointer;'>";
			}

		} else {  
			document.getElementById(ID).style.display = "none";
			document.getElementById(IDSPAN).innerHTML = "<img src='../public/imagens/bt_compare.gif' style='cursor:pointer;'>";
		}
	}	
	

	
	function ValidarPreferencia(){
		if(document.formPreferencia.nome.value == ''){
			document.formPreferencia.nome.focus();
			alert('Preencha o seu nome');
			return false;
		}
		
		if(document.formPreferencia.email.value == ''){
			document.formPreferencia.email.focus();
			alert('preencha o campo email');
			return false;
		} else {
			if((document.formPreferencia.email.value.indexOf('@') < 1) || (document.formPreferencia.email.value.indexOf('.') < 2)){
				document.formPreferencia.email.focus();
				alert('Email incorreto');
				return false;
			}
		}
		
		if(document.formPreferencia.telefone.value == ''){
			document.formPreferencia.telefone.focus();
			alert('Preencha o campo telefone');
			return false;
		} else {
			var er = /[0-9]{3,4}-?[0-9]{4}/;
			if (!document.formPreferencia.telefone.value.match (er)) {
			  document.formPreferencia.telefone.focus();	
			  alert ("Formato de telefone inválido!");
			  return false;
			}		
		}		
		
	
		if(document.formPreferencia.mensagem.value == ''){
			document.formPreferencia.mensagem.focus();
			alert('Preencha a sua mensagem');
			return false;
		}	
		
		if(document.formPreferencia.imoveis.value != 1){
			alert('antes de enviar um email aos favoritos, adicione um imóvel aos seus favoritos !');	
			return false;
		}	
			document.formPreferencia.submit();
	}

	
	
function valida_cpfcnpj(pValor)
{
	pcpfcnpj = pValor;

	if (pcpfcnpj.length == 11)
 	{
		pcpf = pcpfcnpj;
		if (pcpf.length != 11) 
		{
			sim=false
		}
 		else 
 		{
 			sim=true
 		}

  		if (sim)  // valida o primeiro digito
  		{
  			for (i=0;((i<=(pcpf.length-1))&& sim); i++)
  			{
   				val = pcpf.charAt(i)
   				if ((val!="9")&&(val!="0")&&(val!="1")&&(val!="2")&&(val!="3")&&(val!="4") && (val!="5")&&(val!="6")&&(val!="7")&&(val!="8")) 
   				{
   					sim=false
   				}
   			}

	   		if (sim)
			{
	    		soma = 0
	    		for (i=0;i<=8;i++)
	    		{
	     			val = eval(pcpf.charAt(i))
	     			soma = soma + (val*(i+1))
	    		}
	
	    		resto = soma % 11
	    		if (resto>9) 
	    			dig = resto -10
	    		else  
	    			dig = resto
	    		if (dig != eval(pcpf.charAt(9))) 
	    		{ 
	    			sim=false 
	    		}
	   			else   // valida o segundo digito
	    		{
	     			soma = 0
					for (i=0;i<=7;i++)
	     			{
	     				val = eval(pcpf.charAt(i+1))
	      				soma = soma + (val*(i+1))
	    			}
	
	     			soma = soma + (dig * 9)
	    			resto = soma % 11
	     			if (resto>9) 
	     				dig = resto -10
	     			else  
	     				dig = resto
	   				if (dig != eval(pcpf.charAt(10))) 
	   				{
	   					sim = false 
	   				}
	    			else 
	    				sim = true
	   			}
	   		}
	  	}
		if (sim) 
	  	{
	  		if      (pcpf == 11111111111) return false;
	  		else if (pcpf == 22222222222) return false;
	  		else if (pcpf == 33333333333) return false;
	  		else if (pcpf == 44444444444) return false;
	  		else if (pcpf == 55555555555) return false;
	  		else if (pcpf == 66666666666) return false;
	  		else if (pcpf == 77777777777) return false;
	  		else if (pcpf == 88888888888) return false;
	  		else if (pcpf == 99999999999) return false;
	  		else if (pcpf == 00000000000) return false;
	  		else
	  			return true;
	  	}
	  	else
	  	{
			return false;
	  	}
	}
	else if((pcpfcnpj.length == 14))
 	{
		pcgc = pcpfcnpj;

		// verifica o tamanho
		if (pcgc.length != 14)
		{
			sim=false
		}
		else 
		{
			sim=true
		}

		if (sim)  // verifica se e numero
		{
			for (i=0;((i<=(pcgc.length-1))&& sim); i++)
			{
				val = pcgc.charAt(i)
				if ((val!="9")&&(val!="0")&&(val!="1")&&(val!="2")&&(val!="3")&&(val!="4") && (val!="5")&&(val!="6")&&(val!="7")&&(val!="8")) 
				{
					sim=false
				}
			}
		}
		if (sim)  // se for numero continua
		{
			m2 = 2
			soma1 = 0
			soma2 = 0
			for (i=11;i>=0;i--)
			{
				val = eval(pcgc.charAt(i))
				m1 = m2
				if (m2<9) 
				{ 
					m2 = m2+1
				}
				else 
				{
					m2 = 2
				}
				soma1 = soma1 + (val * m1)
				soma2 = soma2 + (val * m2)
			}  // fim do for de soma

  			soma1 = soma1 % 11
			if (soma1 < 2) 
			{  
				d1 = 0
			}
			else 
			{ 
				d1 = 11- soma1
			}

			soma2 = (soma2 + (2 * d1)) % 11
			if (soma2 < 2) 
			{ 
				d2 = 0
			}
			else 
			{ 
				d2 = 11- soma2
			}

			if ((d1==pcgc.charAt(12)) && (d2==pcgc.charAt(13)))
			{ 
		  		if      (pcgc == 11111111111111) return false;
		  		else if (pcgc == 22222222222222) return false;
		  		else if (pcgc == 33333333333333) return false;
		  		else if (pcgc == 44444444444444) return false;
		  		else if (pcgc == 55555555555555) return false;
		  		else if (pcgc == 66666666666666) return false;
		  		else if (pcgc == 77777777777777) return false;
		  		else if (pcgc == 88888888888888) return false;
		  		else if (pcgc == 99999999999999) return false;
		  		else if (pcgc == 00000000000000) return false;
		  		else
		  			return true;
			}
			else 
			{
				return false;
			}
		}
		if (!sim)
			return false;
		else
		{
	  		if      (pcgc == 11111111111111) return false;
	  		else if (pcgc == 22222222222222) return false;
	  		else if (pcgc == 33333333333333) return false;
	  		else if (pcgc == 44444444444444) return false;
	  		else if (pcgc == 55555555555555) return false;
	  		else if (pcgc == 66666666666666) return false;
	  		else if (pcgc == 77777777777777) return false;
	  		else if (pcgc == 88888888888888) return false;
	  		else if (pcgc == 99999999999999) return false;
	  		else if (pcgc == 00000000000000) return false;
	  		else
	  			return true;
		}
	}
	else
		return false;
}

function checar(valor){
	if(valor == 1){
		document.formBusca.selecionatodos.value = 0;
		
		for(cont = 0;cont <= document.formBusca.bairros.length; cont++){
			if(document.formBusca.bairros[cont])
				document.formBusca.bairros[cont].checked = false;
		}
			
	} else {
		document.formBusca.selecionatodos.value = 1;
		for(cont = 0;cont <= document.formBusca.bairros.length; cont++){
			if(document.formBusca.bairros[cont])
				document.formBusca.bairros[cont].checked = true;
		}		
	}
}

function resolucao(){
	if(screen.width == 1440)
		document.getElementById("logo").style.left = '23%';
		
	if(screen.width == 1280)		
		document.getElementById("logo").style.left = '19%';

	if(screen.width == 1152)		
		document.getElementById("logo").style.left = '16%';
		
	if(screen.width == 1024)		
		document.getElementById("logo").style.left = '12%';			

	if(screen.width == 960)		
		document.getElementById("logo").style.left = '9%';						

	if(screen.width == 800)		
		document.getElementById("logo").style.left = '1%';									
}
