{% load i18n chimere_tags %}<!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">
<head>
    <title>{% block title %}Chimère{% endblock %}</title>
    <link rel="stylesheet" href="{{ STATIC_URL }}chimere/css/styles.css" />
    {% head_jquery %}
</head>
<body class='window'>
<div>
{% if thanks %}
<div class='warning'>
<p>{% trans "Thank you for your submission!"%}</p>
</div>
{% endif %}
<fieldset class='edit'>
<legend>{% trans "Upload a file" %}</legend>
{% if errors %}
<ul class="errorlist"><li>{{errors}}</li></ul>
{% endif %}
{% if category %}<h3>{{category}}</h3>{% endif %}
<div class="fieldWrapper">
{% if gpx_id %}
<script type="text/javascript"><!--
jQuery(document).ready(function() {
    jQuery.get("{% url chimere:process_route_file gpx_id %}", function(data) {
            var data = eval(data);
            var main_page = opener.document;
            jQuery(main_page).find("#id_route").val(data.wkt);
            jQuery(main_page).find("#id_associated_file_id").val(data.file_id);
            jQuery(main_page).find("#draw-or").hide();
            jQuery(main_page).find("#draw-toggle-off").hide();
            jQuery(main_page).find("#upload").hide();
            opener.toggleDraw();
            opener.initFeatureFromWkt(data.wkt);
            opener.toggleDrawOn();
            opener.focus();
            self.close();
        }).error(function (xhr, ajaxOptions, thrownError){
                    alert(xhr.responseText);
                }    );
});
// --></script>
{% else %}
<form enctype="multipart/form-data" method='post' action='.'>
{{ form }}
<p><input type='submit' value="{% trans 'Upload'%}"/></p>
</form>
{% endif %}
</div>
</div>
</body>
</html>

