﻿//
//**********************************************************************************************//
//								Livraria Javascript - módulo site								//
//											versão 1.5											//
//																								//
//	Este código pertence á seu desenvolvedor e está protegido por direitos autorais previstos	//
//	na Lei de Software pela constituição Brasileira. Sua cópia, venda utilização sem autoriza-	//
// 				ção é CRIME. Seja legal, produza seu software. Diga não à pirataria.			//
//																								//
//										Desenvolvedores											//
//								José Eduardo Perotta de Almeida									//
//								  eduardo@web2solutions.com.br									//
//									Alvaro Luiz dos Santos										//
//								  alvaro@web2solutions.com.br									//
//																								//
//								  web2 Soluções para internet									//
//								    www.web2solutions.com.br									//
//																								//
//								 última atualização: 18/03/2010									//
//								atualizado por: Eduardo Almeida									//
//**********************************************************************************************//
//
// Variáveis Globais
var timerfechamento=0;
var idqp=1;
var stridqp='';
// Funções
function pega(elemento)
{
	return document.getElementById(elemento);
};
function manipulaelemento(objetotela, acao)
{
	var objetotela = pega(objetotela);
	if (acao == "o"){$(objetotela).fadeOut();}
	if (acao == "e"){$(objetotela).fadeIn();}
	if (acao == "l"){$(objetotela).val("");} 
};
var xmlhttp = inciaAjax();
function inciaAjax()
{
	if (window.XMLHttpRequest)
	{
		return new XMLHttpRequest();
	} else if (window.ActiveXObject)
	{
		return new ActiveXObject("Microsoft.XMLHTTP");
	}
};
function clsinput(id){
	pega(id).value='';
};
function populainput(id,oque){
	if(pega(id).value=='')
	{
		pega(id).value=oque;	
	}
};
function reloadpagina()
{
	document.location=location.reload;
};
function navega(pagina)
{
	document.location=pagina;
};
function buscar(){
	document.location='busca.asp';
};
function limparvisualizados(idvisualizado)
{
	if (confirm('Deseja realmente excluir o imóvel da lista de vizualizados?')){
		xmlhttp.open("GET", "scripts/processalimparvisualizados.asp?id=" + idvisualizado + "", true);
		xmlhttp.onreadystatechange = function()
		{
			if (xmlhttp.readyState==4)
			{
				window.alert('Imóvel excluído da lista de vizualizados com sucesso!');
				setTimeout("reloadpagina()", 1000);
			}
		};
		xmlhttp.send(null);
	}
};
function limpartodosvisualizados()
{
	if (confirm('Deseja realmente excluir todos os imóveis da lista de vizualizados?')){
		xmlhttp.open("GET", "scripts/processalimpartodosvisualizados.asp", true);
		xmlhttp.onreadystatechange = function()
		{
			if (xmlhttp.readyState==4)
			{
				window.alert('A lista de imóveis vizualizados foi limpa com sucesso!');
				setTimeout("reloadpagina()", 1000);
			}
		};	
		xmlhttp.send(null);
	}
};
function marcavoto(qualvoto)
{
	pega('opcaoh').value=qualvoto;
};
function registrarcliente(nome,email,usuario,senha)
{
				xmlhttp.open("GET", "scripts/processaregistrocliente.asp?nome=" + nome + "&email=" + email + "&usuario=" + usuario + "&senha=" + senha + "", true);
				xmlhttp.onreadystatechange = function()
				{
					if (xmlhttp.readyState==4)
					{
						if (xmlhttp.responseText=='emailemuso')
						{
							window.alert('O e-mail fornecido ja está sendo utilizado!');
							return (false);
						}
						if (xmlhttp.responseText=='usuarioemuso')
						{
							window.alert('O nome de usuário fornecido ja está sendo utilizado!');
							return (false);
						}
						if (xmlhttp.responseText=='sucesso')
						{
							window.alert('Registro efetuado com sucesso!');
							window.location='default.asp';
						}
					}
				};	
				xmlhttp.send(null);
};
function logincliente(usuario,senha){
				xmlhttp.open("GET", "scripts/processalogincliente.asp?usuario=" + usuario + "&senha=" + senha + "", true);
				xmlhttp.onreadystatechange = function()
				{
					if (xmlhttp.readyState==4)
					{
						if (xmlhttp.responseText=='naologou')
						{
							window.alert('Usuário ou senha incorretos!');
							return (false);
						}
						if (xmlhttp.responseText=='logado')
						{
							window.alert('Login efetuado com sucesso!');
							window.location='default.asp';
						}
					}
				};	
				xmlhttp.send(null);
};
function indicaimovel(idimovel,nome,email,nomepara,emailpara,resposta,container)
{
		window.alert('Aguarde um segundo!');
		var nomede = pega(nome).value;
		var emailde = pega(email).value;
		var nomepara = pega(nomepara).value;
		var emailpara = pega(emailpara).value;
		pega(resposta).innerHTML = '<br><br><br><br><img src=assets/ajax-loader.gif /><br><br>';
		window.setTimeout(function()
			{
				xmlhttp.open("GET", "scripts/processaindicaimovel.asp?id=" + idimovel + "&nome=" + nomede + "&email=" + emailde + "&nomepara=" + nomepara + "&emailpara=" + emailpara + "", true);
				xmlhttp.onreadystatechange = function()
				{
					if (xmlhttp.readyState==4)
					{
						pega(resposta).innerHTML = xmlhttp.responseText;
						window.setTimeout(function()
									{
										pega(resposta).innerHTML = '<strong>Forneça seu nome, seu e-mail, nome e <br />e-mail do seu amigo(a)</strong><br /><br /><label><input name="'+ nome +'" id="'+ nome +'" class="inputp" type="text" value="seu nome" onclick="clsinput(this.id);" onblur="populainput(this.id,\'seu nome\');" /></label><label><input name="'+ email +'" id="'+ email +'" class="inputp" type="text" value="seu e-mail" onclick="clsinput(this.id);" onblur="populainput(this.id,\'seu e-mail\');" /></label><label><input name="'+ nomepara +'" id="'+ nomepara +'" class="inputp" type="text" value="nome do amigo" onclick="clsinput(this.id);" onblur="populainput(this.id,\'nome do amigo\');" /></label><label><input name="'+ emailpara +'" id="'+ emailpara +'" class="inputp" type="text" value="e-mail do amigo" onclick="clsinput(this.id);" onblur="populainput(this.id,\'e-mail do amigo\');" /></label><br /><img src="imagens/bt_enviar.png" alt="indicar" style="cursor:pointer; margin-top:5px;" onclick="indicaimovel('+ idimovel +',\''+ nome +'\',\''+ email +'\',\''+ nomepara +'\',\''+ emailpara +'\',\''+ resposta +'\',\''+ container +'\');" />';
										window.setTimeout(function()
											{
												manipulaelemento(container,'o');
											}, 3000);
									}, 3000);
					}
				};	
				xmlhttp.send(null);
			}, 1000); /*  milisegundos */
};
function enviarfotos(idimovel,nomef,emailf,resposta,container)
{
		window.alert('Aguarde enquanto enviamos as fotos!');
		var nome = pega(nomef).value;
		var email = pega(emailf).value;
		pega(resposta).innerHTML = '<br><br><br><br><img src=assets/ajax-loader.gif /><br><br>';
		window.setTimeout(function()
			{
				xmlhttp.open("GET", "scripts/processaenviafotos.asp?id=" + idimovel + "&nome=" + nome + "&email=" + email + "", true);
				xmlhttp.onreadystatechange = function()
				{
					if (xmlhttp.readyState==4)
					{
						pega(resposta).innerHTML = '<br><br><br>Fotos enviadas com sucesso para o e-mail ' + email + '!';
						window.setTimeout(function()
									{
										pega(resposta).innerHTML = '<br /><strong>Forneça seu nome e o endereço de e-mail para receber as fotos do imóvel</strong><br /><br /><label><input name="'+ nomef +'" id="'+ nomef +'" type="text" value="seu nome" class="inputp" onclick="clsinput(this.id);" onblur="populainput(this.id,\'seu nome\');"  /></label><label><input name="'+ emailf +'" id="'+ emailf +'" type="text" value="seu e-mail" class="inputp" onclick="clsinput(this.id);" onblur="populainput(this.id,\'seu e-mail\');" /></label><br /><br /><img src="imagens/bt_enviar.png" alt="indicar" style="cursor:pointer; margin-top:5px;" onclick="enviarfotos('+ idimovel +',\''+ nomef +'\',\''+ emailf +'\',\''+ resposta +'\',\''+ container +'\');" />';
										window.setTimeout(function()
											{
												manipulaelemento(container,'o');
											}, 3000);
									}, 3000);
					}
				};	
				xmlhttp.send(null);
			}, 1000); /*  milisegundos */
};
function solicitarinformacoes(idimovel,nomef,telefonef,resposta,container)
{
		window.alert('Aguarde 1 segundo!');
		var nome = pega(nomef).value;
		var telefone = pega(telefonef).value;
		pega(resposta).innerHTML = '<br><br><br><br><img src=assets/ajax-loader.gif /><br><br>';
		window.setTimeout(function()
			{
				xmlhttp.open("GET", "scripts/processamaisinformacoes.asp?id=" + idimovel + "&nome=" + nome + "&telefone=" + telefone + "", true);
				xmlhttp.onreadystatechange = function()
				{
					if (xmlhttp.readyState==4)
					{
						pega(resposta).innerHTML = xmlhttp.responseText;
						window.setTimeout(function()
								{
									manipulaelemento(container,'o');
								}, 3000);
					}
				};	
				xmlhttp.send(null);
			}, 1000); /*  milisegundos */
};
function processafavoritos(id,acao,elemento)
{
	if (acao == "adiciona")
	{
		if (confirm('Deseja realmente adicionar este imóvel à lista de favoritos?'))
		{
			xmlhttp.open("GET", "scripts/processafavoritos.asp?acao=" + acao + "&id=" + id + "", true);
			xmlhttp.onreadystatechange = function()
			{
				if (xmlhttp.readyState==4)
				{
					//window.alert(xmlhttp.responseText);
					if (xmlhttp.responseText=='adicionado')
					{
						window.alert('Imóvel adicionado à lista de favoritos!');
						pega(elemento).innerHTML='<img src="imagens/bt_favorito-on.png" onclick="processafavoritos(\''+ id +'\',\'exclui\',\''+ elemento +'\');" />';
					}
				}
			};	
			xmlhttp.send(null);
		}
	}
	if (acao == "exclui")
	{
		if (confirm('Deseja realmente excluir este imóvel da lista de favoritos?'))
		{
			xmlhttp.open("GET", "scripts/processafavoritos.asp?acao=" + acao + "&id=" + id + "", true);
			xmlhttp.onreadystatechange = function()
			{
				if (xmlhttp.readyState==4)
				{
					//window.alert(xmlhttp.responseText);
					if (xmlhttp.responseText=='excluido')
					{
						window.alert('Imóvel excluído da lista de favoritos!');
						pega(elemento).innerHTML='<img src="imagens/bt_favorito-off.png" onclick="processafavoritos(\''+ id +'\',\'adiciona\',\''+ elemento +'\');" />';

					}
				}
			};	
			xmlhttp.send(null);
		}
	}
};
function processafavoritosimovel(id,acao,elemento)
{
	if (acao == "adiciona")
	{
		if (confirm('Deseja realmente adicionar este imóvel à lista de favoritos?'))
		{
			xmlhttp.open("GET", "scripts/processafavoritos.asp?acao=" + acao + "&id=" + id + "", true);
			xmlhttp.onreadystatechange = function()
			{
				if (xmlhttp.readyState==4)
				{
					if (xmlhttp.responseText=='adicionado')
					{
						window.alert('Imóvel adicionado à lista de favoritos!');
						pega(elemento).innerHTML='<img src="imagens/bt_delfavoritos.png" width="139" height="40" style="cursor:pointer" onclick="processafavoritosimovel(\''+ id +'\',\'exclui\',\''+ elemento +'\');" />';
					}
				}
			};	
			xmlhttp.send(null);
		}
	}
	if (acao == "exclui")
	{
		if (confirm('Deseja realmente excluir este imóvel da lista de favoritos?'))
		{
			xmlhttp.open("GET", "scripts/processafavoritos.asp?acao=" + acao + "&id=" + id + "", true);
			xmlhttp.onreadystatechange = function()
			{
				if (xmlhttp.readyState==4)
				{
					if (xmlhttp.responseText=='excluido')
					{
						window.alert('Imóvel excluído da lista de favoritos!');
						pega(elemento).innerHTML='<img src="imagens/bt_addfavoritos.png" width="139" height="40" style="cursor:pointer" onclick="processafavoritosimovel(\''+ id +'\',\'adiciona\',\''+ elemento +'\');" />';

					}
				}
			};	
			xmlhttp.send(null);
		}
	}
};
function transferevalor(valor,alvo){
	pega(alvo).value=valor;
};
function enviamensagemcontato()
{
	if (pega('nomecontato').value == "" || pega('emailcontato').value == "" || pega('mensagemcontato').value == "")
	{
		window.alert('Favor informar ao menos seu nome, e-mail e a mensagem que deseja enviar!');
		pega('nomecontato').focus();
		return (false);
	}else xmlhttp.open("GET", "scripts/processacontato.asp?nomecontato=" + pega('nomecontato').value + "&emailcontato=" + pega('emailcontato').value + "&telefonecontato=" + pega('telefonecontato').value + "&mensagemcontato=" + pega('mensagemcontato').value + "", true);
	xmlhttp.onreadystatechange = function()
	{
		if (xmlhttp.readyState==4)
		{
					if (xmlhttp.responseText=='enviado')
					{
						window.alert('Mensagem processada com sucesso!');
					}
		}
	};	
	xmlhttp.send(null);
};
function buscacodigo(codigo)
{
	if (codigo == "" || codigo == "código")
	{
		window.alert('Favor informar o código do imóvel que deseja encontrar!');
		pega('bcodigo').focus();
		return (false);
	}else xmlhttp.open("GET", "scripts/processabuscac.asp?codigo=" + codigo + "", true);
	xmlhttp.onreadystatechange = function()
	{
		if (xmlhttp.readyState==4)
		{
			if (xmlhttp.responseText=='inexistente')
			{
				window.alert('Código Inexistente!');
				pega('bcodigo').focus();
				return (false);
			}else
			{
			window.alert('Imóvel encontrado, aguarde!');
			self.location.href='imovel.asp?id=' + xmlhttp.responseText + '';
			}
		}
	};	
	xmlhttp.send(null);
};
function sns(evento){var tecla=(window.event)?event.keyCode:evento.which; if((tecla > 47 && tecla < 58)) return true; else{if (tecla != 8) return false; else return true;}};
function mascara(o,f){
    v_obj=o;
    v_fun=f;
    setTimeout("execmascara()",1)
};
function execmascara(){
    v_obj.value=v_fun(v_obj.value)
};
function soNumeros(v){
    return v.replace(/\D/g,"")
};
function telep(v){
    v=v.replace(/\D/g,"")                 //Remove tudo o que não é dígito
    v=v.replace(/^(\d\d)(\d)/g,"($1) $2") //Coloca parênteses em volta dos dois primeiros dígitos
    v=v.replace(/(\d{4})(\d)/,"$1-$2")    //Coloca hífen entre o quarto e o quinto dígitos
    return v
};
function checaemail(id)
{
	if ((pega(id).value).length > 0)
	{
		if (!/^([a-zA-Z0-9_\-\.]+)@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.)|(([a-zA-Z0-9\-]+\.)+))([a-zA-Z]{2,4}|[0-9]{1,3})(\]?)$/.test(pega(id).value))
		{
			alert('E-mail incorreto.');
			pega(id).focus();
			return false;
		}

	}
};
function imprimirpagina() {
//	var oPrint, oJan;
//	oPrint = window.document.getElementById(id).innerHTML;
//	oJan = window.open(pg);
//	oJan.document.write(oPrint);
//	oJan.window.print();
//    oJan.document.close();
//    oJan.focus();
	window.print()
};
function mudabulleto(id){
	pega('canuncio'+id).style.display='none';
	pega('bullet'+id).innerHTML='<img src="imagens/bulletd.jpg" width="20" height="21" onclick="mudabullete(' + id + ');"  alt="exibir anúncio ' + id + '" title="exibir anúncio ' + id + '"/>';
};
function mudabullete(id){
	pega('canuncio'+id).style.display='block';
	pega('bullet'+id).innerHTML='<img src="imagens/bulleth.jpg" width="20" height="21" onclick="mudabulleto(' + id + ');" alt="ocultar anúncio ' + id + '" title="ocultar anúncio ' + id + '" />';
};
function inputfocus(inputid)
{
	var inputid=pega(inputid);
	inputid.style.background='#af1620';
	inputid.style.color='#e9e8e8';
};
function inputblur(inputid)
{
	var inputid=pega(inputid);
	inputid.style.background='#f4f4f4';
	inputid.style.color='#333';
};
function FormataReal(nvalor){
nvalor = nvalor.replace(".","");
nvalor = nvalor.replace(",",".");
return nvalor;
};
function FormataRealn(nvalor){
nvalor = nvalor.replace(".",",");
nvalor = nvalor.replace(",",".");
return nvalor;
};
function FormataValor(objeto,teclapres,tammax,decimais) 
{
	var tecla			= teclapres.keyCode;
	var tamanhoObjeto	= objeto.value.length;
	if ((tecla == 8) && (tamanhoObjeto == tammax))
	{
		tamanhoObjeto = tamanhoObjeto - 1 ;
	}
    if (( tecla == 8 || tecla == 88 || tecla >= 48 && tecla <= 57 || tecla >= 96 && tecla <= 105 ) && ((tamanhoObjeto+1) <= tammax))
	{
		vr	= objeto.value;
		vr	= vr.replace( "/", "" );
		vr	= vr.replace( "/", "" );
		vr	= vr.replace( ",", "" );
		vr	= vr.replace( ".", "" );
		vr	= vr.replace( ".", "" );
		vr	= vr.replace( ".", "" );
		vr	= vr.replace( ".", "" );
		tam	= vr.length;
		if (tam < tammax && tecla != 8)
		{
			tam = vr.length + 1 ;
		}
		if ((tecla == 8) && (tam > 1))
		{
			tam = tam - 1 ;
			vr = objeto.value;
			vr = vr.replace( "/", "" );
			vr = vr.replace( "/", "" );
			vr = vr.replace( ",", "" );
			vr = vr.replace( ".", "" );
			vr = vr.replace( ".", "" );
			vr = vr.replace( ".", "" );
			vr = vr.replace( ".", "" );
		}
		if ( tecla == 8 || tecla >= 48 && tecla <= 57 || tecla >= 96 && tecla <= 105 )
		{
			if (decimais > 0)
			{
				if ( (tam <= decimais) )
				{ 
					objeto.value = ("0," + vr) ;
				}
				if( (tam == (decimais + 1)) && (tecla == 8))
				{
					objeto.value = vr.substr( 0, (tam - decimais)) + ',' + vr.substr( tam - (decimais), tam ) ;	
				}
				if ( (tam > (decimais + 1)) && (tam <= (decimais + 3)) &&  ((vr.substr(0,1)) == "0"))
				{
					objeto.value = vr.substr( 1, (tam - (decimais+1))) + ',' + vr.substr( tam - (decimais), tam ) ;
				}
				if ( (tam > (decimais + 1)) && (tam <= (decimais + 3)) &&  ((vr.substr(0,1)) != "0"))
				{
				    objeto.value = vr.substr( 0, tam - decimais ) + ',' + vr.substr( tam - decimais, tam ) ; 
				}
				if ( (tam >= (decimais + 4)) && (tam <= (decimais + 6)) )
				{
			 		objeto.value = vr.substr( 0, tam - (decimais + 3) ) + '.' + vr.substr( tam - (decimais + 3), 3 ) + ',' + vr.substr( tam - decimais, tam ) ;
				}
			 	if ( (tam >= (decimais + 7)) && (tam <= (decimais + 9)) )
				{
			 		objeto.value = vr.substr( 0, tam - (decimais + 6) ) + '.' + vr.substr( tam - (decimais + 6), 3 ) + '.' + vr.substr( tam - (decimais + 3), 3 ) + ',' + vr.substr( tam - decimais, tam ) ;
				}
				if ( (tam >= (decimais + 10)) && (tam <= (decimais + 12)) )
				{
			 		objeto.value = vr.substr( 0, tam - (decimais + 9) ) + '.' + vr.substr( tam - (decimais + 9), 3 ) + '.' + vr.substr( tam - (decimais + 6), 3 ) + '.' + vr.substr( tam - (decimais + 3), 3 ) + ',' + vr.substr( tam - decimais, tam ) ;
				}
				if ( (tam >= (decimais + 13)) && (tam <= (decimais + 15)) )
				{
			 		objeto.value = vr.substr( 0, tam - (decimais + 12) ) + '.' + vr.substr( tam - (decimais + 12), 3 ) + '.' + vr.substr( tam - (decimais + 9), 3 ) + '.' + vr.substr( tam - (decimais + 6), 3 ) + '.' + vr.substr( tam - (decimais + 3), 3 ) + ',' + vr.substr( tam - decimais, tam ) ;
				}
			}
			else if(decimais == 0)
			{
				if ( tam <= 3 )
				{ 
			 		objeto.value = vr ;
				}
				if ( (tam >= 4) && (tam <= 6) )
				{
					if(tecla == 8)
					{
						objeto.value = vr.substr(0, tam);
						window.event.cancelBubble = true;
						window.event.returnValue = false;
					}
					objeto.value = vr.substr(0, tam - 3) + '.' + vr.substr( tam - 3, 3 ); 
				}
				if ( (tam >= 7) && (tam <= 9) )
				{
					if(tecla == 8)
					{
						objeto.value = vr.substr(0, tam);
						window.event.cancelBubble = true;
						window.event.returnValue = false;
					}
					objeto.value = vr.substr( 0, tam - 6 ) + '.' + vr.substr( tam - 6, 3 ) + '.' + vr.substr( tam - 3, 3 ); 
				}
				if ( (tam >= 10) && (tam <= 12) )
				{
			 		if(tecla == 8)
					{
						objeto.value = vr.substr(0, tam);
						window.event.cancelBubble = true;
						window.event.returnValue = false;
					}
					objeto.value = vr.substr( 0, tam - 9 ) + '.' + vr.substr( tam - 9, 3 ) + '.' + vr.substr( tam - 6, 3 ) + '.' + vr.substr( tam - 3, 3 ); 
				}

				if ( (tam >= 13) && (tam <= 15) )
				{
					if(tecla == 8)
					{
						objeto.value = vr.substr(0, tam);
						window.event.cancelBubble = true;
						window.event.returnValue = false;
					}
					objeto.value = vr.substr( 0, tam - 12 ) + '.' + vr.substr( tam - 12, 3 ) + '.' + vr.substr( tam - 9, 3 ) + '.' + vr.substr( tam - 6, 3 ) + '.' + vr.substr( tam - 3, 3 ) ;
				}			
			}
		}
	}
	else if((window.event.keyCode != 8) && (window.event.keyCode != 9) && (window.event.keyCode != 13) && (window.event.keyCode != 35) && (window.event.keyCode != 36) && (window.event.keyCode != 46))
		{
			window.event.cancelBubble = true;
			window.event.returnValue = false;
		}
}
var navegador = navigator.userAgent.toLowerCase();
var xmlhttp2;
function objetoXML() {
    if (navegador.indexOf('msie') != -1) { //Internet Explorer
        var controle = (navegador.indexOf('msie 5') != -1) ? 'Microsoft.XMLHTTP' : 'Msxml2.XMLHTTP'; 
        try {
            xmlhttp2 = new ActiveXObject(controle);
        } catch (e) { }
    } else {
        xmlhttp2 = new XMLHttpRequest(); //Inicia o objeto no Firefox, Safari, Mozilla
    }
};
function enviarForm(url, campos, destino) {
    var elemento = pega(destino);
    objetoXML();
	manipulaelemento('popmensagem','e');
    if (!xmlhttp2) {
		elemento.innerHTML = 'Impossível iniciar o objeto XMLHttpRequest.';
		window.setTimeout(function()
			{
				manipulaelemento('popmensagem','o');
			}, 3000);
        return;
    } else {
		elemento.innerHTML = 'Carregando...';
    }
    xmlhttp2.onreadystatechange = function () {
        //Se a requisição estiver completada
        if (xmlhttp2.readyState == 4 || xmlhttp2.readyState == 0) {
            //Se o status da requisição estiver OK
            if (xmlhttp2.status == 200) {
                elemento.innerHTML = xmlhttp2.responseText;
				window.setTimeout(function()
					{
						manipulaelemento('nomecontato','l');
					}, 1000);
				window.setTimeout(function()
					{
						manipulaelemento('emailcontato','l');
					}, 2000);
				window.setTimeout(function()
					{
						manipulaelemento('telefonecontato','l');
					}, 3000);
				window.setTimeout(function()
					{
						manipulaelemento('mensagemcontato','l');
					}, 4000);
				window.setTimeout(function()
					{
						manipulaelemento('popmensagem','o');
					}, 5000);
            } else {
                elemento.innerHMTL = 'Página não encontrada!';
				window.setTimeout(function()
					{
						manipulaelemento('popmensagem','o');
					}, 3000);
            }
        }
    }
    xmlhttp2.open('POST', url+'?'+campos, true);
    xmlhttp2.send(campos);
};
function enviarcontato(){
	setarCampos();enviarForm('scripts/processacontato.asp', campos, 'mensagem', 'popmensagem'); return false;
};
function url_encode(str)
{ 
		var hex_chars = "0123456789ABCDEF"; 
		var noEncode = /^([a-zA-Z0-9\_\-\.])$/; 
		var n, strCode, hex1, hex2, strEncode = ""; 
		for(n = 0; n < str.length; n++) { 
			if (noEncode.test(str.charAt(n))) { 
				strEncode += str.charAt(n); 
			} else { 
				strCode = str.charCodeAt(n); 
				hex1 = hex_chars.charAt(Math.floor(strCode / 16)); 
				hex2 = hex_chars.charAt(strCode % 16); 
				strEncode += "%" + (hex1 + hex2); 
			} 
		} 
		return strEncode; 
};
// track analise de trafego
var pagetitle = document.title;
var scriptlocation = "/analisedetrafego/track.asp";
var pagedata = 'mtpt=' + escape(pagetitle) + '&mtr=' + escape(document.referrer) + '&mtt=2&mts=' + window.screen.width + 'x' + window.screen.height + '&mti=1&mtz=' + Math.random();
document.write ('<img height=1 width=1 ');
document.write ('src="' + scriptlocation + '?' + pagedata + '">');
// DROPDOWN WEB2
var gId = "";
function postField(hiddenFieldID, val) {
    if(hiddenFieldID != null && hiddenFieldID != "")
    {
        var hiddenField = document.getElementById(hiddenFieldID);
        if (hiddenField) {
            hiddenField.value = val;
            __doPostBack(hiddenFieldID,'');
        }
    }
};
function selectField(hiddenFieldID, val)
{
    if(hiddenFieldID != null && hiddenFieldID != "")
    {
        var hiddenField = document.getElementById(hiddenFieldID);
         if (hiddenField)
            hiddenField.value = val;
    }
};
function iniciaCombo() {
	comboBox_web2();
};
function comboBox_web2()
{
    $('div.webII_dropdown span.meio a').unbind("click");
    $('div.webII_dropdown span.meio a').click(function() {
    	var p = $(this).parent().parent();
    	$('.divConteudowebII_dropdown').each(function(i) {
    		if ($(this).parent()[0] !== p[0]) {
    			$(this).slideUp();
    			$(this).parent().css({ "zIndex": 1 });
    		}
    		$("body").unbind("click");
    		$(".divConteudowebII_dropdown").removeClass("pbActive");
    	});
    	p.find('.divConteudowebII_dropdown').each(function() {
    		var e = $(this).parent().css("zIndex");
    		if (e == 1) {
    			$(this).parent().css({ "zIndex": 502 });
    		}
    		$(this).slideToggle("fast", function() {
    			if (e != 1) {
    				$(this).parent().css({ "zIndex": 1 });
    				$(".divConteudowebII_dropdown").removeClass("pbActive");
    			}
    			$("body").bind("click", function(e) 
    			{
    				var fecha = true;
    				$('.divConteudowebII_dropdown *', p).each(function() 
    				{
    					if (e.target == $(this)[0]) 
    					{
    						fecha = false;
    					}
    				});
    				if (fecha) 
    				{
    					$(p).css({ "zIndex": 1 });

    					
    					p.find('.divConteudowebII_dropdown').hide();
    					$("body").unbind("click");
    					$(".divConteudowebII_dropdown").removeClass("pbActive");
    					return false;
    				}
    			});
    		});
    	});
    	$(".boxwebII_dropdown", p).jScrollPane({ scrollbarWidth: 12, scrollbarMargin: 10, showArrows: true, dragMaxHeight: 8 });
    	return false;
    });
};
function swapmenu(onmouse,img,li){
	switch (onmouse)
	{
		case 'over':
			pega(li).innerHTML='';
			return false;
		case 'out':
			pega(li).innerHTML='';
			return false;
	}
};
function carregaimagens() {
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=carregaimagens.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 pegaObj(n, d) {
  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=pegaObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
};
function swapImagemRestaura() {
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
};
function swapImagem() {
  var i,j=0,x,a=swapImagem.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=pegaObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
};
function fazerpergunta()
{
	xmlhttp.open("GET", "scripts/processapergunta.asp?duvida=" + pega('duvida').value + "", true);
	xmlhttp.onreadystatechange = function()
	{
		if (xmlhttp.readyState==4)
		{
			manipulaelemento('popmensagem','e');
			pega('mensagem').innerHTML = xmlhttp.responseText;
			window.setTimeout(function()
				{
					pega('duvida').value='';
					manipulaelemento('popmensagem','o');
				}, 3000); /*  milisegundos */
		}
	}	
	xmlhttp.send(null);
};
function votar(){
	if (confirm('Deseja realmente votar nesta opção?'))
	{
		var opcao = pega('opcaoh').value;
		var idenqueteh = pega('idenqueteh').value;
		pega('qenquetemeio').innerHTML = '<p style=text-align:center><br><br><br><img src=assets/loading2.gif width=170px style=margin:auto; /><br><br><br><br></p>';
		window.setTimeout(function()
			{
				xmlhttp.open("GET", "scripts/processavoto.asp?id=" + idenqueteh + "&opcao=" + opcao + "&votar=ok", true);
				xmlhttp.onreadystatechange = function()
				{
					if (xmlhttp.readyState==4)
					{
						pega('qenquetemeio').innerHTML = '<p style=text-align:center;color:#ca1c23;><br><br><strong>Voto computado com Sucesso!</strong><br>Aguarde as estatísticas<br><br><br></p>';
						window.setTimeout(function()
						{
							pega('qenquetemeio').innerHTML = xmlhttp.responseText;
						}, 3000);
					}
				};
				xmlhttp.send(null);
			}, 1000); /*  milisegundos */
	}
};
function exibeabaimovel(qualaba)
{
 //alert('aba atual é '+pega('abaatual').value );
 manipulaelemento(pega('abaatual').value ,'o');
 pega('abaatual').value=qualaba;
 //alert('aba atual recebeu '+pega('abaatual').value );
 manipulaelemento(pega('abaatual').value ,'e');
};
function transferevalorbusca(valor,alvo,aID,texto,menu,ajax,tiporesposta,parametro,lugardaresposta){
	var dd;
	if (ajax=='true')
	{
				//alert('entrou');
				document.getElementById('h_bairro').value='Selecione';
				document.getElementById('meiobairro').innerHTML='<span style="line-height:17px;WIDTH: 109px; PADDING-RIGHT: 15px; BACKGROUND: url(../imagens/setabaixo-off.png) no-repeat right top; FLOAT: left;">Carregando ...</span>'
				xmlhttp.open("GET", "scripts/processa_ajax_dropdown.asp?sess=" + tiporesposta + "&parametro=" + parametro + "", true);
				xmlhttp.onreadystatechange = function()
				{
					if (xmlhttp.readyState==4)
					{
						if(xmlhttp.responseText!='vazio')
						{
							document.getElementById('meiobairro').innerHTML='<A href=javascript:void(0); id=dropdown_bairro>Selecione</A>'
						}
						else
						{
							document.getElementById('meiobairro').innerHTML='<span style="line-height:17px;WIDTH: 109px; PADDING-RIGHT: 15px; BACKGROUND: url(../imagens/setabaixo-off.png) no-repeat right top; FLOAT: left;">Cidade sem bairro</span>';
						}
					}
				};
				xmlhttp.send(null);
				reinitialiseScrollPane = function()
				{
					try{comboBox_web2()} catch(e){};
				}
				$('#' + lugardaresposta).load('scripts/processa_ajax_dropdown.asp?sess=' + tiporesposta + '&parametro=' + parametro + '', '', reinitialiseScrollPane);
	}
	pega(alvo).value=valor;
	if (valor>1)
		{
			dd=' ' + texto + 's';
		}
	else
		{
			dd=' ' + texto;
		}
	if (texto != 'nulo')
	{
		pega(aID).innerHTML=valor + dd;
	}
	else
	{
		pega(aID).innerHTML=valor.substr(0, 19);
	}
	
	manipulaelemento(menu,'o');
};