   /****************************************************************************/
   // création de l'objet HttpRequest :
   function getHttpObject()
   {
      try
      {
         obj = new ActiveXObject("Msxml12.XMLHTTP");
      }
      catch(e)
      {
         try
         {
            obj = new ActiveXObject("Microsoft.XMLHTTP");
         }
         catch(oc)
         {
            obj = null;
         }
      }
      if(!obj && typeof XMLHttpRequest != "undefined")
      {
         try
         {
            obj = new XMLHttpRequest();
         }
         catch(e)
         {
            obj = null;
         }
      }
      if(!obj)
         alert('votre navigateur ne supporte pas les \'httpRequest\'');
      
      return obj;
   }
   /****************************************************************************/
   function move_javascript(div)
   {
      var div;
      
      if(document.getElementsByTagName)
      {
         // déplacer les scripts de la div vers le body :
         scripts = null;
         scripts = $(div).getElementsByTagName('script');
         
         for(i=0; i<scripts.length; i++)
         {
            var script = document.createElement('script');
            script.setAttribute("language","javascript");
            script.setAttribute('name','xhr');
            script.text = scripts[i].firstChild.nodeValue;
            document.body.appendChild(script);
            if(scripts[i] && scripts[i].parentNode) scripts[i].parentNode.removeChild(scripts[i]);
         }
      }
   }
   /****************************************************************************/
   function xhr_get(div,url)
   {
      var div;
      var url;
      
      var bg_image    = $(div).style.backgroundImage;
      var bg_repeat   = $(div).style.backgroundRepeat;
      var bg_position = $(div).style.backgroundPosition;
      
      $(div).style.backgroundImage    = "url('themes/"+theme+"/images/icones/loading.png')";
      $(div).style.backgroundRepeat   = "no-repeat";
      $(div).style.backgroundPosition = "center";
      
      // requete POST en mode asynchrone :
      var xhr;
      if(xhr = getHttpObject())
      {
         xhr.open('GET',url+'&rnd='+Math.random(),true);
         xhr.onreadystatechange = function()
         { 
            if (xhr.readyState == 4)
            {
               $(div).style.backgroundImage    = '';
               $(div).style.backgroundRepeat   = bg_repeat;
               $(div).style.backgroundPosition = bg_position;
               switch(xhr.status)
               {
                  case 200:
                     $(div).innerHTML = xhr.responseText;
                     move_javascript(div);
                     break;
                     
                  default:
                     alert(xhr.status);
                     break;
               }
            }
            else
            {
               // attendre...
            }
         }
         xhr.send(null);
      }
   }
   /****************************************************************************/
   function xhr_post(div,url)
   {
      var div;
      var url;
      
      var classe;
      var chaine = '';
      var champs = $(div).getElementsByTagName('*');
      var div_result = 'xhr_result';
      
      if($(div+'_submit'))
      {
         classe = $(div+'_submit').getAttribute('class');
         if(div != 'loginForm') $(div+'_submit').setAttribute('class',classe+'_disabled');
      }
      if($(div+'_status')) $(div+'_status').style.display = 'inline';
      
      $(div_result).innerHTML = '';
      for(i=0; i<champs.length; i++)
      {
         if(champs[i].name)
         {
            if((champs[i].type == 'checkbox') && !champs[i].checked) // typeof() ou .type
            {
            }
            else if((champs[i].type == 'radio') && !champs[i].checked)
            {
            }
            else
            {
               chaine += champs[i].name+'='+champs[i].value+'&';
            }
            champs[i].disabled = true;
         }
      }
      //alert(chaine);return;
      
      // réinitialiser les scripts déjà chargés : bout de script à importer depuis la partie 'admin' si besoin...
      
      // requete POST en mode asynchrone :
      var xhr;
      if(xhr = getHttpObject())
      {
         xhr.open('POST',url+'&rnd='+Math.random(),true);
         xhr.onreadystatechange = function()
         { 
            if (xhr.readyState == 4)
            {
               switch(xhr.status)
               {
                  case 200:
                     $(div_result).innerHTML = xhr.responseText;
                     move_javascript(div_result);
                     break;
                     
                  default:
                     alert(xhr.status);
                     break;
               }
               
               if($(div))
               {
                  if($(div+'_submit'))
                  {
                     $(div+'_submit').setAttribute('class',classe);
                     $(div+'_submit').disabled = false;
                  }
                  if($(div+'_status')) $(div+'_status').style.display = 'none';
                  
                  for(i=0; i<champs.length; i++)
                  {
                     champs[i].disabled = false;
                  }
               }
            }
            else
            {
               // attendre...
            }
         }
         xhr.setRequestHeader('Content-Type','application/x-www-form-urlencoded'); // utiliser en POST uniquement
         xhr.setRequestHeader("Content-length", chaine.length);
         xhr.setRequestHeader("Connection", "close");
         xhr.send(chaine);
      }
      
      // requete POST en mode synchrone :
      return;
      var xhr;
      if(xhr = getHttpObject())
      {
         xhr.open('POST','?xhr=comments/add/',false); // '&redirect={aa:lang}/{aa:url}&rnd='+Math.random()
         xhr.setRequestHeader('Content-Type','application/x-www-form-urlencoded'); // utiliser en POST uniquement
         xhr.send(chaine); // 'message='+
         alert(xhr.responseText);
      }
      
      return;
   }
   /****************************************************************************/

