<?php
// COOKIE
$cookie = 'false';

if (isset($_COOKIE["disclaimer"])) {
  $cookie = $_COOKIE["disclaimer"];
}

$pageTemplate = basename(get_page_template());

if ($pageTemplate == "template-minimal.php") {
  $cookie = 'true';
}

// TITLE AND SEO
$description = get_bloginfo('description');

$specialCSS = '';
?>

<!DOCTYPE html>
<!--[if IE 9 ]><html class="ie9"> <![endif]-->
<!--[if IE 8 ]><html class="ie8 ie9"> <![endif]-->
<!--[if (gt IE 9)|!(IE)]><!-->

<html lang="<?php echo  apply_filters('wpml_current_language', null); ?>">
<!--<![endif]-->

<head>
  <!-- Google Tag Manager -->
  <script>
    (function(w, d, s, l, i) {
      w[l] = w[l] || [];
      w[l].push({
        'gtm.start': new Date().getTime(),
        event: 'gtm.js'
      });
      var f = d.getElementsByTagName(s)[0],
        j = d.createElement(s),
        dl = l != 'dataLayer' ? '&l=' + l : '';
      j.async = true;
      j.src =
        'https://www.googletagmanager.com/gtm.js?id=' + i + dl;
      f.parentNode.insertBefore(j, f);
    })(window, document, 'script', 'dataLayer', 'GTM-W3G5CSG');
  </script>
  <!-- End Google Tag Manager -->


  <meta charset="utf-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
  <meta name="viewport" content="width=device-width, minimum-scale=1,user-scalable=0">
  <meta name="mobile-web-app-capable" content="yes">
  <meta name="apple-mobile-web-app-status-bar-style" content="black">
  <!-- <title><?php echo wp_title('&raquo;', true, '') ?></title> -->

  <link rel="apple-touch-icon-precomposed" href="<?php bloginfo('template_url'); ?>/favicon.png" />
  <link rel="shortcut icon" href="<?php bloginfo('template_url'); ?>/favicon.ico">
  <link rel="icon" type="image/png" href="<?php bloginfo('template_url'); ?>/favicon.png" />

  <script type="text/javascript" charset="utf-8">
    var wpLpTemplateUrl = '<?php echo esc_url(home_url("/")); ?>';
    var wpmlLang = '<?php echo  ICL_LANGUAGE_CODE; ?>';
    var country = '<?php echo lp_get_country_ip(); ?>';
  </script>

  <?php wp_head(); ?>

  <meta name=“p:domain_verify” content="f10172eef64afdd869637b348c086457" />
</head>

<body <?php


      if ($cookie == 'false') {
        if (!is_display_buy_buttons()) {
          body_class('no_buy_button needDisclaimer');
        } else {
          body_class('needDisclaimer');
        }
      } else {
        if (!is_display_buy_buttons()) {
          body_class('no_buy_button');
        } else {
          body_class();
        }
      } ?>>

  <!-- Google Tag Manager (noscript) -->
  <noscript><iframe src="https://www.googletagmanager.com/ns.html?id=GTM-W3G5CSG" height="0" width="0" style="display:none;visibility:hidden"></iframe></noscript>
  <!-- End Google Tag Manager (noscript) -->

  <?php
  $insta_url = get_field('insta_url', 'option');
  ?>

  <?php if ($pageTemplate != "template-minimal.php") : ?>
    <!-- HEADER -->
  <?php endif; ?>

  <!-- Skip Links for RGAA Accessibility -->
  <a href="#main-content" class="sr-only focus:not-sr-only focus:absolute focus:top-0 focus:left-0 bg-blue-600 text-white p-2 z-50"><?php echo __('Aller au contenu principal', 'laurentperrier'); ?></a>
  <a href="#main-navigation" class="sr-only focus:not-sr-only focus:absolute focus:top-0 focus:left-32 bg-blue-600 text-white p-2 z-50"><?php echo __('Aller à la navigation', 'laurentperrier'); ?></a>

  <div class="text-[#ffffff] text-[#000000] hidden"></div>

  <?php if (is_single() && $post->post_parent > 0 && get_post_type() == "la-maison") :
    $specialCSS = 'fix-menus';
  endif; ?>
  <header id="header" class="main-header bg-white <?php echo $specialCSS . ' select-' . get_the_ID(); ?> " role="banner">

    <div class="flex w-full mx-auto max-w-[1800px] justify-center lg:justify-between items-center h-full ">
      <div class=""><a href="<?php echo esc_url(home_url('/')); ?>" class="logo" aria-label="<?php echo esc_attr(__('Retour à l\'accueil', 'laurentperrier')); ?>"><img class="max-w-[180px] md:max-w-[240px]" src="<?php echo get_stylesheet_directory_uri() ?>/dist/assets/img/laurent-perrier.svg" alt="<?php echo esc_attr(get_bloginfo('name') . ' - ' . __('Logo', 'laurentperrier')); ?>"></a></div>
      <div>
        <button class="btn-nav-toggler-container js-toggle-element-class lg:hidden" type="button" data-class="js-menu-open" data-dom="body" aria-controls="newMenu" aria-haspopup="true" aria-expanded="false" aria-label="<?php echo esc_attr(__('Ouvrir le menu de navigation', 'laurentperrier')); ?>">
          <div class="btn-nav-toggler items-center justify-center relative">
            <div class="icon"></div>
          </div>
        </button>
        <nav role="navigation" id="newMenu" aria-label="<?php echo esc_attr(__('Navigation principale', 'laurentperrier')); ?>">
          <a href="<?php echo esc_url(home_url('/')); ?>" class="logo lg:hidden" aria-label="<?php echo esc_attr(__('Retour à l\'accueil', 'laurentperrier')); ?>"><img class="max-w-[180px] md:max-w-[240px]" src="<?php echo get_stylesheet_directory_uri() ?>/dist/assets/img/laurent-perrier.svg" alt="<?php echo esc_attr(get_bloginfo('name') . ' - ' . __('Logo', 'laurentperrier')); ?>"></a>
          <?php
          wp_nav_menu(
            array(
              'menu' => 'Menu principal',
              'menu_id' => 'mainMenu',
              'walker' => new WPSE_new_header_Walker,
              'menu_class' => 'menu menu-' . get_post_type(),
            )
          );
          ?>
          <?php // wp_nav_menu(array('menu' => 'Menu principal'));
          ?>
        </nav>
      </div>
    </div>
  </header>

  <style>
    <?php
    $contentWidth_raw = get_field('largeur_de_conteneur');
    $contentWidth = is_string($contentWidth_raw) ? strtolower($contentWidth_raw) : '';
    if (!empty($contentWidth)) {
      switch ($contentWidth) {
        case 'md':
          $contentWidth = '800px';
          break;
        case 'lg':
          $contentWidth = '960px';
          break;
        case 'xl':
          $contentWidth = '1220px';
          break;
        default:
          $contentWidth = '800px';
          break;
      }
    ?>.section_wrapper,
    .post .container {
      max-width: <?php echo $contentWidth; ?> !important;
    }

    <?php
    }
    ?>
  </style>
