<!DOCTYPE html>
<html lang="<?= $this->language ?>">
<head>

  <meta charset="<?= $this->charset ?>">
  <title>Contao Open Source CMS <?= VERSION ?></title>
  <base href="<?= $this->base ?>">
  <meta name="generator" content="Contao Open Source CMS">
  <meta name="viewport" content="width=device-width,initial-scale=1.0">
  <meta name="referrer" content="origin">

  <link rel="stylesheet" href="<?php
    $objCombiner = new Combiner();
    $objCombiner->add('assets/mootools/stylect/css/stylect.css');
    $objCombiner->add('system/themes/'. $this->theme .'/basic.css');
    $objCombiner->add('system/themes/'. $this->theme .'/switch.css');
    echo $objCombiner->getCombinedFile();
  ?>">
  <!--[if IE]><link rel="stylesheet" href="<?= TL_ASSETS_URL ?>system/themes/<?= $this->theme ?>/iefixes.css"><![endif]-->
  <?= $this->stylesheets ?>

  <script><?= $this->getLocaleString() ?></script>
  <script src="<?php
    $objCombiner = new Combiner();
    $objCombiner->add('assets/mootools/core/' . $GLOBALS['TL_ASSETS']['MOOTOOLS'] . '/mootools.js', $GLOBALS['TL_ASSETS']['MOOTOOLS']);
    $objCombiner->add('assets/mootools/stylect/js/stylect.js');
    $objCombiner->add('assets/mootools/mootao/Mootao.js');
    echo $objCombiner->getCombinedFile();
  ?>"></script>
  <script><?= $this->getDateString() ?></script>
  <?= $this->javascripts ?>
  <!--[if lt IE 9]><script src="<?= TL_ASSETS_URL ?>assets/html5shiv/<?= $GLOBALS['TL_ASSETS']['HTML5SHIV'] ?>/html5shiv.min.js"></script><![endif]-->

</head>
<body class="<?= $this->ua ?>">

  <div id="container">

    <div id="left">
      <p><?= $this->fePreview ?></p>
    </div>

    <div id="right">
      <form action="<?= $this->action ?>" method="post">
        <div class="formbody">
          <input type="hidden" name="FORM_SUBMIT" value="tl_switch">
          <input type="hidden" name="REQUEST_TOKEN" value="<?= REQUEST_TOKEN ?>">
          <?php if ($this->isAdmin): ?>
            <label for="ctrl_user"><?= $this->feUser ?>:</label>
            <input type="text" name="user" id="ctrl_user" list="userlist" class="tl_text user" placeholder="<?= $this->username ?>" value="<?= $this->user ?>" autocomplete="off">
            <datalist id="userlist">
              <option value="-"></option>
            </datalist>
          <?php endif; ?>
          <label for="ctrl_unpublished"><?= $this->hiddenElements ?>:</label>
          <select name="unpublished" id="ctrl_unpublished" class="tl_select">
            <option value="hide"><?= $this->lblHide ?></option>
            <option value="show"<?php if ($this->show) echo ' selected="selected"'; ?>><?= $this->lblShow ?></option>
          </select>
          <input type="submit" class="tl_submit" value="<?= $this->apply ?>">
          <input type="button" class="tl_submit" value="<?= $this->reload ?>" onclick="parent.frames[1].location.reload()">
          <a href="javascript:parent.location.href=parent.frames[1].location.href" class="close">&times;</a>
        </div>
      </form>
    </div>

  </div>

  <?php if ($this->update): ?>
    <script>parent.frames[1].location.reload(true)</script>
  <?php endif; ?>

  <script>
    window.addEvent('domready', function() {
      if (document.createElement('datalist') && window.HTMLDataListElement) {
        $('ctrl_user').addEvent('keyup', function() {
          var u = $('ctrl_user'), l = $('userlist');
          if (u.value.length < 2) return;
          new Request.JSON({
            onSuccess: function(txt, json) {
              l.empty() && JSON.decode(json).each(function(v) {
                new Element('option', {'value':v}).inject(l);
              });
            }
          }).post({'value':u.value,'REQUEST_TOKEN':Contao.request_token});
        });
      }
    });
  </script>

</body>
</html>