<%= error_messages_for :questionnaire %>
<p class="req"><span class="pnt">※</span>は必須入力です</p>
<table class="data" cellspacing="1">
  <tr>
    <th class="th">稼働・非稼働 <span class="pnt">※</span></th>
    <td>
      <%= radio_button "questionnaire", "operation", TRUE %><label for="questionnaire_operation_true">　稼働　</label>
      <%= radio_button "questionnaire", "operation", FALSE %><label for="questionnaire_operation_false">　非稼働　</label>
    </td>
  </tr>
  <tr>
    <th class="th">アンケートタイトル <span class="pnt">※</span></th>
    <td><%= text_field "questionnaire", "name", :class => "data_l" %></td>
  </tr>
  <tr>
    <th class="th">アンケート内容 <span class="pnt">※</span></th>
    <td><%= text_area "questionnaire", "content" %></td>
  </tr>
  <% @questions.each_with_index do |question, question_idx| %>
  <tr>
    <th style="width:115px;font-size:12px;">質問<%= question_idx+1 %>　
    <% if question_idx == 0 %>
      <span class="pnt">※</span>
    <% end %>
    </th>
    <td><%= text_field_tag "questions[#{question_idx}]", question.content, :class => "data_l" %></td>
  </tr>
  <tr>
    <td colspan="2"style="width:678px;font-size:12px;">
      <%= radio_button_tag "question#{question_idx}_choice0_format", "0", QuestionChoice::NOUSE == @questions[question_idx].question_choices[0].format, {:onclick=>"fn_choice_display(#{question_idx}, 0)"} %><label for="question<%= question_idx %>_choice0_format_0">　使用しない　</label>
      <%= radio_button_tag "question#{question_idx}_choice0_format", "1", QuestionChoice::TEXTAREA == @questions[question_idx].question_choices[0].format, {:onclick=>"fn_choice_display(#{question_idx}, 1)"} %><label for="question<%= question_idx %>_choice0_format_1">　テキストエリア　</label>
      <%= radio_button_tag "question#{question_idx}_choice0_format", "2", QuestionChoice::TEXTBOX == @questions[question_idx].question_choices[0].format, {:onclick=>"fn_choice_display(#{question_idx}, 2)"} %><label for="question<%= question_idx %>_choice0_format_2">　テキストボックス　</label>
      <%= radio_button_tag "question#{question_idx}_choice0_format", "3", QuestionChoice::CHECKBOX == @questions[question_idx].question_choices[0].format, {:onclick=>"fn_choice_display(#{question_idx}, 3)"} %><label for="question<%= question_idx %>_choice0_format_3">　チェックボックス　</label>
      <%= radio_button_tag "question#{question_idx}_choice0_format", "4", QuestionChoice::RADIOBUTTON == @questions[question_idx].question_choices[0].format, {:onclick=>"fn_choice_display(#{question_idx}, 4)"} %><label for="question<%= question_idx %>_choice0_format_4">　ラジオボタン　</label>
    </td>
  </tr>
  <tr>
    <td colspan = "2" >
      <table id = "td<%= question_idx %>">
        <% 8.times do | choice_idx | %>
          <% if choice_idx%2 == 0 %><tr><% end %>
          <td>
<%-
value = nil
if (question_choice = question.question_choices.find_by_position(choice_idx+1))
  value = question_choice.content
else
  value = params['question%d_choice%d' % [question_idx, choice_idx]]
end
 -%>
 <%= choice_idx+1 %>　<%= text_field_tag "question#{question_idx}_choice#{choice_idx}", value, :class=>"data_m" %>
          </td>
          <% if choice_idx%2 == 1 %></tr><% end %>
        <% end %>
      </table>
    </td>
  </tr>
  <% end %>
</table>
  <%= hidden_field_tag "id", @id %>
  <div class="btn_box">
    <%= submit_tag "この内容で登録する", :class=>"btn", :confirm => "本当に登録しますか？" %>
    <%= image_tag("btn_side.gif", :width => "6", :height => "34", :class => "btn_side") %>
    <input type="button" value="クリア" class="btn" onclick="fn_form_clear();">
    <%= image_tag("btn_side.gif", :width => "6", :height => "34", :class => "btn_side") %>
  </div>
