<% if !@post.is_deleted? %>
  <div>
    <% if !@post.can_be_seen_by?(@current_user) %>
      <p><%= t('.denied') %></p>
    <% elsif @post.image? %>
      <div id="note-container">
        <% @post.active_notes.each do |note| %>
          <div class="note-box" style="width: <%= note.width %>px; height: <%= note.height %>px; top: <%= note.y %>px; left: <%= note.x %>px;" id="note-box-<%= note.id %>">
            <div class="note-corner" id="note-corner-<%= note.id %>"></div>
          </div>
           <div class="note-body" id="note-body-<%= note.id %>" title="Click to edit"><%= sanitize note.formatted_body %></div>
        <% end %>
      </div>
      <% file_sample = @post.get_file_sample(@current_user) %>
      <%= image_tag(file_sample[:url],
                    :alt => @post.cached_tags,
                    :id => 'image',
                    :class => 'image js-notes-manager--toggle js-notes-manager--image',
                    :width => file_sample[:width],
                    :height => file_sample[:height],
                    :large_width => @post.get_file_jpeg(@current_user)[:width],
                    :large_height => @post.get_file_jpeg(@current_user)[:height]) %>
    <% elsif @post.flash? %>
      <object width="<%= @post.width %>" height="<%= @post.height %>">
        <param name="movie" value="<%= @post.file_url %>">
        <embed src="<%= @post.file_url %>" width="<%= @post.width %>" height="<%= @post.height %>" allowScriptAccess="never"></embed>
      </object>

      <p><%= link_to t('.save_flash'), @post.file_url %></p>
    <% else %>
      <h2><a href="<%= @post.file_url %>"><%= t('.download._') %></a></h2>
      <p><%= t('.download.info') %></p>
    <% end %>
  </div>
  <div style="margin-bottom: 1em;">
    <p id="note-count"></p>
    <script type="text/javascript">
      notesManager.post_id = <%= @post.id %>

      <% @post.active_notes.each do |note| %>
        notesManager.all.push(new Note(<%= note.id %>, false, '<%= h note.body.to_escaped_js %>'))
      <% end %>

      notesManager.updateNoteCount()
      notesManager.show()

      Moebooru.dragElement(jQuery('.image'));
    </script>
  </div>
<% end %>
