function getHTTPObject()
{
  var xmlhttp;

    try
    {
      xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
    }
    catch (e)
    {
          try
          {
                xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
          }
          catch (e)
          {
                try
                {
                    xmlhttp = new XMLHttpRequest();
                }
                catch (e)
                {
                    xmlhttp = false;
                }
          }
    }
  return xmlhttp;
}
var http = getHTTPObject();

function handleHttpResponseDiv()
{
  var elem = document.getElementById(id_div);
  elem.style.display = "block";
  elem.innerHTML = "<b>Carregando...</b>";
  if (http.readyState == 4)
 {
      resposta = http.responseText;
      elem.innerHTML = resposta;
			//eval(extraiScript(resposta));
			/**********************
       Segundo Micox - micoxjcg@yahoo.com.br,
       o eval não executa funções.
      ***********************/
			novo = document.createElement("script")
      novo.text = extraiScript(resposta);
			elem.appendChild(novo);
  }
}

function extraiScript(texto){
//Maravilhosa função feita pelo SkyWalker.TO do imasters/forum
     // inicializa o inicio
     var ini = 0;
     // loop enquanto achar um script
     while (ini!=-1){
         // procura uma tag de script
         ini = texto.indexOf('<script', ini);
         // se encontrar
         if (ini >=0){
             // define o inicio para depois do fechamento dessa tag
             ini = texto.indexOf('>', ini) + 1;
             // procura o final do script
             var fim = texto.indexOf('</script>', ini);
             // extrai apenas o script
             codigo = texto.substring(ini,fim);
             // executa o script
						 return codigo;
         }
     }
}

function filldiv(url,id)
{
 		id_div= id;
    http.open("GET", url, true);
    http.onreadystatechange = handleHttpResponseDiv;
    http.send(null);
}

