<!DOCTYPE html>
<!--[if IE]><![endif]-->
<!--[if IE 8 ]><html dir="{{ direction }}" lang="{{ lang }}" class="ie8"><![endif]-->
<!--[if IE 9 ]><html dir="{{ direction }}" lang="{{ lang }}" class="ie9"><![endif]-->
<!--[if (gt IE 9)|!(IE)]><!-->
<html dir="{{ direction }}" lang="{{ lang }}">
<!--<![endif]-->
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<title>{{ title }}</title>
<base href="{{ base }}" />
{% if description %}
<meta name="description" content="{{ description }}" />
{% endif %}
{% if keywords %}
<meta name="keywords" content="{{ keywords }}" />
{% endif %}
<script src="catalog/view/javascript/jquery/jquery-2.1.1.min.js" type="text/javascript"></script>
<link href="catalog/view/javascript/bootstrap/css/bootstrap.min.css" rel="stylesheet" media="screen" />
<script src="catalog/view/javascript/bootstrap/js/bootstrap.min.js" type="text/javascript"></script>
<link href="catalog/view/javascript/font-awesome/css/font-awesome.min.css" rel="stylesheet" type="text/css" />
<link href="//fonts.googleapis.com/css?family=Open+Sans:400,400i,300,700" rel="stylesheet" type="text/css" />
<link href="catalog/view/theme/default/stylesheet/stylesheet.css" rel="stylesheet">
{% for style in styles %}
<link href="{{ style.href }}" type="text/css" rel="{{ style.rel }}" media="{{ style.media }}" />
{% endfor %}
{% for script in scripts %}
<script src="{{ script }}" type="text/javascript"></script>
{% endfor %}
<script src="catalog/view/javascript/common.js" type="text/javascript"></script>
{% for link in links %}
<link href="{{ link.href }}" rel="{{ link.rel }}" />
{% endfor %}
{% for analytic in analytics %}
{{ analytic }}
{% endfor %}

        <script type="text/javascript">
          function facebook_loadScript(url, callback) {
            var script = document.createElement("script");
            script.type = "text/javascript";
            if(script.readyState) {  // only required for IE <9
              script.onreadystatechange = function() {
                if (script.readyState === "loaded" || script.readyState === "complete") {
                  script.onreadystatechange = null;
                  if (callback) {
                    callback();
                  }
                }
              };
            } else {  //Others
              if (callback) {
                script.onload = callback;
              }
            }

            script.src = url;
            document.getElementsByTagName("head")[0].appendChild(script);
          }
        </script>

        <script type="text/javascript">
          (function() {
            var enableCookieBar = '{{ facebook_enable_cookie_bar }}';
            if (enableCookieBar === 'true') {
              facebook_loadScript("catalog/view/javascript/facebook/cookieconsent.min.js");

              // loading the css file
              var css = document.createElement("link");
              css.setAttribute("rel", "stylesheet");
              css.setAttribute("type", "text/css");
              css.setAttribute(
                "href",
                "catalog/view/theme/css/facebook/cookieconsent.min.css");
              document.getElementsByTagName("head")[0].appendChild(css);

              window.addEventListener("load", function(){
                function setConsent() {
                  fbq(
                    'consent',
                    this.hasConsented() ? 'grant' : 'revoke'
                  );
                }
                window.cookieconsent.initialise({
                  palette: {
                    popup: {
                      background: '#237afc'
                    },
                    button: {
                      background: '#fff',
                      text: '#237afc'
                    }
                  },
                  cookie: {
                    name: fbq.consentCookieName
                  },
                  type: 'opt-out',
                  showLink: false,
                  content: {
                    dismiss: 'Agree',
                    deny: 'Opt Out',
                    header: 'Our Site Uses Cookies',
                    message: 'By clicking Agree, you agree to our <a class="cc-link" href="https://www.facebook.com/legal/terms/update" target="_blank">terms of service</a>, <a class="cc-link" href="https://www.facebook.com/policies/" target="_blank">privacy policy</a> and <a class="cc-link" href="https://www.facebook.com/policies/cookies/" target="_blank">cookies policy</a>.'
                  },
                  layout: 'basic-header',
                  location: true,
                  revokable: true,
                  onInitialise: setConsent,
                  onStatusChange: setConsent,
                  onRevokeChoice: setConsent
                }, function (popup) {
                  // If this isn't open, we know that we can use cookies.
                  if (!popup.getStatus() && !popup.options.enabled) {
                    popup.setStatus(cookieconsent.status.dismiss);
                  }
                });
              });
            }
          })();
        </script>

        <script type="text/javascript">
          (function() {
            !function(f,b,e,v,n,t,s){if(f.fbq)return;n=f.fbq=function(){n.callMethod?
            n.callMethod.apply(n,arguments):n.queue.push(arguments)};if(!f._fbq)f._fbq=n;
            n.push=n;n.loaded=!0;n.version='2.0';n.queue=[];t=b.createElement(e);t.async=!0;
            t.src=v;s=b.getElementsByTagName(e)[0];s.parentNode.insertBefore(t,s)}(window,
            document,'script','https://connect.facebook.net/en_US/fbevents.js');

            var enableCookieBar = '{{ facebook_enable_cookie_bar }}';
            if (enableCookieBar === 'true') {
              fbq.consentCookieName = 'fb_cookieconsent_status';

              (function() {
                function getCookie(t){var i=("; "+document.cookie).split("; "+t+"=");if(2==i.length)return i.pop().split(";").shift()}
                var consentValue = getCookie(fbq.consentCookieName);
                fbq('consent', consentValue === 'dismiss' ? 'grant' : 'revoke');
              })();
            }

            {% if facebook_pixel_id_FAE %}
// system auto generated facebook_pixel.js, DO NOT MODIFY
pixel_script_filename = 'catalog/view/javascript/facebook/facebook_pixel_2_1_10.js';
// system auto generated facebook_pixel.js, DO NOT MODIFY
              facebook_loadScript(
                pixel_script_filename,
                function() {
                  var params = {{ facebook_pixel_params_FAE }};
                  _facebookAdsExtension.facebookPixel.init(
                    '{{ facebook_pixel_id_FAE }}',
                    {{ facebook_pixel_pii_FAE }},
                    params);
                  {% if facebook_pixel_event_params_FAE %}
                    _facebookAdsExtension.facebookPixel.firePixel(
                      JSON.parse('{{facebook_pixel_event_params_FAE }}'));
                  {% endif %}
                });
            {% endif %}
          })();
        </script>
      
</head>
<body>
<nav id="top">
  <div class="container">{{ currency }}
    {{ language }}
    <div id="top-links" class="nav pull-right">
      <ul class="list-inline">
        <li><a href="{{ contact }}"><i class="fa fa-phone"></i></a> <span class="hidden-xs hidden-sm hidden-md">{{ telephone }}</span></li>
        <li class="dropdown"><a href="{{ account }}" title="{{ text_account }}" class="dropdown-toggle" data-toggle="dropdown"><i class="fa fa-user"></i> <span class="hidden-xs hidden-sm hidden-md">{{ text_account }}</span> <span class="caret"></span></a>
          <ul class="dropdown-menu dropdown-menu-right">
            {% if logged %}
            <li><a href="{{ account }}">{{ text_account }}</a></li>
            <li><a href="{{ order }}">{{ text_order }}</a></li>
            <li><a href="{{ transaction }}">{{ text_transaction }}</a></li>
            <li><a href="{{ download }}">{{ text_download }}</a></li>
            <li><a href="{{ logout }}">{{ text_logout }}</a></li>
            {% else %}
            <li><a href="{{ register }}">{{ text_register }}</a></li>
            <li><a href="{{ login }}">{{ text_login }}</a></li>
            {% endif %}
          </ul>
        </li>
        <li><a href="{{ wishlist }}" id="wishlist-total" title="{{ text_wishlist }}"><i class="fa fa-heart"></i> <span class="hidden-xs hidden-sm hidden-md">{{ text_wishlist }}</span></a></li>
        <li><a href="{{ shopping_cart }}" title="{{ text_shopping_cart }}"><i class="fa fa-shopping-cart"></i> <span class="hidden-xs hidden-sm hidden-md">{{ text_shopping_cart }}</span></a></li>
        <li><a href="{{ checkout }}" title="{{ text_checkout }}"><i class="fa fa-share"></i> <span class="hidden-xs hidden-sm hidden-md">{{ text_checkout }}</span></a></li>
      </ul>
    </div>
  </div>
</nav>
<header>
  <div class="container">
    <div class="row">
      <div class="col-sm-4">
        <div id="logo">{% if logo %}<a href="{{ home }}"><img src="{{ logo }}" title="{{ name }}" alt="{{ name }}" class="img-responsive" /></a>{% else %}
          <h1><a href="{{ home }}">{{ name }}</a></h1>
          {% endif %}</div>
      </div>
      <div class="col-sm-5">{{ search }}</div>
      <div class="col-sm-3">{{ cart }}</div>
    </div>
  </div>


        {% if facebook_messenger_enabled_FAE == 'true' %}
        <!-- Facebook JSSDK -->
        <script>
          window.fbAsyncInit = function() {
            FB.init({
              appId            : '',
              autoLogAppEvents : true,
              xfbml            : true,
              version          : '{{ facebook_jssdk_version_FAE }}'
            });
          };

          (function(d, s, id){
             var js, fjs = d.getElementsByTagName(s)[0];
             if (d.getElementById(id)) {return;}
             js = d.createElement(s); js.id = id;
             js.src = "https://connect.facebook.net/{{ facebook_customization_locale_FAE }}/sdk/xfbml.customerchat.js";
             fjs.parentNode.insertBefore(js, fjs);
           }(document, 'script', 'facebook-jssdk'));
        </script>
        <div
          class="fb-customerchat"
          attribution="fbe_opencart"
          page_id="{{ facebook_page_id_FAE }}"
          {{ facebook_customization_greeting_text_code_FAE }}
          {{ facebook_customization_theme_color_code_FAE }}
        />
        {% endif %}
      
</header>
{{ menu }}
