<?php
if($u_header_float == "on") {
  $header_div_xtra = " style=\"position: fixed;left: 50%; transform: translate(-50%, 0); z-index: 100;\"";
}
?><div class="header"<?php echo $header_div_xtra; ?>>
  <table style="width: 100%; text-align: center;">
    <tr>
      <?php
      /*if($back_button == true) {
        echo '<td style="padding-left: 15px;" onclick="window.window.history.go(-1); return false;"><i id="header_tds" class="fa fa-arrow-left" aria-hidden="true"></i></td>';
      }
      else {
        echo '<td style="padding-left: 15px;"><i id="header_tds" class="fa fa-arrow-left" aria-hidden="true" style="color: transparent !important;"></i></td>';
      }*/
      $extra = mysqli_query($conx, "SELECT uid FROM notifs WHERE uid='$u_uid' && viewed='no' ORDER BY id");
      $ncount = mysqli_num_rows($extra);
      if($ncount > 0) {
        $alert_bell_color = "#939393";
      }
      if($ncount <= 0) {
        $ncount = "";
      }
      echo "<td id=\"alertbell\" onclick=\"window.location='/alerts';\" style=\"padding-left: 15px;\"><i id=\"header_tds\" style=\"color: $alert_bell_color !important;\" class=\"fa fa-bell\" aria-hidden=\"true\"></i></td>";
      ?>
      <td style="width: 100%;" onclick="window.location='/hub';"><img class="mdv5_header" src="/img/header-dark.png" alt="" style="width: 40%; padding-top: 5px;"></td>
      <td style="padding-right: 15px;" onclick="var log_conf=confirm('Are you sure you really want to logout? \nWhy not stay logged in? \nFine, go ahead. \nLogout?');if(log_conf == true){window.location='/logout?t=<?php echo $u_token; ?>';}"><i id="header_tds" class="fa fa-sign-out" aria-hidden="true"></i></td>
    </tr>
  </table>
</div>
<?php
if($u_header_float == "on") {
  echo "

  <div class=\"header\" style=\"width: 100%; max-width: 600px;\">
    <table style=\"width: 100%; text-align: center;\">
      <tr>";

      /*  if($back_button == true) {
          echo '<td style="padding-left: 15px;" onclick="window.window.history.go(-1); return false;"><i id="header_tds" class="fa fa-arrow-left" aria-hidden="true"></i></td>';
        }
        else {
          echo '<td style="padding-left: 15px;"><i id="header_tds" class="fa fa-arrow-left" aria-hidden="true" style="color: transparent !important;"></i></td>';
        }*/
        /*if($back_button == true) {
          echo '<td style="padding-left: 15px;" onclick="window.window.history.go(-1); return false;"><i id="header_tds" class="fa fa-arrow-left" aria-hidden="true"></i></td>';
        }
        else {
          echo '<td style="padding-left: 15px;"><i id="header_tds" class="fa fa-arrow-left" aria-hidden="true" style="color: transparent !important;"></i></td>';
        }*/
        $extra = mysqli_query($conx, "SELECT uid FROM notifs WHERE uid='$u_uid' && viewed='no' ORDER BY id");
        $ncount = mysqli_num_rows($extra);
        if($ncount > 0) {
          $alert_bell_color = "#939393";
        }
        if($ncount <= 0) {
          $ncount = "";
        }
        echo "<td id=\"alertbell_r\" onclick=\"window.location='/alerts';\" style=\"padding-left: 15px;\"><i id=\"header_tds\" style=\"color: $alert_bell_color !important;\" class=\"fa fa-bell\" aria-hidden=\"true\"></i></td>";
        echo "
        <td style=\"width: 100%;\" onclick=\"window.location='/hub';\"><img class=\"mdv5_header\" src=\"/img/header-dark.png\" alt=\"\" style=\"width: 40%; padding-top: 5px;\"></td>
        <td style=\"padding-right: 15px;\" onclick=\"var log_conf=confirm('Are you sure you really want to logout? \nWhy not stay logged in? \nFine, go ahead. \nLogout?');if(log_conf == true){window.location='/logout?t=$u_token';}\"><i id=\"header_tds\" class=\"fa fa-sign-out\" aria-hidden=\"true\"></i></td>
      </tr>
    </table>
  </div>

  ";
}
 ?>

<?php
if($linebreak == true) {
  echo "<br>";
}
if($logged_in == true) {
  if($alerts == true) {
    if($this_page != 'alerts' && $this_page != 'home') {
      //echo "<div id=\"ld_alerts\">";
      //include_once("../inc/alerts.php");
      //echo "</div>";
      //echo "<script>setInterval('upAlerts()', 10000);</script>";
    }
}
  if($this_page != 'chat' && $this_page != 'mail') {
    echo "<script>function expand(id) {
      var e = document.getElementById(id);
      if(e.style.display == 'block')
      e.style.display = 'none';
      else
      e.style.display = 'block';
    }</script>";
  }
}
?>
<script src="https://misdew.com/inc/jquery.min.js"></script>
<script>
function showSpoiler(obj) {
  var spoiler_hidden = obj.parentNode.getElementsByTagName("div")[0];
  if(spoiler_hidden.style.display == "none") {
    spoiler_hidden.style.display = "";
    obj.innerHTML = "<i class=\"fa fa-eye-slash\" aria-hidden=\"true\"></i>";
  }
  else {
    spoiler_hidden.style.display = "none";
    obj.innerHTML = "<i class=\"fa fa-eye\" aria-hidden=\"true\"></i>";
  }
}
function upAlertBell() {
  $.get("/inc/alertbell-dark.php", function(d) {
    $("#alertbell").html(d);
    $("#alertbell_r").html(d);
  });
}
setInterval('upAlertBell()', 5000);
</script>
