{% extends "base.html" %}

{% load currency_filters %}
{% load promotion_tags %}
{% load category_tags %}

{% block layout %}
    <div id="container">
        <div id="header">
            <p><a href="{% url promotions:home %}">Oscar // Flexible e-commerce for Django</a></p>

            <form method="get" action="{% url search:search %}">
                {{ search_form.as_p }}
                <input type="submit" value="Go!" />
            </form>

            {% if user.is_authenticated %}
                <a href="{% url customer:summary %}">Profile</a>
                <a href="{% url customer:logout %}">Logout</a>
            {% else %}
                <a href="{% url customer:login %}">Login</a>
            {% endif %}

            Basket total: {{ basket.total_incl_tax|currency }}
            <a href="{% url basket:summary %}">View basket</a>

			{% category_tree depth=2 as categories %}

			{% if categories %}
			<ul>
			{% for category in categories %}
			<li><a href="{{ category.0.get_absolute_url }}">{{ category.0.name }}</a>
				{% if category.1 %}
				<ul>
				{% for subcategory in category.1 %}
				<li><a href="{{ subcategory.0.get_absolute_url }}">{{ subcategory.0.name }}</a>
				{% endfor %}
				</ul>
				{% endif %}
			</li>
			{% endfor %}
			</ul>
			{% endif %}

            {% block header %}
            {% endblock %}
        </div>
        <div id="content">

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

            <div id="promotions">
                {% for promotion in promotions_page %}
                    {% render_promotion promotion %}
                {% endfor %}
            </div>

            {% block content %}{% endblock %}
        </div>
        <div id="footer">{% block footer %}{% endblock %}</div>
    </div>
{% endblock %}
