      

      var TRequest;
      var TRequestSection;
      var TRequestCallBack;
      var TRequestLoadingWindow;
      //
      //  TXmlRequest Object
      //
      // func must have the prototype: func(XmlHttpRequest)
      //
      function TGetXml(url, func, method, post_val)
      {

        TRequestCallBack = func;
        this.url = url;
        this.method = method;
        this.post_val = post_val;
        
        this.loadXMLDoc = function ()
        {
          // branch for native XMLHttpRequest object
              if (window.XMLHttpRequest) {
                  TRequest = new XMLHttpRequest();
                  TRequest.onreadystatechange = this.processReqChange;
                  TRequest.open(this.method, this.url, true);
                  if(this.method == 'POST')
                  {
                    TRequest.setRequestHeader('Content-Type','application/x-www-form-urlencoded; charset=iso-8859-1');
                  }
                  TRequest.send(this.post_val);

              // branch for IE/Windows ActiveX version
              } else if (window.ActiveXObject) {
                  TRequest = new ActiveXObject("Microsoft.XMLHTTP");
                  if (TRequest) {
                      TRequest.onreadystatechange = this.processReqChange;
                      TRequest.open(this.method, this.url, true);
                      if(this.method == 'POST')
                      {
                        TRequest.setRequestHeader('Content-Type','application/x-www-form-urlencoded; charset=iso-8859-1');
                      }
                      TRequest.send(this.post_val);
                  }
              }
        }
    

        this.processReqChange = function () 
        {

            // only if req shows "complete"
            if (TRequest.readyState == 4) {
                // only if "OK"
                if (TRequest.status == 200) {
                   
                   TRequestCallBack(TRequest);
                  
                } else {
                    alert("There was a problem retrieving the XML data:\n" + TRequest.statusText);
                }
            }
            
        }
        
      }

      
      function doTSectionRequest(id_section, request, printLoad, method, post_val)
      {
          var o = new TSectionRequest(id_section, request, printLoad, method, post_val);
          
          o.doRequest();  
      }

      function doTSectionRequestFromDesc(desc)
      {
        
        doTSectionRequest(desc.div_name,desc.createURL(),desc.printLoad, desc.method, desc.post_val);
      }

      function TSectionRequest(id_section, request, printLoad, method, post_val)
      {
        TRequestSection = document.getElementById(id_section);
      
        this.end = function (hreq)
        {
          TRequestLoadingWindow.hide();
          TRequestSection.innerHTML = "";
          TRequestSection.innerHTML = hreq.responseText;        
        }
       
        this.doRequest = function()
        {
          
          if(TRequestSection)
          {
            if(printLoad)
            {
              TRequestLoadingWindow = new TLoadingWindow();
              TRequestLoadingWindow.create();
              TRequestLoadingWindow.show();
            }
            
            var r = new TGetXml(request, this.end, method, post_val);
            
            r.loadXMLDoc();

          }
        }
      }

      

    /* *******************************
        Message Window
    **********************************/

    var TLoadingWindowDivWritten = false;
    var TLoadingWindowDivId;
    var TLoadingWindowDivObj;
   

    function TLoadingWindow()
    {
      this.ie=(document.all);
      this.ns=(document.layers);
      this.ns6=(document.getElementById && !this.ie);

      this.create = function()
      {
        TLoadingWindowDivId = 'TLoadingWindowId';


        if(!TLoadingWindowDivWritten)

        {

          TLoadingWindowDivWritten = true;

        }

        TLoadingWindowDivObj = document.getElementById(TLoadingWindowDivId);

        TLoadingWindowDivObj.style.visibility = 'hidden';

      }

      

      this.show = function()

      {

        if(TLoadingWindowDivWritten)

        {

          this.centerWindow();

          TLoadingWindowDivObj.style.visibility = 'visible';

        }

      }

      

      this.hide = function()

      {

        if(TLoadingWindowDivWritten)

          TLoadingWindowDivObj.style.visibility = 'hidden';

      }

      

      this.centerWindow = function()

      {

        var winw = TLoadingWindowDivObj.offsetHeight;

        var winh = TLoadingWindowDivObj.offsetWidth;

        

        if (this.ie){

          

        	//this.documentWidth = Math.floor((centerElement().offsetWidth)/2)+centerElement().scrollLeft-Math.floor(winw/2);

        	//this.documentHeight = Math.floor((centerElement().offsetHeight)/2)+centerElement().scrollTop-Math.floor(winh/2);

        	

        }

        else if (this.ns){

        	this.documentWidth=Math.floor(window.innerWidth/2)+window.pageXOffset-Math.floor(winw/2);

        	this.documentHeight=Math.floor(window.innerHeight/2)+window.pageYOffset-Math.floor(winh/2);

        }

        else if (this.ns6){

        	this.documentWidth=Math.floor(self.innerWidth/2)+window.pageXOffset-Math.floor(winw/2);

        	this.documentHeight=Math.floor(self.innerHeight/2)+window.pageYOffset-Math.floor(winh/2);

        }

        
        if (this.ie)
        {
          TLoadingWindowDivObj.style.top = 0; 
          TLoadingWindowDivObj.style.right = 0;
        }
        else
        {
          TLoadingWindowDivObj.style.top = this.documentHeight;
          TLoadingWindowDivObj.style.left = this.documentWidth;
        }
        

      }

      

      this.centerElement = function()

      {

        return (document.compatMode && document.compatMode!="BackCompat")? document.documentElement : document.body;

      }

    }


    function TSectionDescription()
    {

      this.div_name = '';
      this.template = '';
      this.section_name = '';
      this.method = 'GET';
      this.request = 'BYID';
      this.output = 'html';
      this.taille = '1';
      this.page = '0';
      this.action = '';
      this.printLoad = true;
      this.vote = '';
      this.variables = new Array();
      this.post_val = null;
      
      this.createURL = function()
      {
        this.url ='/ajax.php?s='+this.section_name+'&t='+this.template+'&r='+this.request+'&a='+this.action+'&o='+this.output+'&taille='+this.taille+'&page='+this.page;
        
        
        if(this.vote >= 0)
        {
          this.url = this.url + '&vote='+this.vote;
        }  
        
        for(i = 0; i < this.variables.length; i++)
        {
          this.url = this.url + '&v' + (i+1) + '=' + this.variables[i];
        }
        return this.url;
      }
      
    }     


    function encoder(val)
    {
        if(encodeURIComponent)
        {
          return encodeURIComponent(val);
        }
        else
        {
          return escape(val);
        }
    }
    
    /**************************************************************************/
    /*            Méthodes spécifiques                                        */
    /**************************************************************************/
    function TBigVote(vote,section,id,div)
      {
        d = new TSectionDescription();
        d.section_name = section;   
        d.div_name = div;          
        d.template = 'big.vote.element';
        d.action = 'vote';
        d.request = 'BYID';
        d.variables.push(id);
        d.vote = vote;
        doTSectionRequestFromDesc(d);
      }

    function TSmallVote(vote,section,id,div)
      {
        d = new TSectionDescription();
        d.section_name = section;   
        d.div_name = div;           
        d.template = 'mini.vote.element';
        d.action = 'vote';
        d.request = 'BYID';
        d.variables.push(id);
        d.vote = vote;
        doTSectionRequestFromDesc(d);
      }
