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=[];
ifila=0;
function ajaxLoad(url, destino){
if(destino!=Object){ destino = document.getElementById(destino); }
if(destino.nodeName=="SELECT"){
while(destino.options.length>0)destino.options[0]=null;
destino.options[0]=new Option(" -- Aguarde -- "," -- Aguarde -- ");
} else {
destino.innerHTML="<img src='imagens/ajax-loader.gif' title='Atualizando estatisticas'></img>";
}
fila[fila.length]=[url,destino];
if((ifila+1)==fila.length)ajaxRun();
}
function ajaxShow(valor,destino){
if(destino.nodeName=="SELECT"){
while(destino.options.length>0)destino.options[0]=null;
if(valor.charAt(0)=="[" && valor.charAt(valor.length-1)=="]"){
var destinoTmp=eval(valor);
for(var i=0;i<destinoTmp.length;i++){
destinoTmp[i][0]=unescape(destinoTmp[i][0]);
destinoTmp[i][1]=unescape(destinoTmp[i][1]);
destino.options[destino.options.length]=new Option(destinoTmp[i][1],destinoTmp[i][0]);
}
} else {
destino.options[destino.options.length]=new Option(valor,valor);
}
} else {
destino.innerHTML = unescape(valor.replace(/\+/g," "));
}
}
function ajaxRun(){
url = fila[ifila][0];
destino = fila[ifila][1];
xmlhttp.open("GET", url, true);
xmlhttp.setRequestHeader("Content-Type", "application/x-www-form-urlencoded; charset=ISO-8859-1");
xmlhttp.setRequestHeader("Cache-Control", "no-store, no-cache, must-revalidate");
xmlhttp.setRequestHeader("Cache-Control", "post-check=0, pre-check=0");
xmlhttp.setRequestHeader("Pragma", "no-cache");
xmlhttp.onreadystatechange=function() {
if (xmlhttp.readyState==4){
switch(xmlhttp.status){
case 200: { ajaxShow(xmlhttp.responseText,destino); break }
case 204: { ajaxShow("O servidor n&atilde;o respondeu ao chamado",destino); break }
case 400: { ajaxShow("Endere&ccedil;o inv&aacute;lido",destino); break }
case 403: { ajaxShow("Voc&ecirc; n&atilde;o possui permiss&atilde;o para acessar esse arquivo",destino); break }
case 404: { ajaxShow("Arquivo n&atilde;o encontrado",destino); break }
case 500: { ajaxShow("Erro interno do servidor...",destino); break }
case 502: { ajaxShow("Servidor ocupado.",destino); break }
case 503: { ajaxShow("O servidor n&atilde;o respondeu no tempo limite",destino); break }
default: { ajaxShow("Algum erro ocorreu ao carregar este conte&uacute;do...",destino); break }
}
ifila++;
if(ifila<fila.length)setTimeout("ajaxRun()",20);
}
}
xmlhttp.send(url);
}