function ajaxHTML(id, url)
{

  var xmlhttp=false;
  
  /*@cc_on @*/
  /*@if (@_jscript_version >= 5)
  // JScript gives us Conditional compilation, we can cope with old IE versions.
  // and security blocked creation of the objects.
   try {
    xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
   } catch (e) {
    try {
     xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
    } catch (E) {
     xmlhttp = false;
    }
   }
  @end @*/
  if (!xmlhttp && typeof XMLHttpRequest!='undefined') 
  {
    xmlhttp = new XMLHttpRequest();
  }

  //Obtém o objeto HTML
  objetoHTML=document.getElementById(id);

  //Exibe 'Carregando...'
  objetoHTML.innerHTML='<img src="/wp-content/themes/almost-spring/images/carregando.gif">';
//  objetoHTML.innerHTML='Carregando...';

  // Abre a conexão
  xmlhttp.open('GET', url);

  //
  xmlhttp.onreadystatechange = function()
  {
    if (xmlhttp.readyState==4)
    {
       //Mostra o HTML recebido
       retorno=unescape(xmlhttp.responseText.replace(/\+/g,' '));
       objetoHTML.innerHTML = retorno;
    }
  };

  //Executa
  xmlhttp.send(null);

}

function ajaxPOSTEvent(id, url, poststring, evento)
{
  try
  {
    var xmlhttp=false;

    /*@cc_on @*/
    /*@if (@_jscript_version >= 5)
    // JScript gives us Conditional compilation, we can cope with old IE versions.
    // and security blocked creation of the objects.
     try 
     {
       xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
     } 
     catch (e) 
     {
       try 
       {
         xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
       } 
       catch (E) 
       {
         xmlhttp = false;
       }
     }
    @end @*/
    
    if (!xmlhttp && typeof XMLHttpRequest!='undefined') 
    {
      xmlhttp = new XMLHttpRequest();
    }

    //Obtém o objeto HTML
    objetoHTML=document.getElementById(id);

    //Exibe 'Carregando...'
    objetoHTML.innerHTML='<img src="/wp-content/themes/almost-spring/images/carregando.gif">';
  //  objetoHTML.innerHTML='Carregando';

    // Gera um número randômico, para evitar cache
    var randomNum = Math.floor ((Math.random() * 10000));

    // Abre a conexão
    xmlhttp.open('POST', url+'?'+randomNum);
    //  xmlhttp.open('GET', url+'?'+poststring);  

    //
    xmlhttp.onreadystatechange= function()
    {
      if (xmlhttp.readyState==4)
      {
         //Mostra o HTML recebido
         retorno=unescape(xmlhttp.responseText.replace(/\+/g,' '));
         objetoHTML.innerHTML = retorno;

         evento();
      }
    };

    // Altera o cabeçalho, para poder usar POST_VARS
    xmlhttp.setRequestHeader('Content-Type','application/x-www-form-urlencoded');

    //Executa
    xmlhttp.send(poststring);

    return true;
  }
  catch(e)
  {
  
    alert('Erro ao enviar');
    
    return false;
  
  }

}

function ajaxHTMLEvent(id, url, evento)
{

  var xmlhttp=false;
  
  /*@cc_on @*/
  /*@if (@_jscript_version >= 5)
  // JScript gives us Conditional compilation, we can cope with old IE versions.
  // and security blocked creation of the objects.
   try {
    xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
   } catch (e) {
    try {
     xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
    } catch (E) {
     xmlhttp = false;
    }
   }
  @end @*/
  if (!xmlhttp && typeof XMLHttpRequest!='undefined') {
    xmlhttp = new XMLHttpRequest();
  }


  //Obtém o objeto HTML
  objetoHTML=document.getElementById(id);

  //Exibe 'Carregando...'
  objetoHTML.innerHTML='<img src="/wp-content/themes/almost-spring/images/carregando.gif">';
//  objetoHTML.innerHTML='Carregando';

  // Abre a conexão
  xmlhttp.open('GET', url);

  //
  xmlhttp.onreadystatechange= function()
  {
    if (xmlhttp.readyState==4)
    {
       //Mostra o HTML recebido
       retorno=unescape(xmlhttp.responseText.replace(/\+/g,' '));
       objetoHTML.innerHTML = retorno;
       
       evento();       
    }
  };

  //Executa
  xmlhttp.send(null);

}


function Form2Html(pObject)
{

  var Form2HtmlAdd = function(pObj)
  {
    Retorno = escape(pObj.name) +'='+ escape(pObj.value) +'&';
    return Retorno;
  }

  var iRetorno='';

  for(var i=0;i<pObject.length;i++)
  { 
    var obj = pObject.elements[i];

    // Fieldsets são objetos de formulário...
    // ...embora não se portem como tal   
    
    if (obj.name != null)
    {
      if (obj.name.length > 0)
      {
        switch(obj.type)
        {
          case 'radio':
          case 'checkbox':
          {
            if (pObject.elements[i].checked)
            {
              iRetorno += Form2HtmlAdd(obj);
            }
            break;
          }
          default:
          {
            // Contempla o restante:
            // select, hidden, password, text, textarea, button, sumits, resets
            //
            iRetorno += Form2HtmlAdd(obj);
          }
        }
      }    
    }
  }
  
  return iRetorno;
}
