{% load i18n pybb_tags %}

<script language="javascript" type="text/javascript">
function addtext() {
	var text = '{{ smile|safe }}';
	document.postform.body.value += text;
}
</script>

<form class="post-form" action="
    {% if forum %}
        {% url pybb:add_topic forum.pk %}
    {% else %}
        {% if topic %}
            {% url pybb:add_post topic.pk %}
        {% else %}
            {% url pybb:edit_post pk=object.pk %}
        {% endif %}
    {% endif %}" method="post" enctype="multipart/form-data" name="postform">
    {% csrf_token %}
       <fieldset>
            {{ form.as_p }}
            <div id='emoticons'>
                {% for smile, url in form.available_smiles.items %}
                    <a href='#' onClick='addtext();' title='{{ smile|safe }}'><img src='{{ STATIC_URL }}{{ form.smiles_prefix }}{{ url }}'></a>
                {% endfor %}
            </div>
            {% include "pybb/attachments_formset.html" %}
            <p class="submit">
                {% if PYBB_BUTTONS.submit %}
                    <input type='image' src="{{ STATIC_URL }}{{ PYBB_BUTTONS.submit }}" alt='{% trans "Submit" %}'>
                {% else %}
                   <input type="submit" value="{% trans 'Submit' %}" />
                {% endif %}
            </p>
    </fieldset>
</form>
