{% load i18n satchmo_category satchmo_google satchmo_util satchmo_currency satchmo_discounts app_plugins normalize_decimal %}
{% block doctype %}<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html
     PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
     "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
{% endblock %}
<head>
    {% block extra-head %}{% endblock %}
    {% block stylesheet %}<link rel="stylesheet" href="{{ media_url }}css/style.css" />{% endblock %}
    <title>{% block title %}{{ shop_name }}{% if pagetitle %}: {{ pagetitle }}{% endif %}{% endblock %}</title>
    {% plugin_point "page_head" %}
</head>
{% block body %}
<body{% if bodyid %} id="{{ bodyid }}"{% endif %}{% if bodyclass %} class="{{ bodyclass }}"{% endif %}>
    {% plugin_point "page_top" %}
    <div id="container">
	    <div id="top">
	        <h1>{{ shop_name }}</h1>
	    </div>

	    <div id="navbar">
	    <ul>
	    	{% block navbar %}Breadcrumbs here{% endblock %}
	   	</ul>
    </div>

    <div id="sidebar-secondary">
		{% block sidebar-secondary %}
		<div>
			{% satchmo_search_form %}
		</div>
		<div>
			{% block sidebar %}
			<h3>{% trans "Shop Categories" %}</h3>
			{% block sidebar-categories %}
			<div id="menu_container">
                {% if category.id %}
                    {% category_tree category.id %}
                {% else %}
                    {% if product.get_category %}
                        {% category_tree product.get_category.id %}
                    {% else %}
                        {% category_tree %}
                    {% endif %}
                {% endif %}
			</div>
			{% endblock sidebar-categories %}
			
			{% block sidebar-secondary-bottom %}
			{% plugin_point "sidebar_secondary_bottom" %}
			{% endblock %}
			{% endblock sidebar %}
		</div>
		{% endblock sidebar-secondary %}
	</div>

	<div id="sidebar-primary">{# rightnav #}
		{% block sidebar-primary %}
		<h3>{% trans "Quick Links" %}</h3>
		{% url satchmo_product_recently_added as recenturl %}
		{% if recenturl %}<a href="{{ recenturl }}">{% trans "Recently Added" %}</a>{% endif %}
		{% url satchmo_product_best_selling as popularurl %}
		{% if popularurl %}<br/><a href="{{ popularurl }}">{% trans "Best Sellers" %}</a>{% endif %}
		{% plugin_point "sidebar_links" %}

	    <h3>{% trans "Account Information" %}</h3>
	    {% if user.is_staff %}
		<a href="{% url admin:index %}" target="blank">{% trans "Admin" %}</a><br/>
		{% endif %}
	    {% if user.is_authenticated %}
		{% url satchmo_account_info as accounturl %}
        {% if accounturl %}<a href="{{ accounturl }}" target="blank">{% trans "Account Details" %}</a><br/>{% endif %}
        <a href="{{ logout_url }}?next={{request.path}}">{% trans "Log out" %}</a><br/>
	    {% else %}
        <a href="{{ login_url }}?next={{request.path}}">{% trans "Log in" %}</a><br/>
	    {% endif %}

		{% url satchmo_cart as carturl %}
	    {% if carturl %}<a href="{{ carturl }}">{% trans "Cart" %}</a>{% endif %}

	    {% if cart_count %}
        ({{ cart_count|normalize_decimal }}{% if cart.total %} - {{ cart|discount_cart_total:sale|currency }}{% endif %})<br/>
		{% url satchmo_checkout-step1 as checkouturl %}
        {% if checkouturl %}<a href="{{ checkouturl }}">{% trans "Check out" %}</a>{% endif %}
	    {% endif %}
	
		{% plugin_point "shop_sidebar_actions" %}
    
		{% url satchmo_contact as contact_url %}
	    {% if contact_url %}<p><a href="{{ contact_url }}">{% trans "Contact Us" %}</a></p>{% endif %}

		{% satchmo_language_selection_form %}

		{% block sidebar-primary-bottom %}
		{% plugin_point "shop_sidebar_primary" %}
		{% endblock %}
		{% endblock sidebar-primary %}
	</div>

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

	<div id="footer">
		{% block footer %}
		{% blocktrans %}Powered by <a href="http://www.satchmoproject.com">Satchmo</a>.{% endblocktrans %}
		{% endblock %}
	</div>

    </div>
	{% block page-close %}
    {% block google-tracker %}
    {% if shop.options.GOOGLE.ANALYTICS.value %}
        {% show_tracker is_secure %}
    {% endif %}
    {% endblock %}
	{% endblock %}
</body>
{% endblock %}
</html>
