<!-- In-place attachment browser -->
<div class="content">
{% for Post in Content %}
  <form name="post_{{ Post.id }}$attachments" action="{{ Site.url(channel='$site/posts/attach') }}" method="post" accept-charset="utf-8" enctype="multipart/form-data">
    <table class="post_bounds" id="post_{{ Post.id }}$bounds">
      <script type="text/javascript">
        var Post{{ Post.id }} = new APost({{ Post.id }});
      </script>
      <tr>
        <td class="post_title" id="post_{{ Post.id }}$title">
          Attaching to &quot;{{ Post.title }}&quot;
        </td>
      </tr>
      <tr>
        <td class="post_attributes" id="post_{{ Post.id }}$searchInstructions">
          You may search for and attach an existing file, or choose to upload
          one or more new files to attach.<br />
          Attachments are limited in size to
          {{ Site.Posts.Attachments.sizeLimit|filesizeformat(true) }} or less.
        </td>
      </tr>
      <tr>
        <td class="post_attributes">
          <a href="javascript:void(0)" onclick="Post{{ Post.id }}.toggleDisplayOf('searchAttachments', this);" title="Hide this section"><code>-</code> Search for existing attachments</a>
          <div class="quote" id="post_{{ Post.id }}$searchAttachments">
            <table class="post_attributes">
              <tr>
                <td>
                  <input class="post_text_field_edited" type="text" name="attachmentKeywords" id="post_{{ Post.id }}$attachKeywords" title="Enter a value in order to find attachments" />
                </td>
                <td>
                  <input type="button" value="Search" onClick="Post{{ Post.id }}.searchAttachments()" />
                </td>
              </tr>
              <tr>
                <td class="post_content" id="post_{{ Post.id }}$searchResults">
                  <script type="text/javascript">
                    Post{{ Post.id }}.searchAttachments("{{ Site.url(channel='$site/posts/attach') }}", "view=post/attach/search&template=results.tpl.html&pid={{ Post.id }}");
                  </script>
                </td>
              </tr>
            </table>
          </div>
        </td>
      </tr>
      <tr>
        <td class="post_attributes">
          <a href="javascript:void(0)" onclick="Post{{ Post.id }}.toggleDisplayOf('uploadAttachments', this);" title="Show this section"><code>+</code> Upload new attachments</a>
          <div class="quote" id="post_{{ Post.id }}$uploadAttachments" style="visibility: hidden; display: none;">
            <table class="post_attributes" id="Post{{ Post.id }}$newAttachment">
              <tr>
                <td class="field_name">Attachment name:</td>
                <td><input class="post_text_field_edited" type="text" name="attachmentName" title="Enter a unique name for this attachment" /></td>
              </tr>
              <tr>
                <td class="field_name">Description:</td>
                <td><input class="post_text_field_edited" type="text" name="description" title="Enter a description for this attachment" /></td>
              </tr>
              <tr>
                <td class="field_name">File:</td>
                <td><input type="file" name="file" id="post_{{ Post.id }}$file" /></td>
              </tr>
            </table>
          </div>
        </td>
      </tr>
    </table>
  </form>
{% endfor %}
</div>

