 //controla a fila de carregamento das solicitações
//Tenta criar o objeto xmlHTTP
try{
    xmlhttp = new XMLHttpRequest();
}catch(ee){
    try{
        xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
    }catch(e){
        try{
            xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
        }catch(E){
            xmlhttp = false;
        }
    }
}

//Fila de conexões
fila=[]
ifila=0

//Carrega via XMLHTTP a url recebida e coloca seu valor
//no objeto com o id recebido

function ajaxHTML(id,url){//sem o carregando
    //Carregando...
    document.getElementById(id).innerHTML="&nbsp;"
    //Adiciona à fila
    fila[fila.length]=[id,url]
    //Se não há conexões pendentes, executa
    if((ifila+1)==fila.length)ajaxRun()
}
function ajaxHTMLBlank(id,url){//sem o carregando
    //Carregando...
    //document.getElementById(id).innerHTML="&nbsp;"
    //Adiciona à fila
    fila[fila.length]=[id,url]
    //Se não há conexões pendentes, executa
    if((ifila+1)==fila.length)ajaxRun()
}
function ajaxHTMLon(id,url){//sem o carregando
    //Carregando...
    document.getElementById(id).innerHTML="carregando..."
    //Adiciona à fila
    fila[fila.length]=[id,url]
    //Se não há conexões pendentes, executa
    if((ifila+1)==fila.length)ajaxRun()
}

//Executa a próxima conexão da fila
function ajaxRun(){
    //Abre a conexão
    xmlhttp.open("GET",fila[ifila][1],true);
    //Função para tratamento do retorno
    xmlhttp.onreadystatechange=function() {
        if (xmlhttp.readyState==4){
            //Mostra o HTML recebido
            retorno=unescape(xmlhttp.responseText.replace(/\+/g," "))
            document.getElementById(fila[ifila][0]).innerHTML=retorno
            //Roda o próximo
            ifila++
            if(ifila<fila.length)setTimeout("ajaxRun()",20)
        }
    }
    //Executa
    xmlhttp.send(null)
}

//fim do controle de carregamento




function MM_openBrWindow(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);
}








function menuVai(itemMenu){
var isInternetExplorer = navigator.appName.indexOf("Microsoft") != -1;
switch (itemMenu) {
    case 'empresa':
       valor = 20;
       break
    case 'locacoes':
       valor = 80;
       break
    case 'vendas':
        valor = 132;
       break
	 case 'condominios':
        valor = 195;
       break
	   case 'clienteonline':
        valor = 20;
       break
	 case 'contato':
        valor = 268;
       break
	  default:
   		valor = 20;
} 



if(isInternetExplorer){
	window.document.menuAponta.SetVariable('local',valor);
	 }else{
		//document.getElementById("menuAponta").SetVariable("local",valor);  
	}



}

//VENDAS
function buscaCategorias(codCidade){
	ajaxHTML('divCategorias','index.php?secao=divCategoria&cidade='+codCidade);
	ajaxHTML('divBairros','index.php?secao=divBairroVenda&cidade='+codCidade);
	
	}




//LOCACAO
function buscaBairros(codCidade){
	ajaxHTML('divBairros','index.php?secao=divBairros&cidade='+codCidade);
	
	}
function buscaBairrosAvan(codCidade){
	ajaxHTMLon('divBairrosAvan','index.php?secao=divBairrosAvan&cidade='+codCidade);
	
	}
function buscaTipo(codOcu){
	ajaxHTML('divTipoImovel','index.php?secao=divTipoImovel&ocupacao='+codOcu);
	
	
	}
function buscaTipoAvan(codOcu){
	ajaxHTML('divTipoImovelAvan','index.php?secao=divTipoImovelAdv&ocupacao='+codOcu);
	//document.getElementById('qtDormitorios').disabled = true;
	
	}
	
function buscaVendaAvan(cidade){
	ajaxHTML('divCategoriaAdv','index.php?secao=divCategoriaAdv&cidade='+cidade);
	ajaxHTML('divBairroVendaAdv','index.php?secao=divBairroVendaAdv&cidade='+cidade);
	
	}	

function MarcaTodos(){ 
   for (i=0;i<document.formBuscaAvan.elements.length;i++) 
      if(document.formBuscaAvan.elements[i].type == "checkbox"){
	 if(document.formBuscaAvan.elements[i].id == 'bairro')
         document.formBuscaAvan.elements[i].checked=1 ;
		
}
}
function DesmarcaTodos(){ 
   for (i=0;i<document.formBuscaAvan.elements.length;i++) 
      if(document.formBuscaAvan.elements[i].type == "checkbox"){
	 	if(document.formBuscaAvan.elements[i].id == 'bairro')
         document.formBuscaAvan.elements[i].checked=0 ;
		 
	  }
		 
}
function MarcaTodosCat(){ 
   for (i=0;i<document.formBuscaAvan.elements.length;i++) 
      if(document.formBuscaAvan.elements[i].type == "checkbox"){
	 if(document.formBuscaAvan.elements[i].id == 'categoria')
         document.formBuscaAvan.elements[i].checked=1 ;
		
}
}
function DesmarcaTodosCat(){ 
   for (i=0;i<document.formBuscaAvan.elements.length;i++) 
      if(document.formBuscaAvan.elements[i].type == "checkbox"){
	 	if(document.formBuscaAvan.elements[i].id == 'categoria')
         document.formBuscaAvan.elements[i].checked=0 ;
		 
	  }
		 
}


function MarcaTodosTipo(){ 
   for (i=0;i<document.formBuscaAvan.elements.length;i++) 
      if(document.formBuscaAvan.elements[i].type == "checkbox"){
	 if(document.formBuscaAvan.elements[i].id == 'tipoImovel')
         document.formBuscaAvan.elements[i].checked=1 ;
		
}
}
function DesmarcaTodosTipo(){ 
   for (i=0;i<document.formBuscaAvan.elements.length;i++) 
      if(document.formBuscaAvan.elements[i].type == "checkbox"){
	 	if(document.formBuscaAvan.elements[i].id == 'tipoImovel')
         document.formBuscaAvan.elements[i].checked=0 ;
		 
	  }
		 
}


function CarregaServicos(login,senha){
	
	ajaxHTMLon('divServicos','clienteonline/prg/crLogin.php?LOGIN='+login+'&SENHA='+senha);
	
	}

function Dicas(id){
	var id;
	ajaxHTMLon('dicas_'+id,'index.php?secao=carregadica&id_duvida='+id);
	
	}
	
function enviaViaEmail(id){
	var id;
	ajaxHTML('divEmail','templates/emailPop.htm');
	
	}

function enviaEmailPop(){
	
	ajaxHTML('divEmail','acao.php?secao=popEmail&emailnome='+document.getElementById('emailnome').value+'&emailemail='+document.getElementById('emailemail').value+'&emailquem='+document.getElementById('emailquem').value+'&nomequem='+document.getElementById('nomequem').value+'&tipo='+document.getElementById('emailtipo').value+'&id='+document.getElementById('emailid').value);
	
	ajaxHTML('divEmail','templates/emailPopOk.htm');
	}
	
function loginPop(id){
	var id;
	ajaxHTML('divLoginPop','templates/loginPop.htm');
	
	}
function Limpa(id){
	var id;
	ajaxHTMLBlank(id,'templates/blank.htm');
	
	}
function buscaPersonalizada(){
	
	ajaxHTML('divBuscaPersonalizada','templates/popBuscaPersonalizada.htm');
	
	}

function enviaBuscaPersonalizada(){
	ajaxHTML('divBuscaPersonalizada','acao.php?secao=popBuscaPersonalizada&buscanome='+document.getElementById('buscanome').value+'&buscaemail='+document.getElementById('buscaemail').value+'&buscatelefone='+document.getElementById('buscatelefone').value+'&buscamensagem='+document.getElementById('buscamensagem').value);
	
	
	ajaxHTML('divBuscaPersonalizada','templates/popBuscaPersonalizadaOk.htm');
	
	}

function AbrePop(){
	
		window.open('','popCompara','scrollbars=yes,resizable=yes,width=750,height=650');
	}
	
<!-- Início da Funçao FormataReais -->

function FormataReais(fld, milSep, decSep, e) {

var sep = 0;

var key = '';

var i = j = 0;

var len = len2 = 0;

var strCheck = '0123456789';

var aux = aux2 = '';

var whichCode = (window.Event) ? e.which : e.keyCode;

if (whichCode == 13) return true;

key = String.fromCharCode(whichCode);// Valor para o código da Chave

if (strCheck.indexOf(key) == -1) return false; // Chave inválida

len = fld.value.length;

for(i = 0; i < len; i++)

if ((fld.value.charAt(i) != '0') && (fld.value.charAt(i) != decSep)) break;

aux = '';

for(; i < len; i++)

if (strCheck.indexOf(fld.value.charAt(i))!=-1) aux += fld.value.charAt(i);

aux += key;

len = aux.length;

if (len == 0) fld.value = '';

if (len == 1) fld.value = '0'+ decSep + '0' + aux;

if (len == 2) fld.value = '0'+ decSep + aux;

if (len > 2) {

aux2 = '';

for (j = 0, i = len - 3; i >= 0; i--) {

if (j == 3) {

aux2 += milSep;

j = 0;

}

aux2 += aux.charAt(i);

j++;

}

fld.value = '';

len2 = aux2.length;

for (i = len2 - 1; i >= 0; i--)

fld.value += aux2.charAt(i);

fld.value += decSep + aux.substr(len - 2, len);

}

return false;

}

function txtBoxFormat(objForm, strField, sMask, evtKeyPress) {
var i, nCount, sValue, fldLen, mskLen,bolMask, sCod, nTecla;

if(document.all) { // Internet Explorer
nTecla = evtKeyPress.keyCode; }
else if(document.layers) { // Nestcape
nTecla = evtKeyPress.which;
} else if(document.getElementById) { // FireFox
nTecla = evtKeyPress.which;
}

sValue = objForm[strField].value;

// Limpa todos os caracteres de formataçao que
// já estiverem no campo.
sValue = sValue.toString().replace( "-", "" );
sValue = sValue.toString().replace( "-", "" );
sValue = sValue.toString().replace( ".", "" );
sValue = sValue.toString().replace( ".", "" );
sValue = sValue.toString().replace( "/", "" );
sValue = sValue.toString().replace( "/", "" );
sValue = sValue.toString().replace( "(", "" );
sValue = sValue.toString().replace( "(", "" );
sValue = sValue.toString().replace( ")", "" );
sValue = sValue.toString().replace( ")", "" );
sValue = sValue.toString().replace( " ", "" );
sValue = sValue.toString().replace( " ", "" );
fldLen = sValue.length;
mskLen = sMask.length;

i = 0;
nCount = 0;
sCod = "";
mskLen = fldLen;

while (i <= mskLen) {
bolMask = ((sMask.charAt(i) == "-") || (sMask.charAt(i) == ".") || (sMask.charAt(i) == "/"))
bolMask = bolMask || ((sMask.charAt(i) == "(") || (sMask.charAt(i) == ")") || (sMask.charAt(i) == " "))

if (bolMask) {
sCod += sMask.charAt(i);
mskLen++; }
else {
sCod += sValue.charAt(nCount);
nCount++;
}

i++;
}

objForm[strField].value = sCod;

if (nTecla != 8) { // backspace
if (sMask.charAt(i-1) == "9") { // apenas números...
return ((nTecla > 47) && (nTecla < 58)); } // números de 0 a 9
else { // qualquer caracter...
return true;
} }
else {
return true;
}
}


function Seleciona(id){
	var id;
	
	document.getElementById(id).style.background = '#8D882E';
	document.getElementById(id).style.color = '#FFFFFF';
	
	}
function DesSeleciona(id){
	var id;
	
	document.getElementById(id).style.background = '#F1F1F1';
	document.getElementById(id).style.color = '#006699';
	}

function abrePesquisa(){
	MM_openBrWindow('index.php?secao=pesquisaSatisfacao','','scrollbars=yes,resizable=no,width=690,height=500')
	
	}
function banner(){
	MM_openBrWindow('topSer.htm','','scrollbars=no,resizable=no,width=782,height=529')
	
	}
function atendimentoOnline(){
	window.open('index.php?secao=opcao', 'atendimento' , 'height = 480 , width = 550, status=yes');
	
	}
