{% load cms_tags sekizai_tags %}
{% load i18n %}

{% addtoblock "js" %}<script type="text/javascript" src="{{ STATIC_URL }}js/libs/underscore-1.3.1.min.js"></script>{% endaddtoblock %}
{% addtoblock "js" %}<script type="text/javascript" src="{{ STATIC_URL }}js/libs/json2.js"></script>{% endaddtoblock %}
{% addtoblock "js" %}<script type="text/javascript" src="{{ STATIC_URL }}js/libs/backbone-0.9.1.min.js"></script>{% endaddtoblock %}
{% addtoblock "js" %}<script type="text/javascript" src="{{ STATIC_URL }}js/saq.js"></script>{% endaddtoblock %}
{% addtoblock "js" %}
<script type="text/javascript">
    $(function () {
        SAQ.formNav = new SAQ.FormView({
            el: $('#saq-form-nav-{{ instance.pk }}')[0],
            nextUrl: {% if instance.next_page %}'{% page_url instance.next_page %}'{% else %}null{% endif %},
            endUrl: {% if instance.end_page %}'{% page_url instance.end_page %}'{% else %}null{% endif %},
            submitUrl: '{% url cms_saq_submit %}'
        });
    });
</script>
{% endaddtoblock %}

<div id="saq-form-nav-{{ instance.pk }}" class="saq-form-nav">
    {% if instance.prev_page %}
    <a class="saq-prev-button" href="{% page_url instance.prev_page %}">{% if instance.prev_page_label %}{% trans instance.prev_page_label %}{% else %}{% trans "Back" %}{% endif %}</a>
    {% endif %}
    {% if instance.next_page %}
    <a class="saq-next-button" href="#">{% if instance.next_page_label %}{% trans instance.next_page_label %}{% else %}{% trans "Next" %}{% endif %}</a>
    <span class="saq-ticker"></span>
    {% endif %}
    {% if met_end_condition and instance.end_page %}
    {% if instance.submission_set_tag and instance.end_submission_set %}
    <form class="saq-end-button-data">
        <input class="saq-end-button-data" hidden value="{{ instance.end_submission_set }}" name="end_submission_set"></input>
        <input class="saq-end-button-data" hidden value="{{ instance.submission_set_tag }}" name="submission_set_tag"></input>
    </form>
    {% endif %}
    <a class="saq-end-button" href="#">{% if instance.end_page_label %}{% trans instance.end_page_label %}{% else %}{% trans "Analysis" %}{% endif %}</a>
    {% endif %}
    {% csrf_token %}
</div>
{# vim:set filetype=htmldjango: #}
