$(function(){

				$('#atendimento').dialog({
					autoOpen: false,
					width: 570,
					height: 490,
					zIndex: 3999,
					resizable: false
					
				});
				$('#liga').dialog({
					autoOpen: false,
					width: 500,
					height: 580,
					resizable: false
					
				});
				$('#skipe').dialog({
					autoOpen: false,
					width: 300,
					height: 300,
					zIndex: 3999,
					resizable: false
					
				});
				$('#fale').dialog({
					autoOpen: false,
					width: 560,
					height: 480,
					zIndex: 3999,
					resizable: false
					
				});
				$('#depoimento').dialog({
					autoOpen: false,
					width: 560,
					height: 480,
					zIndex: 3999,
					resizable: false
					
				});
			    $('#chat').dialog({
					autoOpen: false,
					width: 425,
					height: 450,
					zIndex: 3999,
					resizable: false
					
				});
				
				$('#indique_imovel').dialog({
					autoOpen: false,
					width: 500,
					height: 300,
					zIndex: 3999,
					resizable: false
					
				});
				$('#documentacao_imovel').dialog({
					autoOpen: false,
					width: 850,
					height: 550,
					zIndex: 3999,
					resizable: false
					
				});
				$('#vantagem_venda').dialog({
					autoOpen: false,
					width: 850,
					height: 550,
					zIndex: 3999,
					resizable: false
					
				});
				
				$('#informe_seu_nome').dialog({
					autoOpen: false,
					width: 400,
					height: 100,
					zIndex: 3999,
					resizable: false
					
				});
				$('#linha_1,#linha_1_2').click(function(){

					window.open('http://www.chatcomercial.com.br/livehelp/www/visitor/?userId=12072269479215023&COMPANY_ID=2059&SITE_ID=2302','page','toolbar=no,location=no,status=no,menubar=no,scrollbars=no,resizable=no,width=658,height=500');
					
					
					return false;
				});
				
				$('#linha_2').click(function(){
					$('#fale').dialog('open');
				    carregaAjax('resposta','envia_email.php?flag=0');
					document.getElementById('mensagem').value = '';
					document.getElementById('texto_fale_conosco').style.display= 'block';
					return false;
				});
				
				
				if(get_bicoito('nome_cliente') == null)
					$('#informe_seu_nome').dialog('open');
				else{
					document.getElementById('troca_nome').style.display = 'block';
					$('#nome_nao_sou').html(''+get_bicoito('nome_cliente')+'');
					atualiza_nome();
				}

					
				$('#deixe_depoimento,#deixe_depoimento_2,').click(function(){
					carregaAjax('resposta_depoimento','envia_email.php?flag=0');
					$('#depoimento').dialog('open');
					return false;
				});
				
				$('#linha_3,#linha_3_2').click(function(){
					$('#skipe').dialog('open');
					
					return false;
				});
				$('#linha_4,#linha_4_2').click(function(){
				
					
									window.open('http://settings.messenger.live.com/Conversation/IMMe.aspx?invitee=140015772af48400@apps.messenger.live.com&mkt=pt-br','page','toolbar=no,location=no,status=no,menubar=no,scrollbars=no,resizable=no,width=400,height=400');
					
					
					return false;
				});
				$('#linha_5,#linha_5_2').click(function(){
					 carregaAjax('resposta_teliga','envia_email.php?flag=0');
					 aciona_data();
					$('#liga').dialog('open');
					
					return false;
				});
	
				
			});
	
function troca_cor(name,tip,id_menu,id_sub){
			
	if(tip == 'out'){
			document.getElementById('sub_'+name).style.visibility='hidden';
			document.getElementById('link_'+name).src='imagens/'+name+'.png';
			
			
	}if(tip == 'over'){
			document.getElementById('sub_'+name).style.visibility ='visible';
			document.getElementById('link_'+name).src='imagens/'+name+'_2.png';
				}
}	


function teste(){
	document.getElementById('div_fundo').style.display = 'block';
	setTimeout("document.getElementById('div_fundo').style.display = 'none'",2000);
}



$(document).ready(function(){
			
			$('#link_menu_1,#linha_5,#linha_4,#linha_3,#linha_1,#linha_2,#link_menu_5,.banner_4_img,#volta_1,#avanca_1,#link_menu_2,#link_menu_3,#menu_4,#master_pet').tooltip({
				track: true,
				delay: 100,
				showURL: false,
				fixPNG: true,
				showBody: " - ",
				extraClass: "pretty fancy",
				top: 5,
				left: -5
			});
		});
								
							

function getWidth()
{
	return window.innerWidth ? window.innerWidth : /* For non-IE */
	document.documentElement ? document.documentElement.clientWidth : /* IE 6+ (Standards Compilant Mode) */
	document.body ? document.body.clientWidth : /* IE 4 Compatible */
	window.screen.width; /* Others (It is not browser window size, but screen size) */
}
function getHeight()
{
	return window.innerHeight ? window.innerHeight : /* For non-IE */
	document.documentElement ? document.documentElement.clientHeight : /* IE 6+ (Standards Compilant Mode) */
	document.body ? document.body.clientHeight : /* IE 4 Compatible */
	window.screen.height; /* Others (It is not browser window size, but screen size) */
}





function links(titulo,modulo,codigo){
	if(modulo == 2){
		 detalhes(codigo, 1);
	}else{
		conteudo_principal(titulo,modulo);
	}
	
	
	
}
function links2(titulo,modulo,codigo){
	if(modulo == 2){
		 detalhes2(codigo, 1);
	}else{
		conteudo_principal(titulo,modulo);
	}
	
	
}





function detalhes(codigo, flag, voltar){
			randomico_master_pet();
		if(voltar != 1){
			voltar_avancar("2","Detalhes do Im&oacute;vel",codigo);		
		}
	    set_bicoito('pesquisa_imovel', 'aberto');
		if(flag == 0 && voltar != 1){
			//alert('a');
			bookmarkscroll.scrollTo('titulo_pagina');
			document.getElementById("ancora_posicao").value = 3;
		}
		carregaConteudo('o_conteudo','auxiliar.php?modulo=2&cod='+codigo);
		document.getElementById('titulopagina').innerHTML = "Detalhes do Im&oacute;vel";
		inicia_principal();
		document.getElementById('pesquisa_abre_fecha_img').style.display = "block";
		if(get_bicoito('pesquisa_imovel') == "aberto"){
		 	document.getElementById('pesquisa').style.display = "block";
		    document.getElementById('pesquisa_abre_fecha_img').src = "imagens/pesquisa_menos.png";
	 	}
		else{
			document.getElementById('pesquisa').style.display = "none";
			 document.getElementById('pesquisa_abre_fecha_img').src = "imagens/pesquisa_mais.png";
		}
		
	    set_bicoito('titulo_pagina', "Detalhes do Im&oacute;vel");
		set_bicoito('local_pagina', "2");
		set_bicoito('imovel_select', codigo);
		//document.location = '#'+get_bicoito('link_carosel');
	
}

function detalhes2(codigo, flag, voltar){

			randomico_master_pet();
		if(voltar != 1){
			voltar_avancar("2","Detalhes do Im&oacute;vel",codigo);		
		}
	    set_bicoito('pesquisa_imovel', 'aberto');
		if(flag == 0 && voltar != 1){
			//alert('a');
			bookmarkscroll.scrollTo('titulo_pagina');
			document.getElementById("ancora_posicao").value = 3;
		}
		carregaConteudo('o_conteudo','auxiliar.php?modulo=2&flag=1&cod='+codigo);
		document.getElementById('titulopagina').innerHTML = "Detalhes do Im&oacute;vel";
		inicia_principal();
		document.getElementById('pesquisa_abre_fecha_img').style.display = "block";
		if(get_bicoito('pesquisa_imovel') == "aberto"){
		 	document.getElementById('pesquisa').style.display = "block";
		    document.getElementById('pesquisa_abre_fecha_img').src = "imagens/pesquisa_menos.png";
	 	}
		else{
			document.getElementById('pesquisa').style.display = "none";
			 document.getElementById('pesquisa_abre_fecha_img').src = "imagens/pesquisa_mais.png";
		}
		
	    set_bicoito('titulo_pagina', "Detalhes do Im&oacute;vel");
		set_bicoito('local_pagina', "2");
		set_bicoito('imovel_select', codigo);
		//document.location = '#'+get_bicoito('link_carosel');
	
}









function inicia_principal(){
	
	document.getElementById('pesquisa_abre_fecha_img').style.display = "block";
	document.getElementById("conteudo_principal").style.display = "block";
	document.getElementById("conteudo_inicial").style.display = "none";
	document.getElementById('pesquisa').style.display = "none";
	document.getElementById('tamanho_div').style.height = "";
	//	alert(document.getElementById('fundo_esquerda').style.background);
	document.getElementById('fundo_esquerda').style.background = "url(imagens/fundo_esquerda_cabecalho.png) no-repeat right";
	//alert(document.getElementById('fundo_direita').style.background);
	document.getElementById('fundo_direita').style.background = "url(imagens/fundo_direita_cabesalho.png) no-repeat left";
	document.getElementById('img_direita').style.background = "url(imagens/fundo_direita_1px.png) repeat-y left";
	document.getElementById('img_esquerda').style.background = "url(imagens/fundo_esquerda_1px.png) repeat-y right";
	
	document.getElementById('rodape_esquerda').style.background =  "url(imagens/fundo_esquerda_rodape_p.png) no-repeat right";
	document.getElementById('rodape_direita').style.background = "url(imagens/fundo_direita_rodape_p.png) no-repeat left";
	
	document.getElementById('rodape_p').style.background = "url(imagens/rodape_p.png) no-repeat";
	teste();
	
}



function inicia_inicial(){
	
	randomico_master_pet();
	document.getElementById('pesquisa_abre_fecha_img').style.display = "none";
	document.getElementById('pesquisa').style.display = "block";
	document.getElementById("conteudo_principal").style.display = "none";
	document.getElementById("conteudo_inicial").style.display = "block";
	document.getElementById('tamanho_div').style.height = "210px";
	
	
    document.getElementById('fundo_esquerda').style.background = "";
	document.getElementById('fundo_direita').style.background = "";
	document.getElementById('img_direita').style.background = "url(imagens/fundo_direita.png) repeat-y left";
	document.getElementById('img_esquerda').style.background = "url(imagens/fundo_esquerda.png) repeat-y right";
	
	document.getElementById('rodape_esquerda').style.background =  "url(imagens/fundo_esquerda_rodape.png) no-repeat right";
	document.getElementById('rodape_direita').style.background = "url(imagens/fundo_direita_rodape.png) no-repeat left";
	
	document.getElementById('rodape_p').style.background = "url(imagens/rodape.png) no-repeat";
	
	teste();
	
	
}


		
function pesquisar(id_tabela,novo_src,posicao,id_vai,finalidade,opera){
	if(document.getElementById('controla_clicado').value == ''){
		document.getElementById('controla_clicado').value = id_tabela;
		document.getElementById('controla_clicado_posicao').value = posicao;
	}else{

document.getElementById(document.getElementById('controla_clicado').value).src = 'imagens/'+document.getElementById('controla_clicado').value+'.png';

		document.getElementById('controla_clicado').value = id_tabela;
		document.getElementById('controla_clicado_posicao').value = posicao;
	}
	document.getElementById(id_tabela).src = novo_src;
		document.getElementById('div_sobre').style.display = "block";
		
		set_bicoito('titulo_pagina', "Inicial");
		set_bicoito('pesquisa', "timo_descricao="+id_vai+"&operacao="+opera+"&imo_finalidade="+finalidade);
		set_bicoito('pesquisa_bt_1', id_tabela);
		set_bicoito('pesquisa_bt_2', novo_src);
			//alert('c');
    	$("#carrosel").src("carosel.php?timo_descricao="+id_vai+"&operacao="+opera+"&imo_finalidade="+finalidade, function(duration) {
        		document.getElementById('div_sobre').style.display = "none";
      		}
    	);
	//	alert('a');

}

function pesquisar_avancada(){

	var imo_codigomaster = document.getElementById('imo_codigomaster').value;

	var imo_operacao = document.getElementById('imo_operacao').value;

	var timo_codigo = document.getElementById('timo_codigo').value;

	var imo_quantidadedormitorios = document.getElementById('imo_quantidadedormitorios').value;

	var bai_codigo = document.getElementById('bai_codigo').value;

	var imo_valor_min = document.getElementById('imo_valor_min').value;

	var imo_valor_max = document.getElementById('imo_valor_max').value;


	set_bicoito('imo_codigomaster',imo_codigomaster);
	set_bicoito('imo_operacao',imo_operacao);
	set_bicoito('timo_codigo',timo_codigo);
	set_bicoito('imo_quantidadedormitorios',imo_quantidadedormitorios);
	set_bicoito('bai_codigo',bai_codigo);
	set_bicoito('imo_valor_min',imo_valor_min);
	set_bicoito('imo_valor_max',imo_valor_max);
	

	
	if( imo_codigomaster != '' || imo_operacao != '' || timo_codigo != '' || imo_quantidadedormitorios != '' || bai_codigo != '' || imo_valor_min != '' || imo_valor_max != ''){		
	document.getElementById('div_sobre').style.display = "block"; 
	//	alert('b');
	$("#carrosel").src("carosel.php?imo_codigomaster="+imo_codigomaster+"&operacao="+imo_operacao+"&timo_codigo="+timo_codigo+"&imo_quantidadedormitorios="+imo_quantidadedormitorios+"&bai_codigo="+bai_codigo+"&imo_valor_min="+imo_valor_min+"&imo_valor_max="+imo_valor_max+"&tipo=pesquisa_avancada", function(duration) {
					document.getElementById('div_sobre').style.display = "none";
			}
    	);
	}else{
		document.getElementById('div_sobre').style.display = "block"; 
		$("#carrosel").src("carosel.php?teste=0", function(duration) {
					document.getElementById('div_sobre').style.display = "none";
			}
    	);
	}
	//seta_cookie();
}

function atualiza_nome(){
		if(get_bicoito('nome_cliente') != null ){
			document.getElementById('nome').value = get_bicoito('nome_cliente');
			document.getElementById('nome_te_liga').value = get_bicoito('nome_cliente');
			document.getElementById('nome_depo').value = get_bicoito('nome_cliente');
		}
}


function seta_cookie(){
	//alert(get_bicoito('imo_operacao'));
	if(get_bicoito('imo_codigomaster') == null )
	 	document.getElementById('imo_codigomaster').value = '';
	 else
	 	document.getElementById('imo_codigomaster').value = get_bicoito('imo_codigomaster');

	if(get_bicoito('imo_operacao') == null )	
	 	document.getElementById('imo_operacao').value = "";
	 else
	 	document.getElementById('imo_operacao').value = get_bicoito('imo_operacao');
	
	if(get_bicoito('timo_codigo') == null )	
	 	document.getElementById('timo_codigo').value = "";
	 else
	 	document.getElementById('timo_codigo').value = get_bicoito('timo_codigo');
		
	if(get_bicoito('imo_quantidadedormitorios') == null )	
	 	document.getElementById('imo_quantidadedormitorios').value = "";
	 else
	 	document.getElementById('imo_quantidadedormitorios').value = get_bicoito('imo_quantidadedormitorios');
	
	if(get_bicoito('bai_codigo') == null )
	 	document.getElementById('bai_codigo').value = "";
	 else
	 	document.getElementById('bai_codigo').value = get_bicoito('bai_codigo');
	
	if(get_bicoito('imo_valor_min') == null )	
	 	document.getElementById('imo_valor_min').value = "";
	 else
	 	document.getElementById('imo_valor_min').value = get_bicoito('imo_valor_min');
	
	if(get_bicoito('imo_valor_max') == null )
	 	document.getElementById('imo_valor_max').value = "";
	 else
	 	document.getElementById('imo_valor_max').value = get_bicoito('imo_valor_max');
	
	 

}

function pesquisa_troca(tipo,flag){
	set_bicoito('tipo_pesquisar',tipo);
	if(flag != 1 ){
		$.ajax({
	
				// Usando metodo Post
				type: 'GET',
	
				// this.action pega o script para onde vai ser enviado os dados
				url: 'pesquisa_rapida_avancada.php' ,
	
				// os dados que pegamos com a função serialize()
				data: { tipo_busca : tipo },
	
				// Antes de enviar
				beforeSend: function(){
					// mostro a div loading
					$('#busca').show();
					$('#busca').html("Carregando...");
				},
				success: function(txt){
					$('#busca').html(txt);
				//	alert('a');
					seta_cookie();
					pesquisar_avancada();
								
			
		 $('#tipo_busca').html('Busca Avançada');
				},
	
				// Se acontecer algum erro é executada essa função
				error: function(txt){
					$('#busca').html('Por favor tente novamente!');
				}
			})
	}

}


function over(id_tabela,tip1,tip2){
	document.getElementById(id_tabela).src='imagens/'+id_tabela+'_'+tip1+'_'+tip2+'.png';
}
function out(id_tabela,tip1,tip2){
	if(document.getElementById('controla_clicado').value == id_tabela){
		document.getElementById(id_tabela).src='imagens/'+document.getElementById('controla_clicado').value+'_'+document.getElementById('controla_clicado_posicao').value+'.png';
		
	}else
		document.getElementById(id_tabela).src='imagens/'+id_tabela+'.png';
}



//legendas no masterpet
function masterpeat(txt,flag){
	if(flag == 0)
		document.getElementById('txt_peat').src = "formata_img/legenda.php?flag=1&txt="+txt+"&tam=10&x=7&y=55";
	else
		document.getElementById('txt_peat').src = "formata_img/legenda.php?flag=0&txt="+txt+"&tam=10&x=7&y=55";
}



//usada como link nos menus
function conteudo_principal(titulo,local,flag,voltar){
	if(voltar != 1){
	 	voltar_avancar(local,titulo,"");
	}
	randomico_master_pet();
	 if(flag != 1)
			flag = 0;
	inicia_principal();
	 if(titulo != "Inicial"){
		carregaConteudo('o_conteudo','auxiliar.php?modulo='+local);
		document.getElementById('titulopagina').innerHTML = titulo;
		//inicia_principal();
		document.getElementById('pesquisa_abre_fecha_img').style.display = "block";
		if(get_bicoito('pesquisa_imovel') == "aberto"){
		 	document.getElementById('pesquisa').style.display = "block";
		    document.getElementById('pesquisa_abre_fecha_img').src = "imagens/pesquisa_menos.png";
	 	}
		else{
			document.getElementById('pesquisa').style.display = "none";
			 document.getElementById('pesquisa_abre_fecha_img').src = "imagens/pesquisa_mais.png";

		}
		
	    set_bicoito('titulo_pagina', titulo);
		set_bicoito('local_pagina', local);
		
		if(flag == 0 && voltar != 1){
			//alert('b');
			//bookmarkscroll.scrollTo('titulo_pagina');
			document.getElementById("ancora_posicao").value = 3;
		}
	 }
	 else{
		 document.getElementById('pesquisa_abre_fecha_img').style.display = "none";
		document.getElementById('pesquisa').style.display = "block";	
		inicia_inicial();
		
		set_bicoito('titulo_pagina', 'Inicial');
		set_bicoito('local_pagina', '0');
	 }
	

	
}

function set_bicoito(nome,valor){	
	
var expire = "";
expire = new Date((new Date()).getTime() +  3600000000000);
expire = "; expires=" + expire.toGMTString();
document.cookie = nome + "=" + escape(valor) + expire;

}



function get_bicoito(nome)
{
var valorCookie = "";
var search = nome + "=";
if(document.cookie.length > 0) {
	offset = document.cookie.indexOf(search);
	if (offset != -1){
		offset += search.length;
		end = document.cookie.indexOf(";", offset);
		if (end == -1){
			end = document.cookie.length;
		}
		valorCookie = unescape(document.cookie.substring(offset, end))
	}
	else{
		valorCookie = null;
	}
}
else{
	valorCookie = null;
}
return valorCookie;

}

function busca_rapida(){
	if(get_bicoito('tipo_pesquisar') != null){
		var tipo =get_bicoito('tipo_pesquisar');
			$('#tipo_busca').html('Busca Rápida');

	}
	else{
		var tipo ='simples';
			
		 $('#tipo_busca').html('Busca Rápida');
	}
	

	
	
	
	
	
	$.ajax({

            // Usando metodo Post
            type: 'GET',

            // this.action pega o script para onde vai ser enviado os dados
            url: 'pesquisa_rapida_avancada.php' ,

            // os dados que pegamos com a função serialize()
            data: { tipo_busca : tipo },

            // Antes de enviar
            beforeSend: function(){
                // mostro a div loading
                $('#busca').show();
                $('#busca').html("Carregando...");
            },
            success: function(txt){
                $('#busca').html(txt);
				if(get_bicoito('vetor') != 0 && get_bicoito('vetor') != null){
					titulo_troca();
					
				}
				animatedcollapse.addDiv("pesquisa", 'fade=1')
				animatedcollapse.ontoggle=function($, divobj, state){ }
				animatedcollapse.init();
				//alert(tipo);
				if(tipo == 'simples'){
					if(get_bicoito('pesquisa')!= null){
						document.getElementById('div_sobre').style.display = "block"; 
						$("iframe").src("carosel.php?"+get_bicoito('pesquisa'), function(duration) {
								document.getElementById('div_sobre').style.display = "none";
							}
						);
					//	alert('a');
					}else{
						document.getElementById('div_sobre').style.display = "block"; 
						$("iframe").src("carosel.php?teste=0", function(duration) {
								document.getElementById('div_sobre').style.display = "none";
							}
						);
					}
				}
				

					if(get_bicoito('pesquisa_bt_1')!= null){		
						document.getElementById(get_bicoito('pesquisa_bt_1')).src = get_bicoito('pesquisa_bt_2');
						//alert('a');
					}
            },

            // Se acontecer algum erro é executada essa função
            error: function(txt){
                $('#busca').html('Por favor tente novamente!');
            }
        })

	 	
}

//Executada sempre que a pagina e recaregada
function inicia_site(){
	if(get_bicoito('tipo_pesquisar') != null){
		 
		var tipo =get_bicoito('tipo_pesquisar');

		$('#tipo_busca').html('Busca Rápida');
	}
	else{
		var tipo ='simples';
		
		 $('#tipo_busca').html('Busca Rápida');
	}
	$.ajax({

      
            type: 'GET',

        
            url: 'pesquisa_rapida_avancada.php' ,

      
            data: { tipo_busca : tipo },

               beforeSend: function(){
               
                $('#busca').show();
                $('#busca').html("Carregando...");
            },
            success: function(txt){
                $('#busca').html(txt);
				if(get_bicoito('vetor') != 0 && get_bicoito('vetor') != null){
					titulo_troca();
					
				}
				animatedcollapse.addDiv("pesquisa", 'fade=1')
				animatedcollapse.ontoggle=function($, divobj, state){ }
				animatedcollapse.init();
				
				if(tipo == 'simples'){
					if(get_bicoito('pesquisa')!= null){
						document.getElementById('div_sobre').style.display = "block"; 
						$("iframe").src("carosel.php?"+get_bicoito('pesquisa'), function(duration) {
								document.getElementById('div_sobre').style.display = "none";
							}
						);
				
					}else{
						document.getElementById('div_sobre').style.display = "block"; 
						$("iframe").src("carosel.php?teste=0", function(duration) {
								document.getElementById('div_sobre').style.display = "none";
							}
						);
					}
				}
				
				if(tipo == 'avancada'){	
					seta_cookie();
					pesquisar_avancada();
					
			
		 $('#tipo_busca').html('Busca Avançada');
				}
				
				 if(get_bicoito('titulo_pagina')!= null){
					 if(get_bicoito('local_pagina') == "2"){
							detalhes(get_bicoito('imovel_select'),1);
					 }else{
						  conteudo_principal(get_bicoito('titulo_pagina'),get_bicoito('local_pagina'),1);
					 }
					if(get_bicoito('pesquisa_bt_1')!= null && tipo == 'simples'){		
						document.getElementById(get_bicoito('pesquisa_bt_1')).src = get_bicoito('pesquisa_bt_2');
						//alert('a');
					}
				 }
				 if(get_bicoito('pesquisa_imovel') == "aberto"){
					 document.getElementById('pesquisa').style.display = "block";
						document.getElementById('pesquisa_abre_fecha_img').src = "imagens/pesquisa_menos.png";
					
				 }
				 else{
					   document.getElementById('pesquisa_abre_fecha_img').src = "imagens/pesquisa_mais.png";
				 
				 }
				  if(get_bicoito('titulo_pagina') == null || get_bicoito('titulo_pagina') == "Inicial"){
						document.getElementById('pesquisa_abre_fecha_img').style.display = "none";
					
				 }
				 else{
						document.getElementById('pesquisa_abre_fecha_img').style.display = "block";
				 }
            },

            error: function(txt){
                $('#busca').html('Por favor tente novamente!');
            }
        })
	 	
}

function pesquisa_imovel(){
	 if(document.getElementById('pesquisa').style.display == "none"){
			document.getElementById('pesquisa_abre_fecha_img').src = "imagens/pesquisa_menos.png";
		
	 }
	 else{
		   document.getElementById('pesquisa_abre_fecha_img').src = "imagens/pesquisa_mais.png";
	 
	 }
	if(document.getElementById('tamanho_div').style.height == ''){ 
			
		 if(get_bicoito('pesquisa_imovel') == null){
			set_bicoito('pesquisa_imovel', 'aberto');
		 }
		 else{
			if(get_bicoito('pesquisa_imovel') == "aberto"){
				set_bicoito('pesquisa_imovel', 'fechado');
			}
			else{
				set_bicoito('pesquisa_imovel', 'aberto');
			}
		 }
		animatedcollapse.toggle('pesquisa');
		
	}
}

	
	function ancora(tipo){
		valor = parseInt(document.getElementById("ancora_posicao").value);
		if(tipo == "cima"){
			if(valor > 1){
				valor = valor - 1;	
			}
		}
		if(tipo == "baixo"){
			if(valor < 4){
				valor = valor + 1;
			}
		}
		//alert('c');
		bookmarkscroll.scrollTo('ancora_'+valor);
		document.getElementById("ancora_posicao").value = valor;
	}
	
		//master te liga
	function aciona_data(){
			$(function(){
				$('#data_te_liga').datepicker({
					changeMonth: true,
					dateFormat: 'dd/mm/yy',
					dayNames: [
						'Domingo','Segunda','Terça','Quarta','Quinta','Sexta','Sábado','Domingo'
					],
					dayNamesMin: [
						'D','S','T','Q','Q','S','S','D'
					],
					dayNamesShort: [
						'Dom','Seg','Ter','Qua','Qui','Sex','Sáb','Dom'
					],
					monthNames: [
						'Janeiro','Fevereiro','Março','Abril','Maio','Junho','Julho','Agosto','Setembro',
						'Outubro','Novembro','Dezembro'
					],
					monthNamesShort: [
						'Jan','Fev','Mar','Abr','Mai','Jun','Jul','Ago','Set',
						'Out','Nov','Dez'
					],
					nextText: 'Próximo',
					prevText: 'Anterior'
					
				});
			});
		}
	
	
function voltar_avancar(modulo,titulo,codigo){
			if(get_bicoito('voltar') != null){

			var aux ="";
			aux= get_bicoito('voltar');
			
			}
	
	document.getElementById('volta_1').style.display = "block";
	document.getElementById('volta_2').style.display = "none";

	var string = "";
	if(codigo == ""){ codigo = "-";}
	
		if(get_bicoito('voltar') == null){
			var aux ="";
			if(modulo == 0){
				string = 0+":"+modulo+":"+titulo+":"+codigo+"|"
			}else{
				string = 0+":0:Inicial:0|" + 1+":"+modulo+":"+titulo+":"+codigo+"|"
			}
			
			  set_bicoito('voltar', string);	
			  set_bicoito('vetor',1);	
		}
		else{
				
				
				var posicao =  parseInt(get_bicoito('vetor'));
				var tmp = get_bicoito('voltar').split('|');
				
				var nodo = tmp[tmp.length-2];
				var posicao_interna = parseInt(nodo[0]);
				if((posicao_interna+1) == (posicao+1)){				
					if(tmp[tmp.length-2] != posicao+":"+modulo+":"+titulo+":"+codigo){
						posicao = posicao + 1;
						string = posicao+":"+modulo+":"+titulo+":"+codigo+"|";					
						set_bicoito('voltar', string);
						set_bicoito('vetor',posicao);
					}
				}
				else{
					var tmp = get_bicoito('voltar').split('|');
				  	string = "";
					for(i = 0; i < tmp.length; i++){
						nodo = tmp[i];
						posicao_interna = parseInt(nodo[0]);
						if(posicao_interna <= posicao){
							string += tmp[i]+"|";
						}	 
					}
					string = string+(posicao+1)+":"+modulo+":"+titulo+":"+codigo+"|";
					set_bicoito('voltar', string);
					set_bicoito('vetor',(posicao+1));
					document.getElementById('avanca_1').style.display = "none";
					document.getElementById('avanca_2').style.display = "block";
					
				}
		}	
		

	  if(get_bicoito('voltar') != null )
			set_bicoito('voltar', aux+get_bicoito('voltar'));
		titulo_troca()
//titul2o();	
}

function volta_pagina(){
	local = parseInt(get_bicoito('vetor'));
	
	if((local - 1) > 0){
		document.getElementById('volta_1').style.display = "block";
		document.getElementById('volta_2').style.display = "none";
		document.getElementById('avanca_1').style.display = "block";
		document.getElementById('avanca_2').style.display = "none";
	
	}else{
		document.getElementById('volta_1').style.display = "none";
		document.getElementById('volta_2').style.display = "block";
		document.getElementById('avanca_1').style.display = "block";
		document.getElementById('avanca_2').style.display = "none";
	}
	
	if(local > 0){
		local = local-1;
		set_bicoito('vetor',local)
	}
	vai = get_bicoito('voltar').split("|");
	for(i = 0; i < vai.length; i++){
		nodo = vai[i].split(':');
		posicao_interna = parseInt(nodo[0]);
		if(posicao_interna == local){
			break
		}	 
	}
	if(parseInt(nodo[1]) != 2){
		if(parseInt(nodo[1]) == 0){
				inicia_inicial();
		}
		else{
			conteudo_principal(nodo[2],nodo[1],0,1);
		}

	}else{
		detalhes(nodo[3], 1, 1);
	}
	titulo_troca();
}

function troca_pagina (modulo,link_p){
	
	if(modulo == '2')
		location=link_p;
		//alert(link_p)
	if(modulo == '0')
		location='index.html';
	if(modulo == '4')
		location='imobiliarias_passo_fundo_master_imoveis_historico.html';
	if(modulo == '5')
		location='imobiliarias_passo_fundo_master_imoveis_localizacao.html';
	if(modulo == '6')
		location='imobiliarias_passo_fundo_master_imoveis_diretores.html';
	if(modulo == '7')
		location='imobiliarias_passo_fundo_master_imoveis_fotografias.html';
	if(modulo == '8')
		location='imobiliarias_passo_fundo_master_imoveis_premiacoes.html';
	if(modulo == '9')
		location='imobiliarias_passo_fundo_master_imoveis_depoimentos.html';
		
		
		
	if(modulo == '10')
		location='imobiliarias_passo_fundo_master_imoveis_locacao_vantagens.html';
	if(modulo == '11')
		location='imobiliarias_passo_fundo_master_imoveis_locacao_documentos_necessarios.html';
	if(modulo == '30')
		location='imobiliarias_passo_fundo_master_imoveis_locacao_garantias_locaticias.html';
	if(modulo == '12')
		location='imobiliarias_passo_fundo_master_imoveis_locacao_duvidas_sugestoes.html';
	
	
	
			
		
		
	if(modulo == '13')
		location='imobiliarias_passo_fundo_master_imoveis_vendas_vantagens.html';
	if(modulo == '14')
		location='imobiliarias_passo_fundo_master_imoveis_vendas_documentos_necessarios.html';
	if(modulo == '15')
		location='imobiliarias_passo_fundo_master_imoveis_vendas_duvidas_sugestoes.html';
	if(modulo == '16')
		location='imobiliarias_passo_fundo_master_imoveis_vendas_autorizacao.html';
	
	if(modulo == '23')
		location='imobiliarias_passo_fundo_master_imoveis_lancamentos_imobiliarios.html';
	
	
	if(modulo == '17')
		location='imobiliarias_passo_fundo_master_imoveis_condominios.html';
		
	if(modulo == '19')
		location='sua_ideia_vale_$$$.html';
			
	if(modulo == '21')
		location='imobiliarias_passo_fundo_master_imoveis_venda_seu_imovel.html';
			
	if(modulo == '18')
		location='imobiliarias_passo_fundo_master_imoveis_despachante_imobiliario.html';
			
	if(modulo == '20')
		location='imobiliarias_passo_fundo_master_imoveis_encomende_seu_imovel.html';
		
			
	if(modulo == '80')
		location='contato_master_sucesso.html';
		
}
function avanca_pagina(){
	local = parseInt(get_bicoito('vetor'));
	local_2 = parseInt(get_bicoito('voltar').split('|').length) - 2;
	
	if(local < (local_2 - 1)){		
		document.getElementById('volta_1').style.display = "block";
		document.getElementById('volta_2').style.display = "none";
		document.getElementById('avanca_1').style.display = "block";
		document.getElementById('avanca_2').style.display = "none";
	}else{
		document.getElementById('volta_1').style.display = "block";
		document.getElementById('volta_2').style.display = "none";
		document.getElementById('avanca_1').style.display = "none";
		document.getElementById('avanca_2').style.display = "block";
	}
	
	if(local < local_2){
		local = local+1;
		set_bicoito('vetor',local);		
	}
	
	vai = get_bicoito('voltar').split("|");
	for(i = 0; i < vai.length; i++){
		nodo = vai[i].split(':');
		posicao_interna = parseInt(nodo[0]);
		if(posicao_interna == local){
			break
		}	 
	}
	if(parseInt(nodo[1]) != 2){
		if(parseInt(nodo[1]) == 0){
				inicia_inicial();
		}
		else{
			
			conteudo_principal(nodo[2],nodo[1],0,1);
		}

	}else{
		detalhes(nodo[3], 1, 1);
	}
	titulo_troca();	

}
	function local_inicio(){
		h = (getHeight() - 102)/2
		w = getWidth() - (37 * 2);
	
		document.getElementById('move_pagina').style.top = h-70+"px";
		document.getElementById('move_pagina').style.right = 35+"px";
		
		
		h = (getHeight() - 51)/2
	
		document.getElementById('move_pagina_2').style.top = h-70+"px";
		
		if(parseInt(get_bicoito('vetor')) == 0 || get_bicoito('vetor') == null){
			document.getElementById('volta_1').style.display = "none";
			document.getElementById('volta_2').style.display = "block";
			document.getElementById('avanca_1').style.display = "none";
			document.getElementById('avanca_2').style.display = "block";
		}
		else{
			document.getElementById('volta_1').style.display = "block";
			document.getElementById('volta_2').style.display = "none";
			document.getElementById('avanca_1').style.display = "none";
			document.getElementById('avanca_2').style.display = "block";
			$('volta_1').attr({title:"Voltar para"});
			$('avanca_1').attr({title:"Ir para"});
		}
	}

					function titulo_troca(){
														
									local = parseInt(get_bicoito('vetor'));
									vai = get_bicoito('voltar').split("|");
										for(i = 0; i < vai.length; i++){
											nodo = vai[i].split(':');
											posicao_interna = parseInt(nodo[0]);
											if(posicao_interna == (local-1)){
												$('#volta_1').attr({title:"Voltar para<br>"+nodo[2]});
												
											}
											if(posicao_interna == (local+1)){
												$('#avanca_1').attr({title:"Ir para para<br>"+nodo[2]});
											
											} 
										}
									$('#volta_1,#avanca_1').tooltip({
										track: true,
										delay: 100,
										showURL: false,
										fixPNG: true,
										showBody: " - ",
										extraClass: "pretty fancy",
										top: 5,
										left: -5
									});
								}

