<div class="listbox" id="course-list">
  <h2 class="list-h2">课程列表</h2>
  <div class="category">
    <span class="grayTxt ">排序：</span>
    <%= link_to "时间", {:controller => 'users', :action => 'user_courselist', :id =>@user, :type => @type,  :sort => @c_sort, :order => 1 }, :class => "sortTxt", :remote => true %>
    <% if @type.to_i == 1 %>
        <%= link_to "", {:controller => 'users', :action => 'user_courselist', :id =>@user, :type => @type,  :sort => @c_sort, :order => 1 }, :class => "#{@c_sort.to_i == 1 ? 'sortupbtn' : 'sortdownbtn'} ", :remote => true %>
    <% end %>
    <%= link_to "人气", {:controller => 'users', :action => 'user_courselist', :id =>@user, :type => @type,  :sort => @c_sort, :order => 2 }, :class => "sortTxt", :remote => true %>
    <% if @type.to_i  == 2 %>
        <%= link_to "", {:controller => 'users', :action => 'user_courselist', :id =>@user, :type => @type,  :sort => @c_sort, :order => 2 }, :class => "#{@c_sort.to_i == 1 ? 'sortupbtn' : 'sortdownbtn'} ", :remote => true %>
    <% end %>
    <div class="cl"></div>
  </div>

  <div class="bloglistbox">
    <% if @courses.any? %>
        <% @courses.each do |course|%>
            <ul class="list-file">
              <li>
                <span class="item_list fl"></span>
                <%= link_to course.name+"("+current_time_and_term_short(course)+")", course_path(course.id,:host=>Setting.host_course), :class => "list-title fl #{course_endTime_timeout?(course) ? 'c_dark_grey' : ''}",
                            :style => 'color:#000',:id => "show_course_#{course.id}", :target => '_blank', :title => (course.is_public? ? "公开课程：":"私有课程：")+course.name+"（"+current_time_and_term(course)+"）"%>
                <% teacher = User.where("id=?",course.tea_id).first%>
                <span class="fr grayTxt">
                    <%='主讲老师：'+(teacher.try(:realname) != " " ? teacher.lastname + teacher.firstname : teacher.try(:login)) %>
                  </span>
              </li>
              <div class="cl"></div>
                <li class="ml15">
                  <!--<span class="grayTxt">创建：<%#= format_time(course.created_at) %></span>-->
                  <span class="grayTxt">更新：<%= format_time(course.updated_on) %></span>
                  <span class="grayTxt">
                      学期:&nbsp;&nbsp;<span><%= current_time_and_term course %></span>
                  </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 %>
                  <p class="list-info fr grayTxt"><span><%= homework_num %></span><span>作业</span><span>|</span><span> <%= visable_attachemnts_incourse(course).count %></span><span>资源</span></p>
                </li>
              <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>
    <% else %>
        <p class="nodata"><%= l(:label_no_data) %></p>
    <% end %>
  </div>
</div>

<script type="text/javascript">
    //如果右边的列表比左边的高度低则将右边的高度设为与左边对齐
    $(function() {
        var leftHeight = $("#LSide").height() - $(".fontGrey5").height() - 20;
        var rightHeight = $(".homepageRight").height();
        if (rightHeight < leftHeight) {
            var diffHeight = leftHeight - rightHeight;
            var tmpHeight = $(".listbox").height() + diffHeight;
            $(".listbox").css("height", tmpHeight);
        }
    });
</script>