function ajaxInit() {
  var req;
  try {req = new ActiveXObject("Microsoft.XMLHTTP");}
  catch(e){
    try {req = new ActiveXObject("Msxml2.XMLHTTP");}
	catch(ex){
      try {req = new XMLHttpRequest();} 
	  catch(exc) {
        alert("Esse browser não tem recursos para uso do Ajax");
        req = null;
      }
    }
  }
  return req;
}

function ajaxURL(spanID,url,pPost,pGet) {
  var usersCountTmpVar = document.getElementById(spanID);
  
  usersCountTmpVar.innerHTML = '<table border="0" align="center" height="100%"><tr><td align="right"><img src="images/loading.gif" width="32" height="32"/></td><td style="font-size:10px; font-family:Verdana, Arial, Helvetica, sans-serif; color:#999999;" valign="middle">Carregando, aguarde...<br /></td></tr></table>';

  
  if(!usersCountTmpVar) {
     alert("Campo não encontrado no documento");
     return; //se ele não encontrar o campo, da um alerta e escapa a funcao 
  }
  var ajaxUC = ajaxInit(); //inicia a variavel ajax para uso e UserCount
  url = url+"?"+pGet;
  ajaxUC.open("POST", url, true);
  ajaxUC.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
  ajaxUC.onreadystatechange = function() { //funcao executada ao trocar de stado
    if(ajaxUC.readyState == 4) { //verifica se o estado atual é "concluido"
       if(ajaxUC.status == 200) { //verifica se o arquivo foi lido corretamente
          usersCountTmpVar.innerHTML = ajaxUC.responseText + " "; //define o texto do span		  
       }
    }
  }  
  if(pPost == "")
    ajaxUC.send(null); //enviar dados somente pelo GET
  else
    ajaxUC.send(pPost); //enviar dados pelo metodo POST
}
