function createXMLHttpRequest() {
   try{ return new ActiveXObject("Msxml2.XMLHTTP"); }catch(e){}
   try{ return new ActiveXObject("Microsoft.XMLHTTP"); }catch(e){}
   try{ return new XMLHttpRequest(); }catch(e){}
   alert("XMLHttpRequest not supported");
   return null;
}


var xhReq = createXMLHttpRequest();

function geraJS(texto){
        
          var ini = 0;
          while (ini!=-1){
              ini = texto.indexOf('<script', ini);
              if (ini >=0){
                  ini = texto.indexOf('>', ini) + 1;
                  var fim = texto.indexOf('</script>', ini);
                  codigo = texto.substring(ini,fim);
                  eval(codigo);
              }
          }
 }

          function ajax(url,div){
               var div = document.getElementById(div);
               div.innerHTML = "<img src='ajax/espera.gif'>&nbsp;&nbsp;<font color=black size=2px>Carregando...</font>"; 

               xhReq.open("GET",url,true);
               
               xhReq.onreadystatechange=function() {
                    if(xhReq.readyState == 4) {
                         div.innerHTML = xhReq.responseText ;
                         geraJS(xhReq.responseText);
                    }
               }
               xhReq.send(null);
          }
