{% load static %}
{% load adv_cache %}

<!DOCTYPE html>
<html lang="en">
  <head>
    <title>{% block title %}{% endblock %} - {{SITE_META.site_name}}</title>

    {% include 'partials/seo.html' %}
    {% include 'partials/icons.html' %}

    <link href="https://maxcdn.bootstrapcdn.com/font-awesome/4.4.0/css/font-awesome.min.css" rel="stylesheet">
    <link href='https://fonts.googleapis.com/css?family=Open+Sans:400,700,300italic' rel='stylesheet' type='text/css'>
    <link rel="stylesheet" type="text/css" href="{% static 'css/bootstrap.journal.min.css' %}" />
    <link rel="stylesheet" type="text/css" href="{% static 'css/dataTables.bootstrap.css' %}" />
    <link rel="stylesheet" type="text/css" href="{% static 'css/custom.css' %}" />
    <link rel="stylesheet" type="text/css" href="{% static 'css/city_custom.css' %}" />

    {% block extra_css %}{% endblock %}

  </head>
  <body>

    {% cache 600 nav_wrapper 'nav' %}

      <nav class="navbar navbar-default navbar-fixed-top">
        <div class="container-fluid container-fluid-nav">
          <div id="nav-title">
            <a class="navbar-brand" href="/">
              <img id="logo" src="{% static IMAGES.logo %}"></img>
              <span id="logo-text">{{ CITY_NAME_SHORT }} Councilmatic</span>
            </a>
          </div>
          <ul id="nav-items">
            <li>
              <a href="{% url 'about' %}">About</a>
            </li>
            <li>
              <a href='{% url 'council_members' %}'>{{ CITY_VOCAB.COUNCIL_MEMBERS }}</a>
            </li>
            <li>
              <a href='{% url 'committees' %}'>Committees</a>
            </li>
            <li>
              <a href='{% url 'events' %}'>{{ CITY_VOCAB.EVENTS }}</a>
            </li>
            <li>
              <a href="{% url 'search' %}">Legislation</a>
            </li>

            {% nocache %}

              {% if USING_NOTIFICATIONS and request.user.is_authenticated %}
                <li>
                  <div class="dropdown">
                    <a class="dropdown-toggle" data-toggle="dropdown" title="Account">
                      <i class="fa fa-user" aria-hidden="true"></i>
                      <span class="caret"></span>
                    </a>
                    <ul class="dropdown-menu dropdown-menu-right">
                      <li class="non-link text-muted small">{{request.user.email}}</li>
                      <li role="separator" class="divider"></li>
                      <li>
                        <a href="/account/subscriptions">
                          <i class="fa fa-bullhorn fa-fw" aria-hidden="true"></i>
                          Manage Alerts
                        </a>
                      </li>
                      <li>
                        <a href="/logout/">
                          <i class="fa fa-sign-out fa-fw" aria-hidden="true"></i>
                          Sign out
                        </a>
                      </li>
                    </ul>
                  </div>
                </li>
              {% endif %}

              {% if USING_NOTIFICATIONS and not request.user.is_authenticated %}
                <li>
                  <a href="/login/" title="Sign in">
                    <i class="fa fa-sign-in" aria-hidden="true"></i>
                  </a>
                </li>
              {% endif %}

            {% endnocache %}
          </ul>
        </div>
      </nav>

      {% if messages %}
        <div class="container">
          <div class="row">
            <div class="col-sm-12">
              {% for message in messages %}
                <div {% if message.tags %}class="alert-signup alert alert-info {{ message.tags }}"{% endif %} role="alert">
                  {{ message }}
                </div>
              {% endfor %}
            </div>
          </div>
        </div>
      {% endif %}

    {% endcache %}

    {% block full_content %}
    {% endblock %}

    <div class="container-fluid footer">
      <div class='col-sm-12'>
        <div class='clearfix'></div>

        {% if FOOTER_CREDITS %}
          <p>Part of the <a href='https://www.councilmatic.org' target="_blank">Councilmatic family</a>. Proudly brought to you by</p>

          {% for credit in FOOTER_CREDITS %}

            <a href='{{credit.url}}' title='{{credit.name}}' target="_blank"><img src='/static/images/{{credit.image}}' /></a>

          {% endfor %}
        {% else %}
          <p>Part of the <a href='https://www.councilmatic.org' target="_blank">Councilmatic family</a>.</p>
        {% endif %}

      </div>
    </div>

    <script src="{% static 'js/lib/jquery-1.10.1.min.js' %}"></script>
    <script src="{% static 'js/lib/bootstrap.min.js' %}"></script>
    {% if USING_NOTIFICATIONS %}
      <script>
        var alertMsg = '<div class="alert alert-info" role="alert">' +
        '<strong>Want to subscribe?</strong> Please <a href="{% url 'notifications_login' %}?next={{ request.get_full_path }}">login</a> or <a href="{% url 'notifications_signup' %}?next={{ request.get_full_path }}">create</a> a user account.' +
        '<button type="button" class="close" data-dismiss="alert" aria-label="Close"><span aria-hidden="true">&times;</span></button></div>'
      </script>
    {% endif %}
    <script type="text/javascript">
      function getCookie(name) {
        var cookieValue = null;
        if (document.cookie && document.cookie !== '') {
          var cookies = document.cookie.split(';');
          for (var i = 0; i < cookies.length; i++) {
            var cookie = jQuery.trim(cookies[i]);
            // Does this cookie string begin with the name we want?
            if (cookie.substring(0, name.length + 1) === (name + '=')) {
              cookieValue = decodeURIComponent(cookie.substring(name.length + 1));
              break;
            }
          }
        }
        return cookieValue;
      }
      var csrftoken = getCookie('csrftoken');
      function csrfSafeMethod(method) {
        // these HTTP methods do not require CSRF protection
        return (/^(GET|HEAD|OPTIONS|TRACE)$/.test(method));
      }
      $.ajaxSetup({
        beforeSend: function(xhr, settings) {
          if (!csrfSafeMethod(settings.type) && !this.crossDomain) {
            xhr.setRequestHeader("X-CSRFToken", csrftoken);
          }
        }
      });
    </script>

    {% block extra_js %}{% endblock %}

    <script>
      var analyticsTrackingCode = '{{ANALYTICS_TRACKING_CODE}}';
    </script>
    <script src="{% static 'js/lib/analytics_lib.js' %}"></script>
    <script>
      $(function () {
        $('[data-toggle="tooltip"]').tooltip()
      });
    </script>

  </body>
</html>
