<div id="Header" >
  <div class="logo fl" >
    <%=link_to image_tag("/images/logo.png",weight:"35px", height: "30px")%>
  </div>
  <div id="TopNav" class="fl">
    <%= render_dynamic_nav if User.current.logged? || !Setting.login_required? -%>
  </div>
  <div id="TopUser" class="fr">
    <div id="menu">
      <ul class="menu">
        <% if User.current.logged? %>
            <li>
              <%=link_to_user(User.current)%><!--<a href="javascript:void(0);" class="parent">用户名称</a>-->
              <ul>
                <% hidden_non_project = Setting.find_by_name("hidden_non_project")
                   visiable = hidden_non_project && hidden_non_project.value == "0"%>
                <% if @show_course == 1 && !visiable %>
                    <%# if User.current.user_extensions && [UserExtensions::TEACHER, UserExtensions::STUDENT].include?(User.current.user_extensions.identity) -%>
                    <% hasCourse=false %>
                    <% User.current.courses.each do |course| %>
                        <% if !course_endTime_timeout?(course) %>
                            <% hasCourse=true %>
                        <% end %>
                    <% end %>
                    <% if hasCourse %>
                        <li>
                          <a href="<%= url_for(:controller => 'users', :action => 'user_courses', :id=>User.current.id, :host=>Setting.host_user) %>" class="parent">我的课程</a>
                          <ul>
                            <%  User.current.courses.select("courses.*,(SELECT MAX(created_at)  FROM `course_activities` WHERE course_activities.course_id = courses.id) AS a").order("a desc").each do |course| %>
                                <% if !course_endTime_timeout?(course) %>
                                    <li title="<%=course.name%>"><a href="<%= url_for(:controller => 'courses', :action=>"show", :id=>course.id, :host=>Setting.host_course) %>"><%= course.name %></a>
                                <% end %>
                            <% end %>
                          </ul>
                        </li>
                    <% end %>
                    <%# end -%>
                <% end %>

                <% if User.current.projects.count>0 %>
                    <li>
                      <a href="<%= url_for(:controller => 'users', :action => 'user_projects', :id=>User.current.id, :host=>Setting.host_user) %>" class="parent">我的项目</a>
                      <ul>
                        <% User.current.projects.select("projects.*,(SELECT MAX(created_at)  FROM `forge_activities` WHERE forge_activities.project_id = projects.id) AS a").order("a desc").each do |project| %>
                            <li title="<%=project.name%>">
                              <a href="<%= url_for(:controller => 'projects', :action=>"show", :id=>project.id, :host=>Setting.host_name) %>">
                                <%=project.name%>
                              </a>
                            </li>
                        <% end %>
                      </ul>
                    </li>
                <% end %>
                <li><a href="<%= url_for(:controller => 'my', :action => 'account') %>">编辑资料</a></li>
              </ul>
            </li><!---level1 end--->
            <!--消息提醒-->
            <div class="navHomepageNews">
              <%= link_to image_tag("/images/news_icon_small.png" , :width => "21", :height => "24"), user_message_path(User.current) %>
              <% if User.current.count_new_message >0 %>
                  <div class="newsActive"><%= link_to "" , user_message_path(User.current) %></div>
              <% end %>
            </div>
            <!--消息提醒end-->
            <!--<li ><a href="javascript:void(0);">退出</a></li>-->
        <% end %>
      </ul>
      <%= render_menu :account_menu -%>
    </div>
  </div>
</div>
<div class="cl"></div>