<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
  <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
  <title>新建作业</title>
  <%= stylesheet_link_tag  'css'%>
  <script type="text/javascript" language="javascript">
      function switchTab(ProTag){
          var display_index = 3 - ProTag;
          $("#tb_" + ProTag).attr("class","hovertab");
          $("#tb_" + display_index).attr("class","normaltab");
          $("#content" + ProTag).show();
          $("#content" + display_index).hide();
      }
      function submit_homework_form()
      {
          if(regexName()){$('#edit_homework_attach_<%= @homework.id%>').submit();}
      }
      function regexName()
      {
          var name = $("#homework_attach_name").val();

          if(name=="")
          {
              $("#homework_attach_name_span").text("名称不能为空");
              $("#homework_attach_name_span").css('color','#ff0000');
              return false;
          }
          else
          {
              $("#homework_attach_name_span").text("<%= l(:label_field_correct)%>");
              $("#homework_attach_name_span").css('color','#008000');
              return true;
          }
      }
  </script>
</head>

<body>
<div class="container"  id="content">
  <div class="Newwork">
    <div id="tb_" class="tb_">
      <ul>
        <li id="tb_1" class="hovertab" onclick="switchTab(1);this.blur();return false;" style="width: auto; padding:5px 10px 0;">
          修改作品
        </li>
        <li id="tb_2" class="normaltab" onclick="switchTab(2);this.blur();return false;">
          成员
        </li>
        <li class="N_top" style="width: 747px;">
          <%= link_to(l(:label_project_new), {:controller => 'projects',
                                              :action => 'new',
                                              :course => 0,
                                              :project_type => 0}) if User.current.allowed_to?(:add_project, nil, :global => true) %>
        </li>
      </ul>

    </div>
    <div id="content1">
      <div class="N_con">
        <%= form_for(@homework) do |f|%>
          <p>
            <label>
              <span class="c_red">*</span>
              &nbsp;&nbsp;作品名称&nbsp;&nbsp;&nbsp;&nbsp;：
            </label>
            <%= f.text_field :name, :required => true, :name => "homework_name", :class => "w430 bo", :maxlength => 254, :placeholder => "作品名称", :onkeyup => "regexName();"%>
            <span id="homework_attach_name_span"></span>
          </p>
          <p>
            <label style="float:left;">
              <span class="c_red">*</span>
              &nbsp;&nbsp;作业描述&nbsp;&nbsp;&nbsp;&nbsp;：&nbsp;
            </label>
            <%= f.text_area :description, :rows => 8, :name => "homework_description", :class => "w620",
                            :maxlength => 3000, :placeholder => "最多3000个汉字"  %>
          </p>
            <!--<div class="cl"></div>-->
          <!--<p>-->
            <!--<label style="float: left;">-->
              <!--&nbsp;&nbsp;&nbsp;添加附件&nbsp;&nbsp;&nbsp;&nbsp;：-->
            <!--</label>-->
            <!--<div style="float: left;padding-bottom: 15px;">-->
              <!--<%#= render :partial => 'attachments/form', :locals => {:container => @homework}%>-->
            <!--</div>-->
          <!--</p>-->
            <!--<div class="cl"></div>-->


            <div class="cl"></div>
            <label style="float: left;padding-left: 15px;">
              &nbsp;&nbsp;&nbsp;添加附件&nbsp;&nbsp;&nbsp;&nbsp;：
            </label>
            <!--<div style="float: left;margin-left: 5px;">-->
              <!--<%#= render :partial => 'attachments/form',locals: {:container => @homework}%>-->
            <!--</div>-->

            <div style="float: left;">
              <%= render :partial => 'attachments/form', :locals => {:container => @homework} %>
            </div>
            <div class="cl"></div>

          <p style="padding-top: 10px;">
              <label>&nbsp;&nbsp;&nbsp;开发项目
                <img src="/images/bid/pic_question.png" width="16" height="16"
                     title="项目是一种由用户创建的基于网络的协作空间，能够为个人或小组提供分布式的协同交流和资料管理等方面的支持。
                            项目托管平台：http://forge.trustie.ne">：
              </label>
              <% if @homework.project.nil? %>
                  <%= f.select :project_id, options_for_select(user_projects_option),{}, {:name => "project_id", :required => true,:class => "w350 bo"}%>
              <% else %>
                  <%= f.select :project_id, options_for_select(user_projects_option,@homework.project.id),{},{:name => "project_id", :required => true, :class => "w350 bo"}%>
              <% end %>
          </p>

          <p>
            <span style="float: left;">
              &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
            </span>
            <a href="javascript:void(0)" class="tijiao" onclick="submit_homework_form();">
              <%= l(:label_button_ok)  %>
            </a>
            <a href="javascript:history.back()" class="tijiao">取&nbsp;&nbsp;消</a>
          <div class="cl"></div>
          </p>
        <% end %>
      </div><!---创建作业内容结束-->
    </div>

    <div id="content2" class="undis">
      <%= render :partial => "homework_member",:locals => {:members => @members,:hoemwork_users =>@hoemwork_users,:homework => @homework} %>
    </div><!---成员结束-->
  </div>
</div><!--新建作业结束-->
</body>
</html>
