
try {
	var xmlhttp = new XMLHttpRequest()
	var xmlhttp2 = new XMLHttpRequest()
} catch(e) {
	try {
		var xmlhttp = new ActiveXObject("Msxml2.XMLHTTP")
		var xmlhttp2 = new ActiveXObject("Msxml2.XMLHTTP")
	} catch(ee) {
		try {
			var xmlhttp = new ActiveXObject("Microsoft.XMLHTTP")
			var xmlhttp2 = new ActiveXObject("Microsoft.XMLHTTP")
		} catch(eee) {
			var xmlhttp = false
			var xmlhttp2 = 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,jogo){
    //Carregando...
    document.getElementById(id).innerHTML='<div style="text-align:center"><p><img src="img/spinner.gif" alt="Aguarde"></p><h3>A G U A R D E</h3></div>'
    //Adiciona à fila
    fila[fila.length]=[id,url,jogo]
    //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
	var dados_post = fila[ifila][2];
    xmlhttp.open("POST",fila[ifila][1],true);
	xmlhttp.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
    //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(dados_post)
}
