<% if @courses.any? %>
    <div class="sy_category">
      <span class="sy_cgrey ">排序：</span>
      <%= link_to "时间", {:controller => 'syllabuses', :action => 'syllabus_courselist', :id =>@syllabus, :type => @type,  :sort => @c_sort, :order => 1 }, :class => "sy_cgrey fl", :remote => true %>
      <% if @type.to_i == 1 %>
          <%= link_to "", {:controller => 'syllabuses', :action => 'syllabus_courselist', :id =>@syllabus, :type => @type,  :sort => @c_sort, :order => 1 }, :class => "#{@c_sort.to_i == 1 ? 'sortupbtn' : 'sortdownbtn'} mt15 fl", :remote => true %>
      <% end %>
      <%= link_to "人气", {:controller => 'syllabuses', :action => 'syllabus_courselist', :id =>@syllabus, :type => @type,  :sort => @c_sort, :order => 2 }, :class => "sy_cgrey fl #{@type == 1 ? '' : 'ml10'}", :remote => true %>
      <% if @type.to_i  == 2 %>
          <%= link_to "", {:controller => 'syllabuses', :action => 'syllabus_courselist', :id =>@syllabus, :type => @type,  :sort => @c_sort, :order => 2 }, :class => "#{@c_sort.to_i == 1 ? 'sortupbtn' : 'sortdownbtn'} mt15 fl", :remote => true %>
      <% end %>
      <% if @syllabus.syllabus_members.map{|sm| sm.user_id}.include?(User.current.id) %>
          <%= link_to "新建班级", new_course_path(:host=> Setting.host_course, :syllabus_id => @syllabus.id), :class => "sy_btn_green fr mt10 mr15", :target => '_blank'%>
      <% end %>
      <div class="cl"></div>
    </div>
    <div class="sy_classbox">
      <% @courses.each do |course| %>
          <ul class="sy_classlist">
            <div class="fl">
              <% if course.is_public == 0 && !User.current.member_of_course?(course) && !User.current.admin? %>
                  <h3 class="sy_classlist_title fl">
                    <%= link_to @syllabus.title, syllabus_path(@syllabus.id), :style => 'color:#000', :target => '_blank' %>
                    <font class="fb"> · </font>
                    <%=course.name %>（<%=current_time_and_term_short(course) %>）
                  </h3>
              <% else %>
                <h3 class="sy_classlist_title fl">
                  <%= link_to @syllabus.title, syllabus_path(@syllabus.id), :style => 'color:#000', :target => '_blank' %>
                  <font class="fb"> · </font>
                  <%= link_to course.name+"("+current_time_and_term_short(course)+")", course_path(course.id,:host=>Setting.host_course),
                              :style => 'color:#000',:id => "show_course_#{course.id}", :target => '_blank', :title => (course.is_public? ? "公开班级：":"私有班级：")+course.name+"（"+current_time_and_term(course)+"）"%>
                </h3>
              <% end %>
              <span class="<%= course.is_public == 0 ? 'hw_icon_private' : 'hw_icon_open' %> fl mr20 mt3"></span>
              <div class="cl"></div>
              <p class="sy_cgrey">
                <span class=" mr15">创建老师：<%=link_to course.teacher.show_name, user_path(course.teacher), :class => 'sy_cblue' %></span>
                <% if User.current.admin? || User.current.allowed_to?(:as_teacher,course) %>
                    <% homework_num = course.homework_commons.count %>
                <% else %>
                    <% homework_num = course.homework_commons.where("publish_time <= '#{Date.today}'").count %>
                <% end %>
                <span class=" mr15">作业：
                  <% if course.is_public == 0 && !User.current.member_of_course?(course) %>
                    <%=homework_num %>
                  <% else %>
                    <%= link_to homework_num, homework_common_index_path(:course => course.id), :class => "sy_cblue",:target => '_blank'%>
                  <% end %>
                </span>
                <span class=" mr15">资源：
                  <% if course.is_public == 0 && !User.current.member_of_course?(course) %>
                    <%=visable_attachemnts_incourse(course).count %>
                  <% else %>
                    <%= link_to visable_attachemnts_incourse(course).count, course_files_path(course), :class => "sy_cblue",:target => '_blank'%>
                  <% end %>
                </span>
                <span class=" mr15">学期：<%= current_time_and_term course %></span>
                <span class=" mr15">更新时间：<%= format_date(course.updated_on) %></span>
              </p>
            </div>
            <% if User.current.member_of_course?(course) %>
                <%=link_to '进入班级', course_path(course), :class => 'btn_orange_big fr mt5', :target => '_blank' %>
            <% else %>
                <%= link_to "加入班级",join_private_courses_courses_path,:remote => true,:class => "btn_green_big fr mt5",:method => "post"%>
            <% end %>
            <div class="cl"></div>
          </ul>
      <% end %>
      <div>
        <ul class="wlist" id="pages" >
          <%= pagination_links_full @atta_pages, @atta_count, :per_page_links => false, :remote => @is_remote, :flag => true %>
        </ul>
        <div class="cl"></div>
      </div>
   </div>
<% else %>
    <div class="icons_tishi"><img src="/images/sy/icons_tan.png" width="110" height="110" alt="" ></div>
    <% if User.current.member_of_syl?(@syllabus) %>
        <p class="sy_tab_con_p">该课程还未创建班级，请
          <%= link_to "新建班级", new_course_path(:host=> Setting.host_course, :syllabus_id => @syllabus.id), :class => "sy_corange", :target => '_blank'%>
          ，谢谢啦！</p>
    <% else %>
        <p class="sy_tab_con_p">该课程还未创建班级，敬请期待！</p>
    <% end %>
<% end %>

<script type="text/javascript">
    //如果右边的列表比左边的高度低则将右边的高度设为与左边对齐
    $(function() {
        $(".sy_con_l").css("min-height",$(".sy_con_r").height());
    });
</script>