<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=Edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <% project = get_project_spec(ENV['PROJECT_INDEX']) %>

    <title><%= project["title"] %></title>

    <!--  Icons for Mobile Devices, Favicon -->
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta name="mobile-web-app-capable" content="yes" />

    <%= csrf_meta_tags %>
    <%= stylesheet_link_tag "/css/" + project['theme'], :media => "all" %>

    <!-- Favicon use base if not specified -->
    <% if project['favicon'] != "" and project['theme'] != "default" %>
        <% fav_path = ENV['RAILS_RELATIVE_URL_ROOT'] + "themes/" + project['theme'] %>
    <% else %>
        <% fav_path = ENV['RAILS_RELATIVE_URL_ROOT'] + "images/" %>
    <% end %>
    <link rel="icon" href="<%= fav_path %>favicon-32x32.png" sizes="32x32">
    <link rel="icon" href="<%= fav_path %>favicon-57x57.png" sizes="57x57">
    <link rel="icon" href="<%= fav_path %>favicon-76x76.png" sizes="76x76">
    <link rel="icon" href="<%= fav_path %>favicon-96x96.png" sizes="96x96">
    <link rel="icon" href="<%= fav_path %>favicon-120x120.png" sizes="120x120">
    <link rel="icon" href="<%= fav_path %>favicon-128x128.png" sizes="128x128">
    <link rel="icon" href="<%= fav_path %>favicon-144x144.png" sizes="144x144">
    <link rel="icon" href="<%= fav_path %>favicon-152x152.png" sizes="152x152">
    <link rel="icon" href="<%= fav_path %>favicon-167x167.png" sizes="167x167">
    <link rel="icon" href="<%= fav_path %>favicon-180x180.png" sizes="180x180">
    <link rel="icon" href="<%= fav_path %>favicon-192x192.png" sizes="192x192">
    <link rel="icon" href="<%= fav_path %>favicon-195x195.png" sizes="195x195">
    <link rel="icon" href="<%= fav_path %>favicon-196x196.png" sizes="196x196">
    <link rel="icon" href="<%= fav_path %>favicon-228x228.png" sizes="228x228">

    <!-- Load vars for use in JS -->
    <%= render partial: 'layouts/javascriptvars' %>

    <%= stylesheet_link_tag "/css/viewer-datauri.css", :media => "all" %>
  </head>
  <body>
    <nav class="navbar navbar-inverse navbar-fixed-top">
      <div class="container-fluid">
        <!-- Brand and toggle get grouped for better mobile display -->
        <div class="navbar-header">
          <button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#bs-navbar-collapse-1">
            <span class="sr-only">Toggle navigation</span>
            <span class="icon-bar"></span>
            <span class="icon-bar"></span>
            <span class="icon-bar"></span>
          </button>
          <a class="navbar-brand" href="/">
            <% if project['logo'] != "" and project['theme'] != "default" %>
                <% logo = ENV['RAILS_RELATIVE_URL_ROOT'] + "themes/" + project['theme'] + "/" + project['logo'] %>
            <% else %>
                <% logo = ENV['RAILS_RELATIVE_URL_ROOT'] + "images/looking-glass-white.png" %>
            <% end %>
            <img src="<%= logo %>">
            <span class="title"><%= project['title'] %></span>
          </a>
        </div>
        <!-- Collect nav links, forms, and other content for toggling -->
        <div class="collapse navbar-collapse" id="bs-navbar-collapse-1">
	      <%= render partial: 'docs/index/search/searchbar/searchbar' %>
	      <%= render partial: 'layouts/linkmenu', locals: { project: project } %>
        </div>
      </div>
    </nav>
    <%= bootstrap_flash %>
    <div class="container-fluid">
      <div class="row">
	    <%= yield %>
      </div>
    </div>
    <%= javascript_include_tag "application" %>
    <% if params["controller"] != "catalyst" and params["controller"] != "entities" %>
    <div id="efm-button">
      <i class="icon-modified"></i>
      <div id="efm-menu">
        <h3>
          <i class="icon-modified"></i>
          Highlighter
        </h3>
        <a id="efm-unhighlightall" class="efm-need-highlight">Un-highlight all</a>
        <a id="efm-unhighlight" class="efm-need-highlight" >Un-highlight selection<span>u</span></a>
        <a id="efm-highlight">Highlight selection<span>h</span></a>
        <div id="efm-permalink" class="efm-need-highlight">
          <span>Link to highlights (on this page)</span>
          <input type="text" readonly="readonly" class="form-control" value="">
        </div>
        <% if is_editable?("show") %>
        <button id="button-save-highlights" class="btn btn-primary btn-small efm-need-highlight">
          Save Highlights
        </button>
        <% end %>
      </div>
    </div>
    <script src="<%= ENV['RAILS_RELATIVE_URL_ROOT']%>js/efatmarker.js"></script>
    <% end %>
    <% if ["docs", "search"].include? params["controller"] %>
    <script src="<%= ENV['RAILS_RELATIVE_URL_ROOT']%>js/search.js"></script>
    <% end %>
    <% if params["controller"] == "docs" and params["action"] == "show" %>
    <script src="<%= ENV['RAILS_RELATIVE_URL_ROOT']%>js/show.js"></script>
    <script src="<%= ENV['RAILS_RELATIVE_URL_ROOT']%>js/editor.js"></script>
    <% end %>
    <% if params["controller"] == "catalyst" %>
    <script src="<%= ENV['RAILS_RELATIVE_URL_ROOT']%>js/catalyst.js"></script>
    <% end %>
    <% if params["controller"] == "entities" %>
    <script src="<%= ENV['RAILS_RELATIVE_URL_ROOT']%>js/entities.js"></script>
    <% end %>
  </body>
</html>
