<div class="form-error" id="form-error" style="display:none"></div>

{% if saved %}
  <div class="form-success">{{ "info_saved"|lang }}</div>
{% endif %}

{{ bc(bc) }}

<table cellpadding="0" cellspacing="0" class="blog-write-table">
  <tr>
    <td id="form_first_cell">
      <form class="blog-write-form form-layout-v" name="postForm" action="{{ form_url }}" method="post">
        <div class="form-field-wrap clearfix">
          <div class="form-field-label">{{ "blog_write_form_title"|lang }}</div>
          <div class="form-field">
            <input class="form-field-input" type="text" name="title" value="{{ title }}" />
          </div>
        </div>

        <div class="form-field-wrap clearfix">
          <div class="form-field-label">{{ "blog_write_form_text"|lang }}</div>
          <div class="form-field">
            <textarea class="form-field-input" name="text" wrap="soft">{{ text }}</textarea><br/>
            <a class="blog-write-form-toggle-link" id="toggle_wrap" href="">{{ "blog_write_form_toggle_wrap"|lang }}</a>
          </div>
        </div>

        <div class="form-field-wrap clearfix">
          <table class="blog-write-options-table">
            <tr>
              <td>
                <div class="clearfix">
                  <div class="form-field-label">{{ "blog_post_options"|lang }}</div>
                  <div class="form-field">
                    <label for="visible_cb"><input type="checkbox" id="visible_cb" name="visible"{% if visible %} checked="checked"{% endif %}> {{ "blog_write_form_visible"|lang }}</label>
                  </div>
                </div>
              </td>
              <td>
                <div class="clearfix">
                  <div class="form-field-label">{{ "blog_text_options"|lang }}</div>
                  <div class="form-field">
                    <label for="toc_cb"><input type="checkbox" id="toc_cb" name="toc"{% if toc %} checked="checked"{% endif %}> {{ "blog_write_form_toc"|lang }}</label>
                    &nbsp;<select name="lang">
                      {% for l in langs %}
                        <option value="{{ l }}"{% if l == lang %} selected="selected"{% endif %}>{{ l }}</option>
                      {% endfor %}
                    </select>
                  </div>
                </div>
              </td>
              <td>
                <div class="clearfix">
                  <div class="form-field-label">{{ "blog_write_form_date"|lang }}</div>
                  <div class="form-field">
                    <input type="date" name="date"{% if date %} value="{{ date }}"{% endif %}>
                  </div>
                </div>
              </td>
            </tr>
            <tr>
              <td colspan="3">
                <div class="clearfix">
                  <table width="100%" cellspacing="0" cellpadding="0" style="table-layout: fixed; width: 100%; border-collapse: collapse">
                    <tr>
                      <td width="50%" style="width: 50% !important;">
                        <div class="form-field-label">{{ "blog_write_form_keywords"|lang }}</div>
                        <div class="form-field">
                          <input class="form-field-input" type="text" name="keywords" value="{{ keywords }}" />
                        </div>
                      </td>
                      <td width="50%" style="width: 50% !important;">
                        <div class="form-field-label">{{ "blog_write_form_source"|lang }}</div>
                        <div class="form-field">
                          <input class="form-field-input" type="text" name="source_url" value="{{ source_url }}" />
                        </div>
                      </td>
                    </tr>
                  </table>
                </div>
              </td>
            </tr>
            <tr>
              <td colspan="2">
                <div class="clearfix">
                  <div class="form-field-label">{{ "blog_write_form_short_name"|lang }}</div>
                  <div class="form-field">
                    <input class="form-field-input" type="text" name="{% if is_edit %}new_short_name{% else %}short_name{% endif %}" value="{{ short_name }}" />
                  </div>
                </div>
              </td>
              <td>
                <div class="form-field-label">&nbsp;</div>
                <div class="form-field">
                  <button type="submit" name="submit_btn"><b>{% if is_edit %}{{ "save"|lang }}{% else %}{{ "blog_write_form_submit_btn"|lang }}{% endif %}</b></button>
                </div>
              </td>
            </tr>
          </table>
        </div>
      </form>
      <div id="form_placeholder"></div>
    </td>
    <td>
      <div class="blog-write-form-preview post_text" id="preview_html"></div>
    </td>
  </tr>
</table>

{% js %}
cur.form = new AdminWriteEditForm({{ js_params|json_encode|raw }});
{% endjs %}