
<div class="por_header_top">
  <div class="por_header_con">
    <div class="pr fl">
        <% if User.current.logged? && User.current.admin_of_org?(@organization)%>
            <%=link_to image_tag(url_to_avatar(@organization),width:"51", height: "51", :id=>'nh_source_tx'), my_clear_user_avatar_temp_path(:organization => @organization.id), :remote => true%>
            <div class="homepageEditProfile undis">
              <%=link_to '', my_clear_user_avatar_temp_path(:organization => @organization.id), :remote => true, :class => 'homepageEditProfileIcon', :title => '点击编辑Logo' %>
            </div>
        <% else %>
            <%= image_tag(url_to_avatar(@organization), :width => "51", :height => "51", :alt => "组织logo") %>
        <% end %>
    </div>
    <%#= image_tag(url_to_avatar(@organization), width:"51", height: "51", :id => 'nh_user_tx', :class => "por_logo fl mt1", :target => "_blank") %>
    <% if User.current.logged? %>
        <div class="navHomepageProfile" id="navHomepageProfile">
          <ul>
            <li class="homepageProfileMenuIcon fr mt5 " id="homepageProfileMenuIcon">
              <%= link_to "<div class='user-img' id='user_avatar'>#{image_tag(url_to_avatar(User.current), :width =>"40", :height => "40", :class => "portraitRadius",:alt=>"头像", :id => "nh_user_logo")}</div>".html_safe, user_url_in_org(User.current.id) %>
              <ul class="topnav_login_list none sn-f12" id="topnav_login_list" style="text-align:left;">
                <li><%= link_to "修改资料", my_account_path, :class => "menuGrey"%></li>
                <li><%= link_to "我的组织", user_organizations_user_path(:id => User.current.id), :class => "menuGrey"%></li>
                <li><%= link_to "新建组织", new_organization_path, :class => "menuGrey"%></li>
                <li><%= link_to "退出", logout_url_without_domain, :class => "menuGrey", :method => "post"%></li>
              </ul>
            </li>
          </ul>
        </div>
    <% else %>
        <ul class="por_login fr">
          <li><a href="<%= signin_url_without_domain %>" target="_blank" class=" ">登录</a></li>
          <li><a href="<%= register_url_without_domain %>" target="_blank" class=" ">注册</a></li>
        </ul>
    <% end %>
    <!--<div class="por_search fr">-->
      <!--<input type="text" class="pro_input_search fl" value="00000" />-->
      <!--<a href="javascript:void(0);"  class="por_search_btn fl"></a>-->
    <!--</div>-->
  </div>
</div>
<div class="cl"></div>
<div class="por_nav"   >
  <ul >
    <% subfield_content.each do |field| %>
        <% if is_default_field?(field) %>
            <% case field.name %>
            <% when 'activity' %>
                <li style="display:<%= field.hide == 0 ? 'block':'none' %>;">
                  <%= link_to "首页", organization_path(@organization), :class => "por_index_act" %>
                </li>
            <% when 'course' %>
            <% when 'project' %>
            <% end %>

        <% else %>
            <% if field.field_type == "Post" && field.hide == 0 %>
                <li>
                  <% if !field.subfield_subdomain_dir.nil? %> <!--讨论帖子-->
                      <% if !request.local? and Secdomain.where("sub_type=2 and pid=?", @organization.id).count > 0 and Secdomain.where("sub_type=2 and pid=?", @organization.id).map(&:subname).include?(request.subdomain) %>
                          <%= link_to field.name, show_subfield_without_id_path(:sub_dir_name => field.subfield_subdomain_dir.name), :class => "sn-link-white", :target => "_blank" %>
                      <% else %>
                          <%= link_to field.name, show_org_subfield_organization_path(:id => @organization.id, :sub_dir_name => field.subfield_subdomain_dir.name), :class => "sn-link-white", :target => "_blank" %>
                      <% end %>
                  <% else %>
                      <%= link_to field.name, organization_path(@organization, :org_subfield_id => field.id), :class => "sn-link-white", :target => "_blank" %>
                  <% end %>
                </li>
                <!--二级目录-->
                <div class="sn-row sn-subnav-position sn-grey-opacity" style="display:none;">
                  <ul class="sn-sub-nav" style="display:<%= if_hidden_subdomain( field) ? 'block':'none' %>;">
                    <% field.sub_domains.each do |subdomain| %>
                        <li><%=link_to subdomain.name, org_subfield_sub_domain_sub_document_comments_path(subdomain, :org_subfield_id => field.id), :class => "sn-link-grey" %></li>
                        <li class="sn-subnav-slice">|</li>
                    <% end %>
                  </ul>
                </div>
            <% elsif field.field_type == "Comptec" %>
                <li>
                  <%= link_to "#{field.name}", teachers_organization_path(@organization, :org_subfield_id => field.id, :type => "#{User.current.admin? ? "" : "famous"}"), :class => "sn-link-white", :target => "_blank" %>
                </li>
            <% elsif field.field_type == "Compstu" %>
                <li>
                  <%= link_to "#{field.name}", students_organization_path(@organization, :org_subfield_id => field.id, :type => "#{User.current.admin? ? "" : "famous"}"), :class => "sn-link-white", :target => "_blank" %>
                </li>
            <% elsif field.field_type == "Comppro" %>
                <li>
                  <%= link_to "#{field.name}", projects_organization_path(@organization, :org_subfield_id => field.id, :type => "#{User.current.admin? ? "" : "famous"}"), :class => "sn-link-white", :target => "_blank" %>
                </li>
            <% elsif field.field_type == "Compcou" %>
                <li>
                  <%= link_to "#{field.name}", courses_organization_path(@organization, :org_subfield_id => field.id, :type => "#{User.current.admin? ? "" : "famous"}"), :class => "sn-link-white", :target => "_blank" %>
                </li>
            <% elsif field.field_type == "Compact" %>
                <li>
                  <%= link_to "#{field.name}", acts_organization_path(@organization, :org_subfield_id => field.id), :class => "sn-link-white", :target => "_blank" %>
                </li>
            <% elsif field.field_type == "Resource" && field.hide == 0 %>
                <li>
                  <%= link_to field.name, org_subfield_files_path(field), :class => "sn-link-white", :target => "_blank" %>
                </li>
            <% end %>
        <% end %>
    <% end %>
  <% if User.current.admin_of_org?(@organization) %>
      <a href="<%= setting_organization_path(@organization) %>" class="link-black fr por_edit_index" target="_blank">配置</a>
  <% end %>
  </ul>

  <div class="cl"></div>
</div><!--por_nav end-->


<script type="text/javascript">
    $("#navHomepageProfile").mouseenter(function(){
        $("#homepageProfileMenuIcon").addClass("homepageProfileMenuIconhover");
        $("#topnav_login_list").show();
    });
    $("#navHomepageProfile").mouseleave(function(){
        $("#homepageProfileMenuIcon").removeClass("homepageProfileMenuIconhover");
        $("#topnav_login_list").hide();
    });
    function signout(){
        $.post(
                '<%= signout_path%>',
                {}
        );
    }
</script>