{% from "macros/pagination.html" import pagination %}
<!DOCTYPE html>
<html lang="{{ LANG }}" dir="{{ DIR }}" class="production">
    <head>
        <meta charset="UTF-8" />
        <title>{% block page_title %}Crash Data for {{ product }}{% endblock %}</title>

        {% block site_css %}
            {% compress css %}
            <link href="{{ static('crashstats/css/screen.less') }}" type="text/less" rel="stylesheet">
            {% endcompress %}
            {{ browserid_css() }}
        {% endblock %}
	{% if GOOGLE_ANALYTICS_ID %}
        <script type="text/javascript">
          (function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
          (i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
          m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
          })(window,document,'script','//www.google-analytics.com/analytics.js','ga');

          ga('create', '{{ GOOGLE_ANALYTICS_ID }}', '{{ GOOGLE_ANALYTICS_DOMAIN }}');
          ga('send', 'pageview');
        </script>
	{% endif %}

    <script>
        // Track a page view in our analytics tracker. To be called by pages
        // that use AJAX requests to load content.
        {% if GOOGLE_ANALYTICS_ID %}
            function socorroTrackUse(url) {
                ga('send', 'pageview', url);
            }
        {% else %}
            function socorroTrackUse(url) {}
        {% endif %}
    </script>
    </head>
    <body>
    {{ browserid_info() }}
    <div class="page-header">
        <h1>
            <a href="/">
                <span class="icon"></span>
                <span class="title">Mozilla Crash Reports</span>
            </a>
        </h1>

        <form id="simple_search" method="get" action="{{ url('crashstats:query') }}">
            <input type="hidden" name="query_type" value="simple">
            <label for="q" class="visually-hidden">Search</label>
            <input type="text" id="q" name="query" placeholder="Find Crash ID or Signature">
            <input type="submit" class="hidden">
        </form>
    </div>

    <h1>Product Navigation</h1>

    <div class="version-nav">
        <input type="hidden" id="url_base" name="url_base" value="/products/{{ product }}" />
        <input type="hidden" id="url_site" name="url_site" value="/" />

	{% block product_nav_filter %}
        <ul class="filter">
            <li>
                <label for="products_select">Product:</label>
                <select id="products_select">
                {% for p in releases %}
                    <option value="{{ p }}" {% if p == product %}selected{% endif %}>{{ p }}</option>
                {% endfor %}
                </select>
            </li>
            <li class="version_select">
                <label for="product_version_select" class="visually-hidden">Select Version:</label>
                <select id="product_version_select" >
                    <optgroup label=" ">
                        <option value="Current Versions">Current Versions</option>
                    </optgroup>
                    <optgroup label=" ">
                    {% for release in releases[product] %}
                      {% if release.featured %}
                      <option value="{{ release.version }}" {% if release.version == version %}selected{% endif %}>{{ release.version }}</option>
                      {% endif %}
                    {% endfor  %}
                    </optgroup>
                    <optgroup label=" ">
                    {% for release in releases[product] %}
                      {% if not release.featured %}
                      <option value="{{ release.version }}" {% if release.version == version %}selected{% endif %}>{{ release.version }}</option>
                      {% endif %}
                    {% endfor  %}
                    </optgroup>
                </select>
            </li>
            <li>
                <label for="report_select">Report:</label>
                <select id="report_select">
                    <optgroup label=" ">
                        <option value="{{ url('crashstats:home', product) }}" {% if report == 'products' %}selected{% endif %}>Overview</option>
                    </optgroup>
                    <optgroup label=" ">
                        <option value="{{ url('crashstats:daily') }}?p={{ product }}" {% if report == 'daily' %}selected{% endif %}>Crashes per User</option>
                        <option value="{{ url('crashstats:topchangers', product) }}" {% if report == 'topchangers' %}selected{% endif %}>Top Changers</option>
                        <option value="{{ url('crashstats:topcrasher', product) }}" {% if report == 'topcrasher' %}selected{% endif %}>Top Crashers</option>
                        <option value="{{ url('crashstats:crash_trends', product)}}" {% if report == 'crash_trends' %}selected{% endif %}>Crash Trends</option>
                        <option value="{{ url('crashstats:gccrashes', product)}}" {% if report == 'gccrashes' %}selected{% endif %}>GC Crashes</option>
                        <option value="{{ url('crashstats:explosive', product) }}" {% if report == 'explosive' %}selected{% endif %}>Explosive Crashes</option>
                        {% if request.user.has_perm('crashstats.view_exploitability') %}
                        <option value="{{ url('crashstats:exploitable_crashes', product) }}" {% if report == 'exploitable' %}selected{% endif %}>Exploitable Crashes</option>
                        {% endif %}
                    </optgroup>
                </select>
            </li>
        </ul>
	{% endblock %}

        <div class="search">
            <a href="{{ url('crashstats:query') }}?product={{ product }}{% if version and version != 'ALL' %}&amp;version={{ product}}:{{ version }}{% endif %}#advanced">Advanced Search</a>
            {% if waffle.switch('supersearch-all') %}
            - <a href="{{ url('supersearch.search') }}">Super Search</a>
            {% endif %}
        </div>
    </div>


        {% if messages %}
            {% for message in messages %}
              <div class="message {% if message.tags %}{{ message.tags }}{% endif %}">
                {{ message }}
              </div>
            {% endfor %}
        {% endif %}

        {% block content %}{% endblock %}
        <div id="footer" class="page-footer">
            <div class="nav">
            <div class="about">
                <strong>Mozilla Crash Reports</strong> - Powered by <a href="https://github.com/mozilla/socorro">Socorro</a> - All dates are UTC
            </div>
            <ul>
                <li><a href="{{ url('crashstats:status') }}">Server Status</a></li>
                <li><a href="{{ url('api:documentation') }}">API Documentation</a></li>
                <li><a href="{{ url('tokens:home') }}">API Tokens</a></li>
                <li><a href="http://socorro.readthedocs.org/">Project Info</a></li>
                <li><a href="https://github.com/mozilla/socorro">Source Code</a></li>
                <li><a href="http://wiki.mozilla.org/Breakpad">Breakpad Wiki</a></li>
                <li><a href="http://www.mozilla.org/about/policies/privacy-policy.html">Privacy Policy</a></li>
            </ul>
        </div>


        <div class="login">
            <ul>
                <li>
                    {% if request.user.is_authenticated() %}
                      {{ request.user.email }}
                      |
                      <a href="{{ url('crashstats:your_crashes') }}">Your Crash Reports</a>
                      |
                      <a href="{{ url('crashstats:permissions') }}">Your Permissions</a>
                      |
                      <a href="{{ url('symbols:home') }}">Symbols</a>
                      {% if request.user.is_superuser %}
                      |
                      <a href="{{ url('manage:home') }}">Admin</a>
                      {% endif %}
                      |
                      {{ browserid_logout(text='Sign out') }}
                    {% else %}
                      {# the redirect_next function comes from the browserid context processor #}
		      {{ browserid_login(text='Sign in', color='dark', next=redirect_next()) }}
                    {% endif %}
                </li>
	    </ul>
        </div>
    </div>
    {% block site_js %}
    {% compress js %}
    <script src="{{ static('crashstats/js/jquery/jquery-2.0.3.min.js') }}"></script>
    <script src="{{ static('crashstats/js/jquery/plugins/jquery.cookies.2.2.0.js') }}"></script>
    <script src="{{ static('crashstats/js/socorro/nav.js') }}"></script>
    {% endcompress %}
    {{ browserid_js() }}
    {% endblock %}
  </body>
</html>
