  window.addEventListener('load', function() { 
    window.scrollTo(0,0);
  }, false);

  /*
   * Personnalisation
   * Que se passe-t-il lorsque la bannière est invisible ?
   */
  function setLogoVisiblity(visibilityFlag) {
    let element = document.querySelector("nav>*>#settings");
    let value = 'hidden';
    if (visibilityFlag) value = "visible";
    element.style.visibility = value;
  }

  function setNavbarStickOnTop(topFlag) {
    let element = document.querySelector("#nav");
    if (topFlag) element.style.setProperty('top', '0px');
    else element.style.removeProperty('top');
  }

  function setDataGridFootSticky(stickyFlag) {
    let element = null;
    if (stickyFlag) {
      //
      // Mettre le tfoot sticky au bottom
      //
      element = document.querySelector("#datagrid>table>tfoot");
      element.style.setProperty('position', 'sticky');
      element.style.setProperty('bottom', '0px');
      element.style.setProperty('z-index', '30');
    } else {
      element = document.querySelector("#datagrid>table>tfoot");
      element.style.setProperty('position', 'relative');
      element.style.setProperty('z-index', '10');
    }
  }

  /*
   * Personnalisation
   * Que se passe-t-il lorsque la synthèse est invisible ?
   */
  function setDatagridFirstColSticky(stickyFlag) {
    let element = null;

    if (stickyFlag) {
      /*
       * Mettre la première case sticky au top left
       */
      element = document.querySelector("#datagrid>table>thead>tr>th:first-child");
      element.style.setProperty('position', 'sticky');
      element.style.setProperty('left', '0px');
      element.style.setProperty('z-index', '30');

      //
      // Mettre la dernière case sticky au bottom left
      //      
      element = document.querySelector("#datagrid>table>tfoot>tr>th:first-child");
      element.style.setProperty('position', 'sticky');
      element.style.setProperty('left', '0px');
      element.style.setProperty('z-index', '30');

    } else {
      element = document.querySelector("#datagrid>table>thead>tr>th:first-child");
      element.style.setProperty('position', 'sticky');
      element.style.setProperty('left', '0px');
      element.style.setProperty('z-index', '10');

      element = document.querySelector("#datagrid>table>tfoot>tr>th:first-child");
      element.style.setProperty('position', 'sticky');
      element.style.setProperty('left', '0px');
      element.style.setProperty('z-index', '10');
    }
  }

  function setDatagridHeadSticky(stickyFlag) {
    let element = document.querySelector("#datagrid>table>thead");
    let navbar = document.querySelector("nav");
    let offset = navbar.offsetHeight;

    if (stickyFlag) {
      /*
       * Mettre le thead sticky au top
       */
      //element = document.querySelector("#datagrid>table>thead");
      element.style.setProperty('position', 'sticky');
      element.style.setProperty('top', offset+'px');
      element.style.setProperty('z-index', '30');
    } else {
      //element = document.querySelector("#datagrid>table>thead");
      element.style.setProperty('position', 'relative');
      element.style.setProperty('top', '0px');
      element.style.setProperty('z-index', '10');
    }
  }

  function smoothJump(hash) {
    location.replace("#" + hash);
  }

  function documentGetElementById(id){
    element = document.getElementById(id);
    if (element === null ) return '';
    return element.value;
  }

  function setElementHeight(elementSelector, elementHeight) {
    let element = document.querySelector(elementSelector);
    element.style.height = elementHeight;
  }

  function slideElement(elementSelector, elementHeight) {
    let element = document.querySelector(elementSelector);
    element.style.transition = "all 2s ease-in-out";
    setElementHeight(elementSelector, elementHeight);
  }

  function scrollToElement(elementSelector) {
    let element = document.querySelector(elementSelector);
    element.scrollIntoView({ behavior: 'smooth' });
  }

  function gotoHelp() {
    scrollToElement('#synthesis');
    setTimeout(scrollToElement, 500, '#footer');
  }

  function gotoTop() {
    let element = document.querySelector('header');
    window.scrollTo(0, element.offsetHeight + 1);
  }

  function headerIsVisible(flagVisible) {
    setLogoVisiblity(!flagVisible);
    if (!flagVisible) gotoTop();
  }

  function synthesisTopIsNowVisible(entry) {

    setDatagridHeadSticky(false);
    setDataGridFootSticky(false);
    /*
    setDatagridFirstColSticky(true);
    */

    myLog('Trigger synthesis is visible');
  }

  function synthesisTopIsNowInvisible(entry) {

    setDatagridHeadSticky(true);
    setDataGridFootSticky(true);
    /*
    setDatagridFirstColSticky(true);
    */

    myLog('Trigger synthesis is invisible');
  }

  function initDatagrid()
  {
    datagridLoading();
  }


  function afficher_synthese(mode) {
    let synthesis_body = document.querySelector('#synthesis_body');
    if (synthesis_body) {
      synthesis_body.innerHTML='';
      let template = document.querySelector('#synthesis_body_' + mode);
      if (template) {
        let contenu = document.importNode(template.content, true);
        if (contenu) synthesis_body.appendChild(contenu);
      }
    }
  }

  function afficher_footer(mode) {
    let footer_body = document.querySelector('footer');
    if (footer_body) {
      footer_body.innerHTML='';
      let template = document.querySelector('#footer_' + mode);
      if (template) {
        let contenu = document.importNode(template.content, true);
        if (contenu) footer_body.appendChild(contenu);
      }
    }
  }

  function activeMenu(element) {
    datagridEmptyLines(50);

    activeMode(element.innerText);

    gotoTop();
  }

  function modeToAffichage(mode)
  {
    let retour='taches';
    switch (mode) {
      case 'Releases':
        retour='releases';
      break;
      case 'Hollidays':
        retour='feries';
      break;
      case 'Rendez-Vous':
        retour='rdv';
      break;
      case 'Rendez-Vous':
        retour='rdv';
      break;
      case 'Items':
        retour='items';
      break;
      case 'Project':
        retour='prestations';
      break;
      default:
      case 'Tasks':
        retour='taches';
      break;
    }
    return retour;
  }

  function activeMode(mode) {
    setFilAriane(['Home', mode]);
    initDatagrid();
  }

  // UI
  setLogoVisiblity(false);

  // Contexte de départ
  setContexteValeur('user', 'Anonymous');

  // GO !
  activeMode('Menu1');
