function ajax2() {
   try {
      xmlhttp = new XMLHttpRequest();
   }
   catch(ee) {
      try {
         xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
      }
      catch(e) {
         try {
            xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
         }
         catch(E) {
            xmlhttp = false;
         }
      }
   }
   return xmlhttp;
}



//Fila de conexoes
fila = [];
ifila = 0;

//Carrega via XMLHTTP a url recebida e coloca seu valor
//no objeto com o id recebido
function ajaxHTML(id,url){
    //Carregando...
    mensagem(id);
    
    //Adiciona a fila
    fila[fila.length]=[id,url]
    //Se nao ha conexoes pendentes, executa
    if((ifila+1)==fila.length)ajaxRun(id)
}

//Executa a proxima conexao da fila
function ajaxRun(){
   ajax2();
   
    //Abre a conexao
    xmlhttp.open("GET",fila[ifila][1],true);
    //Funcao 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 proximo
            ifila++
            if(ifila<fila.length)setTimeout("ajaxRun()",20)
        }
    }
    //Executa
    xmlhttp.send(null)
}

function mensagem(id) {
   document.getElementById(id).innerHTML="<img src='img/carregando.gif' alt='' border='0' id='carregando'/>";
}

