<script>
//    $(document).ready(function(){
////        var popupHeight = $(".referenceResourcesPopup").outerHeight(true);
////        $(".referenceResourcesPopup").css("marginTop",-popupHeight/2);
//
//
//        $(".resourcePopupClose").click(function(){
//            $(".referenceResourcesPopup").css("display","none");
//        });
//    });

    $(document).ready(function(){
        <% if type == "1" %>
        $("#my_resources_choose_homework").addClass("referenceTypeActive");
        $("#public_resources_choose_homework").removeClass("referenceTypeActive");
        <% else %>
        $(".referenceTypeBlock").click(function(){
            var activeBlock = $(".referenceResourceType").children(".referenceTypeActive");
            activeBlock.removeClass("referenceTypeActive");
            $(this).addClass("referenceTypeActive");
        });
        <% end %>
    });

// 点击 checkbox选中引用的资源的时候，保存该资源的id到session里去
function store_seleted_resource(dom){
    if(dom.attr('checked') == 'checked' ){
        $.get(
                        '<%= store_selected_resource_user_path %>'+'?save=y&res_id='+dom.val()
        )
    }else {
        $.get(
                        '<%= store_selected_resource_user_path %>'+'?save=n&res_id='+dom.val()
        )
    }
}
</script>
<!--<div class="referenceResourcesPopup">-->
  <div>
    <div class="referenceText">引用资源库资源</div>
  </div>
  <div>
    <div class="referenceResourceType fl">
      <a href="<%= user_ref_resource_search_user_path(User.current, :type => '6') %>" id="public_resources_choose_homework" class="referenceTypeBlock referenceTypeActive" data-remote="true">公共资源</a>
      <a href="<%= user_ref_resource_search_user_path(User.current, :type => '1') %>"  id="my_resources_choose_homework"  class="referenceTypeBlock" data-remote="true">我的资源</a>
    </div>
    <div class="fr">
      <!--<form class="referenceSearchBox">-->
      <%=  form_tag(user_ref_resource_search_user_path(user, :type => @type),:method => 'get',:remote=>'true',:class=>'referenceSearchBox') do%>
        <input type="text" name="search" placeholder="输入资源关键词进行搜索" class="searchReferencePopup" />
        <a href="javascript:void(0);" onclick="$(this).parent().submit();" class="referenceSearchIcon"></a>
      <% end %>
      <!--</form>-->
    </div>
    <div class="cl"></div>
  </div>
  <div class="resourcesListBanner">
    <ul class="resourcesListTab">
      <li class="resourcesListCheckbox fl"> </li>
      <li class="resourcesListName fl">资源名称</li>
      <li class="resourcesListSize fl">大小</li>
      <li class="resourcesListType fl">类别</li>
      <li class="resourcesListUploader fl">上传者</li>
      <li class="resourcesListTime fl">上传时间</li>
    </ul>
  </div>
  <%= form_tag(import_resources_to_homework_user_path(user),:method => 'post',:remote=>'true') do %>
    <input type="hidden" name="homework_id" value="<%= homework_id%>"/>
  <div style="height: 300px" id="user_ref_resources">
    <%= render :partial => 'homework_ref_resources_list' ,:locals=>{ :attachments => @attachments,:seleted_resources=>seleted_resources} %>
  </div>
  <div >
    <ul class="wlist" id="resource_ref_pages" style="margin-top: 5px;margin-right: 20px">
      <%= pagination_links_full @atta_pages, @atta_count, :per_page_links => false, :remote => @is_remote, :flag => true%>
    </ul>
  </div>
  <div>
    <a href="javascript:void(0);" onclick="$(this).parent().parent().submit();" class="db courseSendSubmit sendSourceText">确定</a>
    <a href="javascript:void(0);" onclick="hideResource();" class="db courseSendCancel sendSourceText">取消</a>
  </div>
  <div class="cl"></div>
  <% end %>
<!--</div>-->
