<!DOCTYPE html>
<!--[if lt IE 7]> <html class="no-js lt-ie9 lt-ie8 lt-ie7" lang="en"> <![endif]-->
<!--[if IE 7]>    <html class="no-js lt-ie9 lt-ie8" lang="en"> <![endif]-->
<!--[if IE 8]>    <html class="no-js lt-ie9" lang="en"> <![endif]-->
<!--[if gt IE 8]><!--> <html class="no-js" lang="en"> <!--<![endif]-->
    <head>
        <base href="{{ request.route_url('home') }}" />
        <meta http-equiv="Content-Type" content="text/html; 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, maximum-scale=1.0, user-scalable=no;" />
        {% block meta %}{% endblock %}
        <title>{% if title %}{{ title }} - {% endif %}Workout With Friends</title>
        <link rel="shortcut icon" type="image/x-icon" href="{{ request.static_url('wowf:static/favicon.ico') }}" />
        <link rel="stylesheet" type="text/css" href="{{ request.static_url('wowf:static/css/common.css') }}" />
        {% block styles %}{% endblock %}
        <script type="text/javascript" src="{{ request.static_url('wowf:static/js/libs/modernizr-2.5.3.min.js') }}"></script>
    </head>
    <body>
        <div id="top-wrapper" class="wrapper">
            <div id="header-wrapper" class="wrapper">
                <div id="header" class="container">
                    <a class="logo-box" title="workout with a purpose" href="{{ request.route_url('home') }}">
                        <span class="logo">WOWF</span>
                        <span class="tagline">Beta</span>
                    </a>
                    {% set notifications_count = request.user.count_unconfirmed_notifications() if request.user else 0 %}
                    <div class="dropdown">
                        <a class="toggle {{ 'alert' if notifications_count }}"></a>
                        <ul class="menu">
                            {% if not request.user %}
                                <li><a href="{{ request.route_url('user.login') }}" title="Log in">Log In</a></li>
                                <li><a href="{{ request.route_url('user.register') }}" title="Register">Register</a></li>
                            {% else %}
                                <li>
                                    <form class="search-bar" action="{{ request.route_url('search.users') }}" method="get">
                                        <input type="text" name="q" placeholder="Search" autocomplete="off" />
                                        <input type="submit" value="Search" />
                                    </form>
                                </li>
                                <li><a {{ dict(class='alert')|xmlattr if notifications_count }} href="{{ request.route_url('user.notifications.unconfirmed') }}" title="Notifications">{{ notifications_count | pluralize('Notification', 'Notifications') }}</a></li>
                                <li><a href="{{ request.route_url('challenge.create.speed') }}" title="New Challenge">New Challenge</a></li>
                                <li><a href="{{ request.route_url('account.profile') }}" title="Settings">Settings</a></li>
                                <li><a href="{{ request.route_url('user.logout') }}" title="Logout">Logout</a></li>
                            {% endif %}
                        </ul>
                    </div>
                </div>
            </div>
            <div id="body-wrapper" class="wrapper">
                <div id="body" class="container">
                    {% for type in (g.ERROR, g.WARNING, g.NOTICE, g.SUCCESS) %}
                        {% for message in request.session.pop_flash(type) %}
                            <p class="{{ type }} notification" title="click to close">{{ message }}</p>
                        {% endfor %}
                    {% endfor %}
                    {% block body %}{% endblock %}
                </div>
            </div>
        </div>
        <div id="footer-wrapper" class="wrapper">
            <div id="footer" class="container">
                <ul class="metadata">
                    <li class="copyright">&copy; 2012 Workout With Friends</li>
                    {% if request.user %}
                        <li><a href="{{ request.route_url('user.invite') }}">Invite Friends</a></li>
                    {% endif %}
                </ul>
            </div>
        </div>
        <script type="text/javascript" src="//ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js"></script>
        <script type="text/javascript">window.jQuery || document.write('<script src="{{ request.static_url('wowf:static/js/libs/jquery-1.7.1.min.js') }}"><\/script>')</script>
        <script type="text/javascript" src="{{ request.static_url('wowf:static/js/libs/response.0.6.0.min.js') }}"></script>
        <script type="text/javascript" src="{{ request.static_url('wowf:static/js/plugins.js') }}"></script>
        <script type="text/javascript" src="{{ request.static_url('wowf:static/js/common.js') }}"></script>
        {% block scripts %}{% endblock %}
    </body>
</html>