var browser;
var ficha;
var empreendimento;

var Cid = "";
var Tp = "";
var Bairro = "";
var Dorm= "";
var Vlr="";
var Bai = "";
var Lista = "";
var Ordem = "";
var Func="";


function ajaxFunction(elemento,pagina) {
elemento.style.visibility = 'visible';
elemento.innerHTML = '<img src="loading.gif">';
var xmlhttp;
if (window.XMLHttpRequest){// code for IE7+, Firefox, Chrome, Opera, Safari
	xmlhttp=new XMLHttpRequest();
	}
	else 
	if (window.ActiveXObject){ // code for IE6, IE5
		xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
		}
		else{
			alert("Your browser does not support XMLHTTP!");
			}
xmlhttp.onreadystatechange=function(){
									if (xmlhttp.readyState==4){
										elemento.innerHTML = xmlhttp.responseText;
										}
									}
xmlhttp.open("GET",pagina,true);
xmlhttp.send(null);
}


function trocaEmpreend(idx,foto,qtd) {
i=1;
for(i=1;i<=qtd;i++)
   document.getElementById('botaoEmpreend'+i).className = 'slideBotaoInativo';
   
document.getElementById('slideFoto').innerHTML = "<img src='flashEmpreend.php?id="+foto+"'/>";
document.getElementById('botaoEmpreend'+idx).className = 'slideBotaoAtivo';
}
function saibotao(num){

if(num==1){
	if(!((document.getElementById('tab2').className=='tab2')&&(document.getElementById('tab3').className=='tab3')))
	document.getElementById('tab1').className = 'tab1';		
}
if(num==2){
	if(!((document.getElementById('tab1').className=='tab1')&&(document.getElementById('tab3').className=='tab3')))
	document.getElementById('tab2').className = 'tab2';		
}
if(num==3){
	if(!((document.getElementById('tab2').className=='tab2')&&(document.getElementById('tab1').className=='tab1')))
	document.getElementById('tab3').className = 'tab3';		
}

}
function trocabotao(num) {
	
document.getElementById('tab1').className = 'tab1';
document.getElementById('tab2').className = 'tab2';
document.getElementById('tab3').className = 'tab3';

if(num==1){
	document.getElementById('tab1').className = 'tab1Hover';
	ajaxFunction(document.getElementById('btn_tabs'),					'conteudo.php?tab1=tab1Hover&tab2=tab2&tab3=tab3');
}
if(num==2){
	document.getElementById('tab2').className = 'tab2Hover';
ajaxFunction(document.getElementById('btn_tabs'),'conteudo.php?tab1=tab1&tab2=tab2Hover&tab3=tab3');
}if(num==3){
	document.getElementById('tab3').className = 'tab3Hover';
ajaxFunction(document.getElementById('btn_tabs'),'conteudo.php?tab1=tab1&tab2=tab2&tab3=tab3Hover');
}}

function imovelDestaquePagina(pag,transacao) {

ajaxFunction(document.getElementById('centro'),'conteudo.php?pagina='+pag+'&transacao='+transacao);

}

function imovelTrocaFoto(cod) {
	
ajaxFunction(document.getElementById('d_foto'),'detalhe_foto_principal.php?cod='+cod);
}

function minhaLista(ficha){
	ajaxFunction(document.getElementById('ml'),'gravasessaobrowser.php?nalista='+ficha);
	alert('Imovel ficha: '+ficha+' adicionado a lista');
}

function buscaurl(num) {
	
	if (document.getElementById('ficha').value != '')
		ficha='&ficha='+(document.getElementById('ficha').value);
		else
		ficha='';
	
	if (document.getElementById('cidade').value != 0) 
		Cid='&cidade='+(document.getElementById('cidade').value);
		else
		Cid='';
		
		
		Func='&transacao='+(document.getElementById('transacao').value);
		
			
	if (document.getElementById('bairros').value != '')
		Bairro='&bairro='+(document.getElementById('bairros').value);
		else
		Bairro='';
	if (document.getElementById('dorms').value != 'sem') 
		Dorm='&dorm='+(document.getElementById('dorms').value);
		else
		Dorm='';
	if (document.getElementById('tipo').value != 0) 
		Tp='&tipo='+(document.getElementById('tipo').value);
		else
		filtroTp='';
	if (document.getElementById('valor').value != 'sem')
		Vlr='&vlr='+(document.getElementById('valor').value);
		else
		Vlr='';
	
	Lista = Func+ficha+Tp+Dorm+Cid+Bairro+Vlr;
	
	if(num==1)
		ajaxFunction(document.getElementById('imovel_sel_base'),'conteudo_miolo_sel.php?'+Lista);
	if(num==2)
	
		ajaxFunction(document.getElementById('site'),'index_sel.php?'+Lista);
	if(num==3)
	ajaxFunction(document.getElementById('site'),'lista.php?lista=lista');
	if(num==4)
	ajaxFunction(document.getElementById('d_ampla'),'index_sel.php?'+Lista);
	
	if(num==5){
		window.location.href="index_sel.php?"+Lista;
	}
}
function voltar(){
	
window.history.go(-1);	
}
function abreLista(lista){
	
	if(lista==null){
		alert("Sua lista est? vazia");
	}else{
		window.location.href="lista.php";
	}
		
}
function abre_edital(div,desc){
	
ajaxFunction(document.getElementById(div),'editais_div.php?descricao='+desc);	
}
function trocaPagina(pag,busca){
	
	ajaxFunction(document.getElementById('imovel_sel_base'),'conteudo_miolo_sel.php?pagina='+pag+'&busca='+busca);
}

function abrePopup(id){
	 document.getElementById(id).style.display="block";

}
function fechaPopup(id){
	 document.getElementById(id).style.display="none";

}// JavaScript Document
