// JavaScript Document
//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 carrega(id,url,mc){
    //Carregando...
	document.getElementById(id).innerHTML = '<div class="avisoCarregando">Aguarde! carregando...</div>'
    //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)
}

function _carrega(id,url,mc){
	//Exibe o texto carregando no div conteúdo
    document.getElementById(id).innerHTML=mc
    //Abre a url
    xmlhttp2.open("GET", url,true);
	xmlhttp2.setRequestHeader('Content-Type','application/x-www-form-urlencoded');
	//Executada quando o navegador obtiver o código
	xmlhttp2.onreadystatechange=function() {
        if (xmlhttp2.readyState==4){
            var texto=xmlhttp2.responseText;
            texto=texto.replace(/\+/g," ");
            texto=unescape(texto);
            var conteudo=document.getElementById(id);
			if(texto.length != 0) conteudo.innerHTML=texto;
		}
	}
    xmlhttp2.send(null);
}