function adicionaAoEventoLoad(fn) {
	if (window.attachEvent) {
		window.attachEvent("onload", fn);
	} else {
		window.addEventListener("load", fn, false);
	}
}

function googleVideo(docId) {
	document.getElementById("videoScreen").innerHTML = "<p style=\"text-align:center; text-indent:0;\"><embed style=\"width:400px; height:326px;\" id=\"VideoPlayback\" type=\"application/x-shockwave-flash\" src=\"http://video.google.com/googleplayer.swf?docId=" + docId + "&hl=pt-BR\" flashvars=\"autoPlay=true\"><\/embed><\/p>";
}

function multimedia(vCod) {
	strMediaPlayer = "";
	videourl = "/midia/asxByCod.asp?vCod="+vCod;
	mpvar = 0;

	var windowsmedia = new Object();
	windowsmedia.installed = false;
	windowsmedia.version = '0.0';

	var gkoaxwma = false;
	if (navigator.plugins && navigator.plugins.length) {
		for (x=0; x<navigator.plugins.length; x++) {
			if (navigator.plugins[x].name.indexOf('ActiveX') != -1 && window.GeckoActiveXObject) {
				gkoaxwma=true;
				break; 
			}
		}
	}

	if (window.ActiveXObject || gkoaxwma) {
		try {
			oWMP=new AXO('WMPlayer.OCX.7');
			if (oWMP) {
				windowsmedia.installed=true;
				parseFloat(oWMP.versionInfo);
				windowsmedia.version=parseFloat(oWMP.versionInfo);
				if (windowsmedia.version.toString().length == 1) windowsmedia.version+='.0';
			}
		} catch(e) {
		}
	} else if (navigator.plugins && navigator.plugins.length) {
		for (x=0; x<navigator.plugins.length; x++) {
			if (navigator.plugins[x].name.indexOf('Windows Media') != -1) {
				windowsmedia.installed=true;
				break;
			}
		}
	}

	windowsmedia.ver7 = (windowsmedia.installed && parseInt(windowsmedia.version) >= 7) ? true:false;
	if (windowsmedia.ver7) {
		mpvar=1;
		strMediaPlayer += '<object width="400" height="360" id="wmp" name="wmp" classid="CLSID:6BF52A52-394A-11d3-B153-00C04F79FAA6" standby="Carregando..." type="application/x-oleobject">';
		strMediaPlayer += '<param name="uiMode" value="full">';
		strMediaPlayer += '<param name="autoStart" value="true">';
		strMediaPlayer += '<param name="URL" value="'+videourl+'">';
		strMediaPlayer += '</object>';
	} else if (windowsmedia.installed) {
		mpvar=2;
		strMediaPlayer += '<OBJECT width="400" height="360" ID="wmp" name="wmp" CLASSID="CLSID:22d6f312-b0f6-11d0-94ab-0080c74c7e95" CODEBASE="http://activex.microsoft.com/activex/controls/mplayer/en/nsmp2inf.cab#Version=6,4,5,715" standby="Carregando..." TYPE="application/x-oleobject">';
		strMediaPlayer += '<PARAM NAME="FileName" VALUE="'+videourl+'">';
		strMediaPlayer += '<PARAM NAME="AutoStart" VALUE="True">';
		strMediaPlayer += '<PARAM NAME="ShowDisplay" VALUE="False">';
		strMediaPlayer += '<PARAM NAME="ShowControls" VALUE="True">';
		strMediaPlayer += '<PARAM NAME="ShowStatusBar" VALUE="True">';
		strMediaPlayer += '<PARAM NAME="ShowTracker" VALUE="True">';
		strMediaPlayer += '<embed name="wmp" ';
		strMediaPlayer += 'type="application/x-mplayer2" pluginspage="http://www.microsoft.com/windows/windowsmedia/download/default.asp?DispLang=br" ';
		strMediaPlayer += 'filename="'+videourl+'" ';
		strMediaPlayer += 'src="'+videourl+'" ';
		strMediaPlayer += 'ShowControls=1 ';
		strMediaPlayer += 'ShowDisplay=0 ';
		strMediaPlayer += 'ShowStatusBar=1 ';
		strMediaPlayer += 'ShowTracker=1 ';
		strMediaPlayer += 'width=400 height=360>';
		strMediaPlayer += '</embed>';
		strMediaPlayer += '</OBJECT>';
	} else {
		strMediaPlayer += "<table width=320 height=304 bgcolor=black style='border:1px solid silver'><tr><td align=center><span style=color:white;font-family:verdana;font-size:12px><b>Para assistir aos vídeos, é preciso ter o<br>Windows Media Player instalado.</b><br><br><a href=http://www.microsoft.com/windows/windowsmedia/download/default.asp?DispLang=br target=_blank style=color:white>Clique aqui</a> para fazer o download<br>do Windows Media Player diretamente<br>do site da Microsoft, em português.</span></td></tr></table>";
	}
	document.getElementById("videoScreen").innerHTML = "<p style=\"text-align:center; text-indent:0;\">" + strMediaPlayer + "<\/p>";
}

function AXO(id) {
	var error; var control = null;
	try {
		if (window.ActiveXObject && navigator.userAgent.indexOf('Win') != -1) control = new ActiveXObject(id);
		else if (gkoaxwma) control = new GeckoActiveXObject(id);
	} catch (error) {
	}
	return control;
}

/*

POP IN

*/
var idImgPopIn = 0;
var intervalo;
var idImagemDestino;
var imagemOrigem;
var vDuracaoTrans;
var preLoad = new Array();
var ultimaFoto;

function imgPopIn(id) {
    var popIn = document.getElementById('popIn');
    var imgPopIn = document.getElementById('imagemPopIn').firstChild;
    document.getElementById("tabela").style.display = '';
    document.getElementById("transparencia").style.display = '';
    idImgPopIn = id;
    if (idImgPopIn == ultimaFoto){
        idImgPopIn = 0
    }else if(idImgPopIn < 0 ){
        idImgPopIn = ultimaFoto-1
    }
    trocaImagem(imgPopIn.id,preLoad[idImgPopIn][0],200);
    imgPopIn.width = preLoad[idImgPopIn][3];
    imgPopIn.height = preLoad[idImgPopIn][4];
    document.getElementById("creditosPopIn").innerHTML = preLoad[idImgPopIn][1];
    document.getElementById("legendaPopIn").innerHTML = preLoad[idImgPopIn][2];
	//document.getElementById("creditosPopIn").style.width = preLoad[idImgPopIn][3];
	//document.getElementById("legendaPopIn").style.width = preLoad[idImgPopIn][3];
    document.getElementById("imagemPopIn").style.width = preLoad[idImgPopIn][3];
    document.getElementById("imagemPopIn").style.height = preLoad[idImgPopIn][4];
}

function fecharPopIn() {
	document.getElementById('transparencia').style.display='none';
	document.getElementById('tabela').style.display='none';
	document.getElementById('imagemPopIn').firstChild.src='legba/admin/imgs/pix.gif';
}

/*

Transição de imagem com fading

*/

function trocaImagem3(objRecebedor,objOrigem,duracaoTrans) {
	if (document.all) {
		objRecebedor.style.filter="blendTrans(duration="+duracaoTrans+")";
		objRecebedor.filters.blendTrans.Apply();
	}

	objRecebedor.src = objOrigem.src;

	if (document.all) {
		objRecebedor.filters.blendTrans.Play();
	}
}

function trocaImagem(id, objOrigem,duracaoTrans) {
	vDuracaoTrans = duracaoTrans
	idImagemDestino = id
	imagemOrigem = objOrigem.src;
	document.getElementById(idImagemDestino).style.Width = objOrigem.width;
	document.getElementById(idImagemDestino).style.Height = objOrigem.height;
	opacity(idImagemDestino, 100, 0, vDuracaoTrans)
	clearInterval(intervalo);
	intervalo = window.setInterval("lerolero()", vDuracaoTrans);
}

function trocaImagem2(objRecebedor,objOrigem,duracaoTrans) {
	if (document.all) {
		objRecebedor.style.filter="blendTrans(duration="+duracaoTrans+")";
		objRecebedor.filters.blendTrans.Apply();
	}

	objRecebedor.src = objOrigem[6].src;
	objRecebedor.parentNode.href = objOrigem[0].src;

	if (document.all) {
		objRecebedor.filters.blendTrans.Play();
	}
}

function lerolero() {
	clearInterval(intervalo);
	document.getElementById(idImagemDestino).onload = carregouFoto;
	document.getElementById(idImagemDestino).src = imagemOrigem;
}

function carregouFoto() {
	opacity(idImagemDestino, 0, 100, vDuracaoTrans)
}

function opacity(id, opacStart, opacEnd, millisec) {
	//speed for each frame
	var speed = Math.round(millisec / 100);
	var timer = 0;

	//determine the direction for the blending, if start and end are the same nothing happens
	if(opacStart > opacEnd) {
		for(i = opacStart; i >= opacEnd; i--) {
			setTimeout("changeOpac(" + i + ",'" + id + "')",(timer * speed));
			timer++;
		}
	} else if(opacStart < opacEnd) {
		for(i = opacStart; i <= opacEnd; i++)
			{
			setTimeout("changeOpac(" + i + ",'" + id + "')",(timer * speed));
			timer++;
		}
	}
}

//change the opacity for different browsers
function changeOpac(opacity, id) {
	var object = document.getElementById(id).style; 
	object.opacity = (opacity / 100);
	object.MozOpacity = (opacity / 100);
	object.KhtmlOpacity = (opacity / 100);
	object.filter = "alpha(opacity=" + opacity + ")";
}
/*----------------------------------------------*/

destaqueAtual = 0;

function trocaDestaque(id,qtd) {
	clearTimeout(timerDestaques);
	for (i=1;i<=qtd;i++) {
		document.getElementById("aba"+i).className = "";
		document.getElementById("destaqueInicial"+i).style.display = "none";
	}
	document.getElementById("aba"+id).className = "selecionada";
	document.getElementById("destaqueInicial"+id).style.display = "";
	timerDestaques = setTimeout('temporizadorDestaques(' + qtd + ')',SEGUNDOS_APOS_CLIQUE_DESTAQUES);
}

function temporizadorDestaques(qtd) {
	clearTimeout(timerDestaques);
	for (i=1;i<=qtd;i++) {
		if (document.getElementById("aba"+i).className == "selecionada") {
			document.getElementById("aba"+i).className = "";
			document.getElementById("destaqueInicial"+i).style.display = "none";
			id = i+1;
			break;
		}
	}
	if (id > qtd) id = 1;
	document.getElementById("aba"+id).className = "selecionada";
	document.getElementById("destaqueInicial"+id).style.display = "";
	timerDestaques = setTimeout('temporizadorDestaques(' + qtd + ')',10000);
}

function atualizaBairrosEPontosDeRef(vCod) {
	var bairros = document.formPesquisaRapida.bairros;
	var referencias = document.formPesquisaRapida.referencias;
	if (vCod != "") {
		bairros.disabled = true;
		bairros.length = 0;
		bairros.options[0] = new Option();
		bairros.options[0].text = "Carregando...";
		GDownloadUrl("/ajax/bairros.asp?sid="+Math.random()+"&vCod="+vCod, function(data, responseCode) {
			bXml = GXml.parse(data);
			var bairros = bXml.documentElement.getElementsByTagName("bairro");
			var listaDestino = document.formPesquisaRapida.bairros;
			listaDestino.disabled = false;
			listaDestino.length = 0;
			listaDestino.options[0] = new Option();
			listaDestino.options[0].value = "";
			listaDestino.options[0].text = "Todos";
			for (i=1;i<=bairros.length;i++) {
				listaDestino.options[i] = new Option();
				listaDestino.options[i].value = bairros[i-1].getAttribute("cod");
				listaDestino.options[i].text = bairros[i-1].getAttribute("nome");
			}
		});
		referencias.disabled = true;
		referencias.length = 0;
		referencias.options[0] = new Option();
		referencias.options[0].text = "Carregando...";
		GDownloadUrl("/ajax/referencias.asp?sid="+Math.random()+"&vCod="+vCod, function(data, responseCode) {
			prXml = GXml.parse(data);
			var referencias = prXml.documentElement.getElementsByTagName("referencia");
			var listaDestino = document.formPesquisaRapida.referencias;
			listaDestino.disabled = false;
			listaDestino.length = 0;
			listaDestino.options[0] = new Option();
			listaDestino.options[0].value = "";
			listaDestino.options[0].text = "Indiferente";
			for (i=1;i<=referencias.length;i++) {
				listaDestino.options[i] = new Option();
				listaDestino.options[i].value = referencias[i-1].getAttribute("cod");
				listaDestino.options[i].text = referencias[i-1].getAttribute("titulo");
			}
		});
	} else {
		bairros.disabled = true;
		bairros.length = 0;
		bairros.options[0] = new Option();
		bairros.options[0].text = "Sel. uma cidade";
		referencias.disabled = true;
		referencias.length = 0;
		referencias.options[0] = new Option();
		referencias.options[0].text = "Sel. uma cidade";
	}
}

function atualizaBairrosEPontosDeRefAvancado(vCod) {
	var spanBairros = document.getElementById("spanBairros"); // ATENÇÃO: spanBairros é uma tabela. (table)
	var spanReferencias = document.getElementById("spanReferencias");
	if (vCod != "") {
		removeTodosOsFilhos(spanBairros);
		removeTodosOsFilhos(spanReferencias);
		var carregando1 = document.createTextNode("Carregando bairros da cidade de " + document.buscaAvancada.cidade.options[document.buscaAvancada.cidade.options.selectedIndex].text + "...");
		var linha = spanBairros.insertRow(0);
		var celula = linha.insertCell(0);
		celula.appendChild(carregando1);
		var carregando2 = document.createTextNode("Carregando pontos de referência da cidade de " + document.buscaAvancada.cidade.options[document.buscaAvancada.cidade.options.selectedIndex].text + "...");
		var linha = spanReferencias.insertRow(0);
		var celula = linha.insertCell(0);
		celula.appendChild(carregando2);
		GDownloadUrl("/ajax/bairros.asp?sid="+Math.random()+"&vCod="+vCod, function(data, responseCode) {
			bXml = GXml.parse(data);
			var bairros = bXml.documentElement.getElementsByTagName("bairro");
			removeTodosOsFilhos(spanBairros);
			
			var qtdPorLinha = 3;
			var linhas = parseInt((bairros.length+qtdPorLinha-1)/qtdPorLinha);
			var linhaAtual = 0;

			for (i=0;i<bairros.length;i++) {
				if (i % qtdPorLinha == 0) {
					var linha = spanBairros.insertRow(linhaAtual);
					linhaAtual++;
					var coluna = 0;
				}
				var celula = linha.insertCell(coluna++);
				celula.width = parseInt(100/qtdPorLinha)+"%";
				celula.vAlign = "top";
				var cod = bairros[i].getAttribute("cod");
				var nome = document.createTextNode(bairros[i].getAttribute("nome"));
				var label = document.createElement("label");
				label.setAttribute("for", "bairro"+cod);
				var input = document.createElement("input");			
				input.setAttribute("id", "bairro"+cod);
				input.setAttribute("name", "bairros");
				input.setAttribute("type", "checkbox");
				input.setAttribute("value",cod);
				label.appendChild(input);
				label.appendChild(nome);
				input.className = "nostyle";
				input.onclick = function() { desmarcaTodosAvancado(); };
				celula.appendChild(label);
				linha.appendChild(celula);
			}
		});

		GDownloadUrl("/ajax/referencias.asp?sid="+Math.random()+"&vCod="+vCod, function(data, responseCode) {
			
			removeTodosOsFilhos(spanReferencias);			
			var linha = spanReferencias.insertRow(0);
			var celula = linha.insertCell(0);
			
			prXml = GXml.parse(data);
			var referencias = prXml.documentElement.getElementsByTagName("referencia");
			removeTodosOsFilhos(spanReferencias);
			
			var qtdPorLinha = 3;
			var linhas = parseInt((referencias.length+qtdPorLinha-1)/qtdPorLinha);
			var linhaAtual = 0;
			
			for (i=0;i<referencias.length;i++) {
			
				if (i % qtdPorLinha == 0) {
					var linha = spanReferencias.insertRow(linhaAtual);
					linhaAtual++;
					var coluna = 0;
				}
				
				var celula = linha.insertCell(coluna++);
				celula.width = parseInt(100/qtdPorLinha)+"%";
				celula.vAlign = "top";
				var cod = referencias[i].getAttribute("cod");
				var titulo = document.createTextNode(referencias[i].getAttribute("titulo"));
				var label = document.createElement("label");
				label.setAttribute("for", "referencia"+cod);
				var input = document.createElement("input");
				input.setAttribute("id", "referencia"+cod);
				input.setAttribute("name", "referencias");
				input.setAttribute("type", "checkbox");
				input.setAttribute("value",cod);
				label.appendChild(input);
				label.appendChild(titulo);
				input.className = "nostyle";
				
				celula.appendChild(label);
				linha.appendChild(celula);
			}
		});
	} else {
		removeTodosOsFilhos(spanBairros);
		removeTodosOsFilhos(spanReferencias);
		var texto = document.createTextNode("Selecione uma cidade.");
		var linha = spanReferencias.insertRow(0);
		var celula = linha.insertCell(0);
		celula.appendChild(texto);
	}
}

function removeTodosOsFilhos(el) {
	for (i = el.childNodes.length-1;i >= 0;i--) {
		el.removeChild(el.childNodes[i]);
	}
}

function temFilhoDoTipoNComPropriedadeX(el,tipo,propriedade,valor) {
	var retorno = false;
	var filhos = el.getElementsByTagName(tipo);
	for (i = 0; i < filhos.length; i++) {
		if (filhos[i].getAttribute(propriedade) == valor) {
			retorno = true;
		}
	}
	return retorno;
}



/*
	Função GetXmlHttpObject
*/

function GetXmlHttpObject(handler) { 
	var objXmlHttp=null;

	if (navigator.userAgent.indexOf("MSIE")>=0) { 
		var strName="Msxml2.XMLHTTP";
		if (navigator.appVersion.indexOf("MSIE 5.5")>=0) {
			strName="Microsoft.XMLHTTP";
		} 
		try { 
			objXmlHttp=new ActiveXObject(strName);
			objXmlHttp.onreadystatechange=handler;
			return objXmlHttp;
		} catch(e) { 
			alert("Erro. \"Scripting for ActiveX\" provavelmente está desabilitado.");
			return;
		}
	}
	if (navigator.userAgent.indexOf("Mozilla")>=0) {
		objXmlHttp=new XMLHttpRequest();
		objXmlHttp.onload=handler;
		objXmlHttp.onerror=handler;
		return objXmlHttp;
	}
}

function validaPesquisaAvancada(dForm) {
    var erro = false, msg_erro = "ERRO:\n", aoMenosUmNegocio = true;

    for (i=0;i<dForm.negocio.length;i++){
        if (dForm.negocio[i].checked) {
            //aoMenosUmNegocio = true;
        }
    }
    if (!aoMenosUmNegocio) {
        erro = true;
        msg_erro += "\nSelecione aluguel e\/ou venda.";
    }

    if (erro) {
        alert(msg_erro);
        return false;
    }
}

/*
  Enviar Interessados 
*/
var iDiv = "";
var anterior;
function verificaFormEnviarInteressado(dform) {
    	
	seuNome = dform.seuNome.value;
	seuEmail = dform.seuEmail.value;
	seuTelefone = dform.seuTelefone.value;
			
	erro = false;
	msg_erro = "ERRO:";
	
	if (seuNome == ""){
		erro = true;
		msg_erro += "\nDigite seu nome.";
	}
	
	if (seuEmail == ""){
		erro = true;
		msg_erro += "\nDigite seu e-mail.";
	}
	
	if (seuEmail == "" || seuEmail.indexOf('@',0) == -1 || seuEmail.indexOf('@',0) == 0 || seuEmail.indexOf('.',0) == -1 || seuEmail.indexOf('@.',0) != -1 || seuEmail.indexOf(',',0) != -1 || seuEmail.indexOf('@',0) == seuEmail.length-1 || seuEmail.indexOf('@',0) != seuEmail.lastIndexOf('@')) {
		erro = true;
		msg_erro += "\nO seu endereço de e-mail não parece válido.";
	}
	
	if (seuTelefone == ""){
		erro = true;
		msg_erro += "\nDigite seu Telefone.";
	}
	
	if (erro) {
		alert(msg_erro);
	} else {
		enviarInteressado(dform);
	}
	return false;
}

function formEnviarInteressado(vCodImovel, onde, vCodParceiro) {
	
	iDiv = onde
																			   
	strFormInteressado = "<form>";
	strFormInteressado += "<input type=\"hidden\" name=\"vCodImovel\" value=\"" + vCodImovel + "\" \/\>";
	strFormInteressado += "<input type=\"hidden\" name=\"vCodParceiro\" value=\"" + vCodParceiro + "\" \/\>";
	strFormInteressado += "<div>Nome:<input type=\"text\" name=\"seuNome\" tabindex=\"200\" \/\>";
	strFormInteressado += " E-mail: <input type=\"text\" name=\"seuEmail\" tabindex=\"202\" \/\><\/div\>";
	strFormInteressado += " <div>Telefone: <input type=\"text\" name=\"seuTelefone\" tabindex=\"201\" \/\><\/div\>";
	strFormInteressado += "<button type=\"button\" onclick=\"verificaFormEnviarInteressado(this.parentNode)\" tabindex=\"203\"><img src=\"imgs/bt_enviar.gif\" border=\"0\" alt=\"Enviar\" \/\><\/button\><\/form\>";
		
	if (document.getElementById("formEnviarInteressado" + iDiv).innerHTML != "") {
		document.getElementById("formEnviarInteressado" + iDiv).innerHTML = "";
	} else {
		document.getElementById("formEnviarInteressado" + iDiv).innerHTML = strFormInteressado;
	}
}

function enviarInteressado(dform) {
	
	var url="legba/enviaInteressado.asp?vCodImovel=" + dform.vCodImovel.value + "&vCodParceiro=" + dform.vCodParceiro.value + "&seuNome=" + dform.seuNome.value + "&seuEmail=" + dform.seuEmail.value + "&seuTelefone=" + dform.seuTelefone.value;
	anterior = document.getElementById("formEnviarInteressado" + iDiv).innerHTML;
	var xmlHttp=GetXmlHttpObject(function() {
		if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete") {
			document.getElementById("formEnviarInteressado" + iDiv).innerHTML = xmlHttp.responseText;
		}
	});
	xmlHttp.open("GET", url , true)
	xmlHttp.send(null);
}

function voltarFormEnviarInteressado() {
	document.getElementById("formEnviarInteressado" + iDiv).innerHTML = "";//anterior;
}

function validaPesquisa(dForm) {
    var erro = false, msg_erro = "ERRO:\n", aoMenosUmNegocio = false;

    for (i=0;i<dForm.negocio.length;i++){
        if (dForm.negocio[i].checked) {
            aoMenosUmNegocio = true;
        }
    }
    if (!aoMenosUmNegocio) {
        erro = true;
        msg_erro += "\nSelecione aluguel, venda e\/ou lançamento.";
    }

    if (erro) {
        alert(msg_erro);
        return false;
    }
}

function validaPesquisaAvancada(dForm) {
    var erro = false, msg_erro = "ERRO:\n", aoMenosUmNegocio = false;

    for (i=0;i<dForm.negocio.length;i++){
        if (dForm.negocio[i].checked) {
            aoMenosUmNegocio = true;
        }
    }
    if (!aoMenosUmNegocio) {
        erro = true;
        msg_erro += "\nSelecione aluguel e\/ou venda.";
    }

    if (erro) {
        alert(msg_erro);
        return false;
    }
}

function desmarcaIndividuos(dForm, todos, nomeIndividuo) {
	var entrouNoLoop = false;
	if (temFilhoDoTipoNComPropriedadeX(dForm,"input","name",nomeIndividuo)) {
		var objIndividuo = dForm[nomeIndividuo];
		for (i=0;i<objIndividuo.length;i++){
			entrouNoLoop = true;
			objIndividuo[i].checked = false;
		}
		if (!entrouNoLoop) {
			objIndividuo.checked = false;
		}
	}
	todos.checked = true;
}

function desmarcaIndividuosAvancado() {
	var filhos = document.getElementById("spanBairros").getElementsByTagName("input");
	for (i = 0; i < filhos.length; i++) {
		filhos[i].checked = false;
	}
	document.buscaAvancada.bairrosT.checked = true;
}

function desmarcaTodos(dForm, todos, individuo) {
	var algumMarcado = false, entrouNoLoop = false;
	for (i=0;i<individuo.length;i++){
		entrouNoLoop = true;
		if (individuo[i].checked) {
			algumMarcado = true;
		}
	}
	if (!entrouNoLoop) {
		if (individuo.checked) {
			algumMarcado = true;
		}
	}
	todos.checked = !algumMarcado;
}

function desmarcaTodosAvancado() {
	var algumMarcado = false;
	var filhos = document.getElementById("spanBairros").getElementsByTagName("input");
	for (i = 0; i < filhos.length; i++) {
		if (filhos[i].checked) {
			algumMarcado = true;
		}
	}
	document.buscaAvancada.bairrosT.checked = !algumMarcado;
}

