/*
Autor: Jason Chaves Schmidt - Junho de 2007
*/
function GetXmlHttpObject() {
  var xmlHttp=null;
  try { // Firefox, Opera 8.0+, Safari
    xmlHttp=new XMLHttpRequest();
  }
  catch (e) { // Internet Explorer
    try {
      xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
    }
    catch (e) {
      xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
    }
  }
  return xmlHttp;
}

function executa_ajax(receptaculo_de_retorno, str, proprioid, programa) {
//  if (str.length==0) {
//    document.getElementById(receptaculo_de_retorno).innerHTML="";
//  return;
//  }
  xmlHttp = GetXmlHttpObject();
  if (xmlHttp==null) {
    alert ("Your browser does not support AJAX!");
    return;
  }
  xmlHttp.onreadystatechange = function() {
    if(xmlHttp.readyState==4) {
      resposta = xmlHttp.responseText;
      if (resposta.charAt(0)=="$") {
        document.getElementById(proprioid).value=resposta.substr(1);
        document.getElementById(receptaculo_de_retorno).innerHTML = resposta.substr(1);
      }
      else {
        document.getElementById(receptaculo_de_retorno).innerHTML=resposta;     
      }
    }
  }
  xmlHttp.open("GET",programa+"?str="+str+"&proprio="+proprioid,true);
  xmlHttp.send(null);
}
