<div class="resources mt10" id="organization_document_<%= document.id %>">
  <div class="homepagePostBrief">
    <div class="homepagePostPortrait">
      <%= link_to image_tag(url_to_avatar(User.find(document.creator_id)), :width => 45, :heigth => 45), user_url_in_org(document.creator_id) %>
      <%= render :partial => 'users/show_detail_info', :locals => {:user => User.find(document.creator_id)} %>
    </div>
    <div class="homepagePostDes">
      <div class="homepagePostTo">
        <%= link_to document.creator.show_name, user_url_in_org(document.creator.id), :class => "newsBlue mr15" %>
        TO&nbsp;&nbsp;<%= link_to document.organization.name, organization_path(document.organization), :class => "newsBlue" %>
        |
            <span style="color:#269ac9;"><%= document.org_subfield_id.nil? ? "组织文章" :"#{OrgSubfield.find(document.org_subfield_id).name}" %></span>
        <% if document.organization.home_id == document.id %>
            <span class="red_homework_btn_cir ml5">已设为首页</span>
        <% end %>
      </div>
      <div class="homepagePostTitle postGrey"><%= link_to document.title, org_document_comment_path(:id => document.id, :organization_id => document.organization.id) %></div>
      <div class="homepagePostDate fl">
        发布时间：<%= format_activity_day(document.created_at) %> <%= format_time(document.created_at, false) %>
      </div>
      <div class="homepagePostDate fl ml15">
        更新时间：<%= format_time(OrgActivity.where("org_act_type='#{document.class}' and org_act_id =#{document.id}").first.updated_at) %>
      </div>
      <div class="cl"></div>
      <% unless document.content.blank? %>
          <%=render :partial =>"users/intro_content", :locals=>{:user_activity_id =>document.id, :content=>document.content} %>
      <% end %>
      <div class="cl"></div>
      <div id="intro_content_show_<%= document.id%>" class="fr" style="display:none;"><a href="javascript:void(0);" class="linkBlue">[展开]</a></div>
      <div id="intro_content_hide_<%= document.id%>" class="fr" style="display:none;"><a href="javascript:void(0);" class="linkBlue">[收起]</a></div>
      <div class="cl"></div>
      <div class="mt10" style="font-weight:normal;">
        <%= render :partial=>"attachments/activity_attach", :locals=>{:activity => document} %>
      </div>
      <!--    <%# if defined?(home_id) %>
        <div style="float:right;">最后编辑：<%#= User.find() %></div>
    <%# end %>-->
      <% if User.current.admin? || User.current.admin_of_org?(Organization.find(document.organization_id)) || User.current.id == document.creator_id %>
          <div class="homepagePostSetting">
            <ul>
              <li class="homepagePostSettingIcon">
                <ul class="homepagePostSettiongText">
                  <li>
                    <% if document.organization.home_id == document.id %>
                        <%= form_for('new_form', :url => {:controller => 'organizations', :action => 'cancel_homepage', :id => document.organization_id, :home_id => document.id}, :method => "put", :remote => true) do |f| %>
                            <a href="javascript:void(0);" class="postOptionLink" onclick="$(this).parent().submit();">取消首页</a>
                        <% end %>
                    <% else %>
                        <%= form_for('new_form', :url => {:controller => 'organizations', :action => 'set_homepage', :id => document.organization_id, :home_id => document.id, :show_homepage => 1}, :method => "put", :remote => true) do |f| %>
                            <a href="javascript:void(0);" class="postOptionLink" onclick="$(this).parent().submit();">设为首页</a>
                        <% end %>
                    <% end %>
                  </li>
                  <li>
                    <%= link_to "编辑文章", edit_org_document_comment_path(:id => document.id, :organization_id => document.organization_id, :flag => flag, :org_subfield_id => params[:org_subfield_id] ), :class => "postOptionLink" %>
                  </li>
                  <li>
                    <%= link_to "删除文章", org_document_comment_path(:id => document.id, :organization_id => document.organization_id), :method => 'delete',
                                :data => {:confirm => l(:text_are_you_sure)},
                                :remote => true, :class => 'postOptionLink' %>
                  </li>
                </ul>
              </li>
            </ul>
          </div>
          <div class="cl"></div>
      <% end %>
    </div>
  </div>
  <% all_comments = []%>
  <% all_replies = get_all_children(all_comments, document) %>
  <% count = all_replies.count %>

  <div class="homepagePostReply fl" style="background-color: #f1f1f1;" id="<%= document.id %>">
    <%= render :partial => 'users/reply_banner', :locals => {:count => count, :activity => document, :user_activity_id => act.id} %>

    <% comments = all_replies[0..2] %>
    <% if count > 0 %>
        <div class="" id="reply_div_<%= act.id %>">
          <%= render :partial => 'users/message_replies', :locals => {:comments => comments, :user_activity_id => act.id, :type => 'OrgDocumentComment', :activity_id =>document.id}%>
        </div>
    <% end %>

    <div class="homepagePostReplyContainer borderBottomNone minHeight48">
      <div class="homepagePostReplyPortrait mr15 imageFuzzy" id="reply_image_<%= act.id %>">
        <%= link_to image_tag(url_to_avatar(User.current), :width => "33", :height => "33", :alt => "用户头像"), user_url_in_org(User.current.id) %>
      </div>
      <div class="homepagePostReplyInputContainer">
        <% if User.current.logged? %>
            <div nhname='new_message_<%= act.id %>' style="display:none;">
              <%= form_for('new_form', :url => add_reply_org_document_comment_path(:id => document.id, :act_id => act.id, :flag => flag), :method => "post", :remote => true) do |f| %>
                  <div nhname='toolbar_container_<%= act.id %>'></div>
                  <textarea placeholder="有问题或建议，请直接给我留言吧！" style="display: none" nhname='new_message_textarea_<%= act.id %>' name="org_content"></textarea>
                  <a id="new_message_submit_btn_<%= act.id %>" href="javascript:void(0)" class="blue_n_btn fr" style="display:none;margin-top:6px;line-height:18px;">发送</a>

                  <div class="cl"></div>
                  <p nhname='contentmsg_<%= act.id %>'></p>
              <% end %>
            </div>
        <% else %>
            <%= render :partial => "users/show_unlogged" %>
        <% end %>
      </div>
      <div class="cl"></div>
    </div>
    <div class="cl"></div>
  </div>
</div>

<script type="text/javascript">
    $(function(){
        user_card_show_hide();
    });
</script>