function mostraMensagemErro(n,e) {
	if (e == '') {
		alert("Problemas no processamento, tente novamente!")
	}
}

function abreInteracao() {
	var teste = (document.body.scrollHeight || document.body.offsetHeight);
	$("boxInteracao").style.height = teste +'px';
	Element.show("boxInteracao");
}
function fechaInteracao() {
	Element.hide("boxInteracao");
}

function abreIndicar() {
	abreInteracao();
	$("boxIndicar").style.marginTop = (((document.documentElement.scrollTop || document.body.scrollTop)+(screen.height/2)-255)) +'px';	
	Element.show("boxIndicar");
}
function fechaIndicar() {
	fechaInteracao();
	Element.hide("boxIndicar");
}


function abreMensagem() {
	abreInteracao();
	$("boxMensagem").style.marginTop = (((document.documentElement.scrollTop || document.body.scrollTop)+(screen.height/2)-275)) +'px';	
	Element.show("boxMensagem");
}
function fechaMensagem() {
	fechaInteracao();
	Element.hide("boxMensagem");
}

function excluirLista(id) {
var confirmacao = confirm("Confirma remover este imóvel de sua lista de imóveis marcados?")
if (confirmacao) {
$("formLista" +id).submit();
}
}

function abreEmpresa() {
	abreInteracao();
	$("boxEmpresa").innerHTML = '<div class="chamada">Quem somos e conheça nosso trabalho</div><div class="box_geral_0"><div class="box_geral_1"><div class="box_geral_2"><div class="box_geral_3"><div class="box_geral_4"><div class="texto">O Litoral Homes é um portal de classificados que oferece as melhores opções na compra, venda ou investimento para ao mercado imobiliário.<br /><br />Nosso objetivo é oferecer aos internautas o maior e mais completo banco de dados de imóveis, oferecendo o máximo de informações sobre dos imóveis.<br /><br />Oferecemos uma plataforma moderna e dinâmica, ajustada aos mais modernos meios de pesquisa da Internet.</div><div class="fechar"><a href="#" onclick="javascript: fechaEmpresa(); return false;">fechar</a></div></div></div></div></div></div>';
	$("boxEmpresa").style.marginTop = (((document.documentElement.scrollTop || document.body.scrollTop)+(screen.height/2)-270)) +'px';	
	Element.show("boxEmpresa");
}
function fechaEmpresa() {
	fechaInteracao();
	$("boxEmpresa").innerHTML = '';
	Element.hide("boxEmpresa");
}




function abreContato() {
	abreInteracao();
	$("boxContato").innerHTML = '<div class="chamada">Entre em contato com o Litoral Homes</div><div class="box_geral_0"><div class="box_geral_1"><div class="box_geral_2"><div class="box_geral_3"><div class="box_geral_4"><form id="formContato" name="formContato" onsubmit="javascript: return false;"><div class="titulo"><table border="0" cellpadding="0" cellspacing="0"><tbody><tr><td width="263">Seu nome</td><td>Seu email</td></tr></tbody></table></div><div class="titulo_2"><table border="0" cellpadding="0" cellspacing="0"><tbody><tr><td width="263"><input name="nome" id="nome" type="text"></td><td><input name="email" id="email" type="text"></td></tr></tbody></table></div><div class="titulo"><table border="0" cellpadding="0" cellspacing="0"><tbody><tr><td width="263">Seu telefone</td><td>Assunto</td></tr></tbody></table></div><div class="titulo_2"><table border="0" cellpadding="0" cellspacing="0"><tbody><tr><td width="263"><input name="telefone" id="telefone" type="text"></td><td><select name="assunto"><option value="Informações" selected="selected">Informações</option><option value="Anunciar">Anunciar</option><option value="Suporte">Suporte</option></select></td></tr></tbody></table></div><div class="titulo_1"><table border="0" cellpadding="0" cellspacing="0"><tbody><tr><td width="263">Mensagem</td></tr></tbody></table></div><div class="titulo_2"><table border="0" cellpadding="0" cellspacing="0"><tbody><tr><td><textarea name="mensagem" id="mensagem"></textarea></td></tr></tbody></table></div><div class="titulo_3"><a href="#" id="botao_contato" onclick="javascript: Contato(); return false;">enviar</a><span id="botao_contato_aguarde" style="display: none;">aguarde</span><span style="padding-left: 20px;"><a href="#" onclick="javascript: fechaContato(); return false;">cancelar</a></span></div></form></div></div></div></div></div>';
	$("boxContato").style.marginTop = (((document.documentElement.scrollTop || document.body.scrollTop)+(screen.height/2)-305)) +'px';	
	Element.show("boxContato");
}
function fechaContato() {
	fechaInteracao();
	$("boxContato").innerHTML = '';
	Element.hide("boxContato");
}


function abreAnunciar() {
	abreInteracao();
	$("boxAnunciar").innerHTML = '<div class="chamada">Anuncie seus imóveis no Litoral Homes</div><div class="box_geral_0"><div class="box_geral_1"><div class="box_geral_2"><div class="box_geral_3"><div class="box_geral_4"><div class="texto">Anuncie seus imóveis e sua imobiliária com um baixo custo. O Litoral Homes oferece também o desenvolvimento de um site para sua imobiliária e disponibiliza uma ferramenta para cadastro e atualização dos imóveis.<br /><br />Os imóveis que são anunciados no Litoral Homes, também são divulgados em outras mídias, como jornal com circulação local (versão impressa) e sites parceiros da região.<br /><br />Os anúncios no Litoral Homes são realizados através da internet, tudo muito prático, rápido e seguro. Mais facilidade, comodidade e economia para quem está anunciando.</div><div class="fechar"><a href="#" id="botao_contato" onclick="javascript: fechaAnunciar(); abreContato(); return false;">contato</a><span style="padding-left: 20px;"><a href="#" onclick="javascript: fechaAnunciar(); return false;">fechar</a></span></div></div></div></div></div></div>';
	$("boxAnunciar").style.marginTop = (((document.documentElement.scrollTop || document.body.scrollTop)+(screen.height/2)-300)) +'px';	
	Element.show("boxAnunciar");
}
function fechaAnunciar() {
	fechaInteracao();
	$("boxAnunciar").innerHTML = '';
	Element.hide("boxAnunciar");
}




function abreLista(id) {
	var url = 'includes/lista_exe.asp';
	var pars = 'id='+id;
	var myAjax = new Ajax.Request(
			url, 
		{
			method: 'get', 
			parameters: pars, 
			onFailure: abreLista_erro,
			onSuccess: extraiScript
		}
		);
}
function abreLista_erro() {
	mostraMensagemErro(1,'')
}


function popup(url, width, height, left, top, scrollbars, toolbar, location, status, menubar, resizable, nome) {
  top = ( (screen.height/2) - (height/2) )
  left = ( (screen.width/2) - (width/2) -10 )
  text = "Você deve desativar o bloqueador de popup.";
  janela = window.open(url,nome,'width='+width+',height='+height+',scrollbars='+scrollbars+',toolbar='+toolbar+',location='+location+',status='+status+',menubar='+menubar+',resizable='+resizable+',left='+left+',top='+top);
  if(janela == null) { alert(text); return; }
  janela.focus();
}

function LimitaCaracteres(campo,tamanho){
   intCaracteres = tamanho - campo.value.length;
   if (intCaracteres > 0){
      return true;
   }
   else {
      campo.value = campo.value.substr(0,tamanho)
	  alert("Você atingiu o limite de caracteres disponível para escrever.")
      return false;
   }
}


function mascaras(e,src,mask) {
if(window.event) { _TXT = e.keyCode; } 
else if(e.which) { _TXT = e.which; }
if((_TXT > 47 && _TXT < 58) || (_TXT == 8)) { var i = (src.value.length); var saida = mask.substring(0,1); var texto = mask.substring(i)
	if (_TXT > 7 && _TXT <9) { return true; }
	if (texto.substring(0,1) != saida) {src.value += texto.substring(0,1); obmv = src.createTextRange(); obmv.collapse(false); obmv.select(); } return true; } else {if (_TXT != 14) { return false; } else { return true; }

}
}







function imoveis_procurar_negocios(){
	var cidade = $("imoveis_cidade").value
	
	var s=document.getElementById("imoveis_negocio")
	if (cidade!=0){
	while(s.options.length>0)s.options[0]=null
	s.options[0]=new Option("Carregando","0")
	} else {
	while(s.options.length>0)s.options[0]=null
	s.options[0]=new Option("Qualquer negócio","0")
	}
	
	var s=document.getElementById("imoveis_categoria")
	while(s.options.length>0)s.options[0]=null
	s.options[0]=new Option("Qualquer imóvel","0")
	
	var s=document.getElementById("imoveis_bairro")
	while(s.options.length>0)s.options[0]=null
	s.options[0]=new Option("Qualquer bairro","0")
	
	if (cidade!=0){
	var url = 'includes/procurar_dadosnegocios_exe.asp';
	var pars = 'cidade='+cidade+'&rolagem='+(document.documentElement.scrollTop || document.body.scrollTop);
	var myAjax = new Ajax.Request(
			url, 
		{
			method: 'get', 
			parameters: pars, 
			onFailure: imoveis_procurar_negocios_erro,
			onSuccess: imoveis_procurar_negocios_atualiza
		}
		);
	}
}
function imoveis_procurar_negocios_atualiza(texto){
var c=document.getElementById("imoveis_negocio")
var d = texto.responseText.split("||||");
var dados=eval((d[0]))
while(c.options.length>0)c.options[0]=null
	for(var i=0;i<dados.length;i++){
		dados[i]=(dados[i])
		var tmp = dados[i].split("|");
		c.options[c.options.length]=new Option(tmp[1],tmp[0])
	}
extraiScript(texto)
}

function imoveis_procurar_negocios_erro() {

	$("pesquisa").reset();

	var s=document.getElementById("imoveis_negocio")

	while(s.options.length>0)s.options[0]=null
	s.options[0]=new Option("Qualquer negócio","0")


	var s=document.getElementById("imoveis_categoria")

	while(s.options.length>0)s.options[0]=null
	s.options[0]=new Option("Qualquer imóvel","0")
	
	var s=document.getElementById("imoveis_bairro")
	while(s.options.length>0)s.options[0]=null
	s.options[0]=new Option("Qualquer bairro","0")
	
	var s=document.getElementById("imoveis_negocio")
	s.value = 0;
	
	mostraMensagemErro(1,'')
}






function imoveis_procurar_categorias(){
	var cidade = $("imoveis_cidade").value
	var negocio = $("imoveis_negocio").value
	var s=document.getElementById("imoveis_categoria")
	if (negocio!=0){
	while(s.options.length>0)s.options[0]=null
	s.options[0]=new Option("Carregando","0")
	} else {
	while(s.options.length>0)s.options[0]=null
	s.options[0]=new Option("Qualquer imóvel","0")
	}
	
	var s=document.getElementById("imoveis_bairro")
	while(s.options.length>0)s.options[0]=null
	s.options[0]=new Option("Qualquer bairro","0")
	
	if (negocio!=0){
	var url = 'includes/procurar_dados_exe.asp';
	var pars = 'cidade='+cidade+'&negocio='+negocio+'&rolagem='+(document.documentElement.scrollTop || document.body.scrollTop);
	var myAjax = new Ajax.Request(
			url, 
		{
			method: 'get', 
			parameters: pars, 
			onFailure: imoveis_procurar_categorias_erro,
			onSuccess: imoveis_procurar_categorias_atualiza
		}
		);
	}
}
function imoveis_procurar_categorias_atualiza(texto){
var c=document.getElementById("imoveis_categoria")
var d = texto.responseText.split("||||");
var dados=eval((d[0]))
while(c.options.length>0)c.options[0]=null
	for(var i=0;i<dados.length;i++){
		dados[i]=(dados[i])
		var tmp = dados[i].split("|");
		c.options[c.options.length]=new Option(tmp[1],tmp[0])
	}
extraiScript(texto)
}

function imoveis_procurar_categorias_erro() {
	mostraMensagemErro(1,'')
	var s=document.getElementById("imoveis_categoria")

	while(s.options.length>0)s.options[0]=null
	s.options[0]=new Option("Qualquer imóvel","0")
	
	var s=document.getElementById("imoveis_bairro")
	while(s.options.length>0)s.options[0]=null
	s.options[0]=new Option("Qualquer bairro","0")
	
	var s=document.getElementById("imoveis_negocio")
	s.value = 0;
}

function imoveis_procurar_bairros(){
	var cidade = $("imoveis_cidade").value
	var categoria = $("imoveis_categoria").value
	var negocio = $("imoveis_negocio").value
	var categoria = $("imoveis_categoria").value
	var s=document.getElementById("imoveis_bairro")
	if (categoria!=0){
	while(s.options.length>0)s.options[0]=null
	s.options[0]=new Option("Carregando","0")
	} else {
	while(s.options.length>0)s.options[0]=null
	s.options[0]=new Option("Qualquer bairro","0")
	}
	
	if (categoria!=0){
	var url = 'includes/procurar_dados_exe.asp';
	var pars = 'cidade='+cidade+'&negocio='+negocio+'&categoria='+categoria+'&rolagem='+(document.documentElement.scrollTop || document.body.scrollTop);
	var myAjax = new Ajax.Request(
			url, 
		{
			method: 'get', 
			parameters: pars, 
			onFailure: imoveis_procurar_bairros_erro,
			onSuccess: imoveis_procurar_bairros_atualiza
		}
		);
	}
}
function imoveis_procurar_bairros_atualiza(texto){
var c=document.getElementById("imoveis_bairro")
var d = texto.responseText.split("||||");
var dados=eval((d[0]))
while(c.options.length>0)c.options[0]=null
	for(var i=0;i<dados.length;i++){
		dados[i]=(dados[i])
		var tmp = dados[i].split("|");
		c.options[c.options.length]=new Option(tmp[1],tmp[0])
	}
extraiScript(texto)
}

function imoveis_procurar_bairros_erro() {
	mostraMensagemErro(1,'')
	var s=document.getElementById("imoveis_categoria")

	while(s.options.length>0)s.options[0]=null
	s.options[0]=new Option("Qualquer imóvel","0")
	
	var s=document.getElementById("imoveis_bairro")
	while(s.options.length>0)s.options[0]=null
	s.options[0]=new Option("Qualquer bairro","0")

	var s=document.getElementById("imoveis_negocio")
	s.value = 0;
}


function Mensagem() {
	var url = 'includes/mensagem_exe.asp';
	var pars = Form.serialize('formMensagem');
	var myAjax = new Ajax.Request(
			url, 
		{
			method: 'post', 
			parameters: pars, 
			onFailure: MensagemErro,
			onCreate: Element.hide('botao_mensagem'),
			onCreate: Element.show('botao_mensagem_aguarde'),
			onSuccess: extraiScript
		}
		);
}
function MensagemErro() {
	Element.show('botao_mensagem')
	Element.hide('botao_mensagem_aguarde')
	mostraMensagemErro(1,'')
}

function Indicar() {
	var url = 'includes/indicar_exe.asp';
	var pars = Form.serialize('formIndicar');
	var myAjax = new Ajax.Request(
			url, 
		{
			method: 'post', 
			parameters: pars, 
			onFailure: IndicarErro,
			onCreate: Element.hide('botao_indicar'),
			onCreate: Element.show('botao_indicar_aguarde'),
			onSuccess: extraiScript
		}
		);
}
function IndicarErro() {
	Element.show('botao_indicar')
	Element.hide('botao_indicar_aguarde')
	mostraMensagemErro(1,'')
}


function Contato() {
	var url = 'includes/contato_exe.asp';
	var pars = Form.serialize('formContato');
	var myAjax = new Ajax.Request(
			url, 
		{
			method: 'post', 
			parameters: pars, 
			onFailure: ContatoErro,
			onCreate: Element.hide('botao_contato'),
			onCreate: Element.show('botao_contato_aguarde'),
			onSuccess: extraiScript
		}
		);
}
function ContatoErro() {	
	Element.show('botao_contato')
	Element.hide('botao_contato_aguarde')
	mostraMensagemErro(1,'')
}







var bo_ns_id = 0;

function startIeFix(){
  if(isIE()){
    document.write('<div id="bo_ns_id_' + bo_ns_id + '"><!-- ');
  }
}

function endIeFix(){
  if(isIE()){
    document.write('</div>');
    var theObject = document.getElementById("bo_ns_id_" + bo_ns_id++);
    var theCode = theObject.innerHTML;
    theCode = theCode.substring(4 ,9+theCode.indexOf("</object>"))
    document.write(theCode);
  }
}

function isIE(){
  var strBrowser = navigator.userAgent.toLowerCase();
  if(strBrowser.indexOf("msie") > -1 && strBrowser.indexOf("mac") < 0){
    return true;
  }else{
    return false;
  }
}