<% content_for :head do -%>
  <%= javascript_include_tag 'admin/mail_magazine' %>
	<script type="text/javascript">
	  function toConfirm() {
	  	if (document.getElementById('mail_magazine_template[body]').contentDocument != null) {
			document.getElementById('mail_magazine_template_body').value = document.getElementById('mail_magazine_template[body]').contentDocument.body.innerHTML;
		}else{
			document.getElementById('mail_magazine_template_body').value = document.getElementById('mail_magazine_template[body]').value;
		}
	  }
	</script>
<% end -%>

<% form_for [:admin, @mail_magazine_template] do |f| %>
  <%= f.error_messages %>
  <p class="req"><span class="pnt">※</span>は必須入力です</p>
  <table class="data" cellspacing="1">
    <tr>
      <th>メール形式 <span class="pnt">※</span></th>
      <td>
        <% [MailMagazineTemplate::HTML, MailMagazineTemplate::TEXT].each do | value | %>
        <% label = MailMagazineTemplate::FORM_TYPE_NAMES[value] %>
         <%= radio_button_tag "mail_magazine_template[form]", value, checked=(@mail_magazine_template.form==value) %>
         <%= content_tag :label, label, :for => "mail_magazine_template_form_%d" % value %>
        <% end %>
      </td>
    </tr>
    <tr>
      <th>Subject <span class="pnt">※</span></th>
      <td>
        <%= f.text_field :subject, :class=>"data_l" %>
      </td>
    </tr>
    <tr>
      <th colspan=2>
        本文 <span class="pnt">※</span>（名前差し込み時は {name} といれてください）
      </th>
    </tr>
    <tr>
      <td colspan=2>
        <%= f.text_area :body, :style => 'width:690px; height:400px;', :id => 'mail_magazine_template[body]' %>
      </td>
    </tr>
  </table>
  <%= hidden_field :mail_magazine_template, :body %>
  <div class="btn_box">
    <%= f.submit "この内容で登録する", :confirm=>"本当に登録しても宜しいですか？", :class=>"btn", :onclick => "toConfirm()" %>
    <%= image_tag("btn_side.gif", :width => "6", :height => "34", :class => "btn_side") %>
  </div>
<% end -%>
