<div id="add_edit_application_dialog" class="dialog">

  <div class="close">x</div>

  <h2>{% if application %}Edit{% else %}Add{% endif %} application</h2>

  <form method="" action="">

    {% if application %}
      <input type="hidden" name="application_id" value="{{ application.id }}">
    {% endif %}

    <div class="formrow">
      <label for="id_application_name">Name (required)</label>
      <input id="id_application_name" class="required" name="name" type="text"{% if application %} value="{{ application.name }}"{% endif %}>
    </div>

    <div class="formrow">
      <label for="id_application_url">URL (required)</label>
      <input id="id_application_url" class="required" name="url" type="text"{% if application %} value="{{ application.url }}"{% endif %}>
    </div>

    <div class="formrow">
      <label for="id_application_description">Description</label>
      <input id="id_application_description" name="description" type="text"{% if application %} value="{{ application.description }}"{% endif %}>
    </div>

    <div class="formrow">
      <label for="id_application_image">Icon file name</label>

      {% if icons %}
        <select id="id_application_image" name="image">
          <option value=""{% if application.image == '' %} selected="selected"{% endif %}></option>
          {% for icon in icons %}
            <option value="{{ icon }}"{% if application.image == icon %} selected="selected"{% endif %}>{{ icon }}</option>
          {% endfor %}
        </select>

      {% else %}
        <input id="id_application_image" type="text" name="image" value="{{ application.image }}">
      {% endif %}

    </div>
    <div class="formrow">
      <label for="id_application_position">Position</label>
      <input id="id_application_position" name="position" type="text"{% if application %} value="{{ application.position }}"{% endif %}>
    </div>

    <div class="choices">
      <div class="save add_application">{% if application %}Save{% else %}Add{% endif %} application</div>
      {% if application %}<div class="delete">Delete</div>{% endif %}
      <div class="cancel">Cancel</div>
    </div>

  </form>

</div>
