{{#if initialize }}
<script>
  (function() {
    function setMqIdent() {
      return window.mqIdent = window.getComputedStyle(document.querySelector('html'), '::before').getPropertyValue('content').replace(/"/g, '');
    }
    window.addEventListener('resize', setMqIdent);

    var mqIdent = setMqIdent();

    function setMetaViewport(viewPortContent) {
      document.querySelector('#metaViewport').setAttribute('content', viewPortContent);
    }
    if (mqIdent === 'tablet') {
      setMetaViewport('width=1000, shrink-to-fit=yes');
    }
  })();
</script>
{{/if}}

{{#unless metadata.disableAds }}

{{#if initialize }}
<!-- IQ AdController -->
<script>
  var iqd_mode = (function() {
    var dm = window.location.href.toLowerCase();
    return (dm.indexOf('iqdeployment=') > 1) ? dm.split('iqdeployment=')[1].split('&')[0] : 'live';
  })();

  var mqIdentIQ = window.matchMedia('only screen and (max-width: 767px)').matches ? 'mobile' : 'desktop';
  var iqd_mandator = mqIdentIQ === 'mobile' ? '{{ getConfigValue 'iqdAdController:mandators:mobile' }}' : '{{ getConfigValue 'iqdAdController:mandators:desktop' }}';
  var AdController;
console.log(mqIdentIQ);
  document.write('<scr'+'ipt src="https://s3-eu-central-1.amazonaws.com/prod.iqdcontroller.iqdigital/' +iqd_mandator+ '/' + iqd_mode + '/iqadcontroller.js.gz"></scr' + 'ipt>');
</script>
<script>
  if (typeof AdController !== 'undefined') {
    {{#if metadata.isAsyncContentSwapPage}}
    var pubCmsObject = {
      $handle: "{{ iqd.handle }}",
      level2: "",
      level3: "",
      level4: "",
      keywords: "",
      tma: ""
    };
    if (!AdController._initialized) {
      AdController.setPageInfo(pubCmsObject);
      AdController.initialize();
    } else {
      (function checkDOMReadyState(c) {
        try {
          if (AdController.getRenderController().isReady()) {
            AdController.reinitialize(pubCmsObject);
          }
        } catch (e) {
          if (c < 50) {
            c++;
            setTimeout(function () {
              checkDOMReadyState(c);
            }, 100);
          }
        }
      })(0);
    }
    {{else}}
    AdController.setPageInfo({
      $handle: "{{ iqd.handle }}",
      $autoSizeFrames: true,
      level2: "",
      level3: "",
      keywords: "",
      tma: ""
    });

    try {
      AdController.stage();
    } catch(e) {}

    AdController.initialize();
    {{/if}}
  }

  window.iqd_createAdTile = function iqd_createAdTile(adPosition, adTile, adTileMob) {
    var ad__position = document.getElementById('ad__position--' +adPosition);
    var adTileUsed = window.mqIdent !== 'mobile' ? adTile : adTileMob;

    if (adTileUsed && adTileUsed !== undefined) {
      ad__position.innerHTML = '<div id="iqadtile' +adTileUsed+ '" class="ad__tile ad__tile--' +adTileUsed+ ' text__small--italic"></div>';

      if(typeof AdController !== 'undefined') {
        AdController.render('iqadtile' +adTileUsed);
      }
    }
  };
</script>
{{/if}}
{{#if finalize}}
<script>
  if (typeof AdController !== 'undefined') {
    AdController.finalize();
  }
  var IQDComplete = {
    init: function() {
      return true;
    }
  }
</script>
{{/if}}

{{/unless}}