<script>
  (function(){
    var userLang = navigator.language || navigator.userLanguage;
    var curLang = userLang.toLowerCase().indexOf('fr') > -1 ? 'fr' : 'en';
  
    var headerNavElements = [
      {
        fr: {
          label: "Parcours",
          href:"/",
          title: "",
          internal: true,
        },
        en: {
          label: "Courses",
          href:"/",
          title: "",
          internal: true,
        }
      },
      {
        fr: {
          label: "Webinars",
          href:"/",
          title: "",
          internal: false,
        },
        en: {
          label: "Webinars",
          href:"/",
          title: "",
          internal: false,
        }
      },
    ];
  
    var footerNavElements = [
      {
        fr: {
          label: "Base de connaissance",
          href:"https://help.iadvize.com/hc/fr",
          title: "",
          internal: false,
        },
        en: {
          label: "Knowledge base",
          href:"https://help.iadvize.com/hc/en-gb",
          title: "",
          internal: false,
        }
      },
      {
        fr: {
          label: "iAdvize.com",
          href:"https://iadvize.com",
          title: "",
          internal: false,
        },
        en: {
          label: "iAdvize.com",
          href:"https://iadvize.com",
          title: "",
          internal: false,
        }
      },
    ];
  
    var initialNavElements = [
      {
        fr: {
          label: "Accueil",
          href:"/",
          title: "",
          internal: true,
        },
        en: {
          label: "Home",
          href:"/",
          title: "",
          internal: true,
        }
      }
    ];
  
    var createNavigation = function(parentSelector, className = '', lang = 'en', navigationElements = initialNavElements) {
      var parent = document.querySelectorAll(parentSelector);
  
      if(
        parent &&
        parent.length &&
        navigationElements.length
      ) {
        var nav = document.createElement('nav');
          nav.classList.add(className);
        var navList = document.createElement('ul');
          navList.classList.add('nav');
  
        navigationElements
          .map(function(navEl) {
            return navEl[lang];
          })
          .forEach(function(el) {
            var item = document.createElement('li');
              item.classList.add('nav__item');
            var link = document.createElement('a');
              link.href = el.href;
              link.title = el.title;
              link.target = el.internal ? '_self' : '_blank';
  
            link.append(el.label);
            item.append(link);
            navList.append(item);
          });
          nav.append(navList);
          parent[0].append(nav);
      }
    }
    createNavigation('.footer__container', 'footer__nav', curLang, footerNavElements);
  })()

  // Add Custom datas
  var parentElement = document.querySelector('.page-wrapper');
  var customDataElement = document.createElement('div');
  var emailData = document.createElement('div');
  
  customDataElement.classList.add('idz-custom-data');
  emailData.classList.add('learner-email');
  emailData.innerText = '{{ current_person.email }}';
  //add email
  customDataElement.appendChild(emailData);
  // hide custom data div
  customDataElement.style.display = 'none';

  parentElement.appendChild(customDataElement);
  </script>
    
    <!-- START IADVIZE LIVECHAT -->
  <script type='text/javascript'>
    var idzCustomData = {};
    (function() {
        var idz = document.createElement('script');
        idz.type = 'text/javascript';
        idz.async = true;
        idz.src = document.location.protocol + '//halc.iadvize.com/iadvize.js?sid=7163';
        var s = document.getElementsByTagName('script')[0];
        s.parentNode.insertBefore(idz, s);
    })();
  </script><!-- END IADVIZE LIVECHAT -->
