<!--

function TableTool( id, parentId, arrayHeaders ){

/* Identifiant des elements */
this.id = id;
this.parentId = parentId;

/* Creation des conteneurs de travail */
this.Header = $C("tr");
this.Line = $C("tr");


/* Création du tableau */
this.init = function (tabClass){
    Table     = $C("table");
    Table.id = this.id;
    TableBody = $C("tbody");
    Table.appendChild( TableBody );
    if( tabClass!="" ) Table.setAttribute("class", tabClass);
    $(this.parentId).appendChild(Table);
  }

/* Ajout d'un Header */
this.addHeader = function (val, cellClass, url, urlClass){
    var td = $C("th");
    var txt = document.createTextNode ( val );
    if( url!="" ){
      var a = $C("a");
      a.setAttribute("href", url);
      if( urlClass!="" ) a.setAttribute("class", urlClass);
      a.appendChild( txt );
      td.appendChild( a );
    }else{
       td.appendChild( txt );
    }
    if( cellClass!="" ){
      td.setAttribute("class", cellClass);
    }
    this.Header.appendChild( td );
    return true;
  }

/* Ajout d'un attirbut du header */
this.addHeaderAttribute = function (attName, val){
    this.Header.setAttribute(attName, val);
    return true;
  }

/* Affichage du header */
this.printHeader = function (){
    $(this.id).firstChild.appendChild(this.Header);
  }

/* Affichage d'une cellule de ligne */
this.addCell = function (val, cellClass, url, urlClass){
    var td = $C("td");
    var txt = document.createTextNode ( val );
    if( url!="" ){
      var a = $C("a");
      a.setAttribute("href", url);
      if( urlClass!="" ) a.setAttribute("class", urlClass);
      a.appendChild( txt );
      td.appendChild( a );
    }else{
       td.appendChild( txt );
    }
    if( cellClass!="" ){
      td.setAttribute("class", cellClass);
    }
    this.Line.appendChild( td );
    return true;
  }

/* Affichage d'une cellule préformattée avec du code */
this.addCellData = function (val, cellClass){
    var td = $C("td");
    if(cellClass!="") td.setAttribute("class", cellClass);
    td.innerHTML = val;

    this.Line.appendChild( td );
    return true;
  }

/* Affichage d'un attribut de ligne */
this.addLineAttribute = function (attName, val){
    this.Line.setAttribute(attName, val);
    return true;
  }

/* Affichage d'une ligne */
this.printLine = function (lineStyle, id){
    if( lineStyle!="" ) this.Line.setAttribute("class",lineStyle);
    if( id!="" ) this.Line.setAttribute("id",id);
    $(this.id).firstChild.appendChild(this.Line);
    this.Line = $C("tr");
  }

/* RAZ des lignes */
this.resetAllLines = function (){
    $(this.parentId).removeChild( $(this.id) );
    this.line = $C("tr");
    this.init(  );
    this.printHeader(  );
  }

this.resetTable = function (){
    $(this.parentId).removeChild( $(this.id) );
  }

/* trie d'un tableau pour la colonne n */
this.sortMe = function( n ) {

    var reg = /^\d+(\.\d+)?$/g;
    var ind = 0, val = null, min = null;
    for (var i= $(this.id).firstChild.rows.length -1; i >= 1; i -= 1) {
      min = val = null;
      ind = 0;
      for (var j=i; j >= 1; j -= 1) {
        /* si l'élément n'est pas du text directement */
        if( $(this.id).firstChild.rows[j].cells[n].firstChild.hasChildNodes() ){
          val = $(this.id).firstChild.rows[j].cells[n].firstChild.firstChild.nodeValue;
        }else{
          val = $(this.id).firstChild.rows[j].cells[n].firstChild.nodeValue;
        }
        if (!isNaN(val)) val = parseFloat(val);
          if(min == null || val < min) { 
            ind = j; min = val; 
          }
      }

      if (ind != 0) {
        var row = $(this.id).firstChild.rows[ind];
        if (row) {
          $(this.id).firstChild.removeChild(row);
          $(this.id).firstChild.appendChild(row);
        }
      }
    }

  }


}
//-->
