<% content_for :head do -%>
  <%= javascript_include_tag 'admin/mail_magazine' %>
<% end -%>
<%= render :partial => "submenu" %>
<div id="main"><!-- メイン -->
<script type="text/javascript">
  function toConfirm() {
  	if (document.getElementById('contents[body]').contentDocument != null) {
		document.getElementById('contents_body').value = document.getElementById('contents[body]').contentDocument.body.innerHTML;
	}else{
		document.getElementById('contents_body').value = document.getElementById('contents[body]').value;
	}
  }
</script>

<h2>配信内容設定</h2>
<%=h flash[:notice] %>
<%=h flash[:errors] %>
<table class="data" cellspacing="1">
  <tr>
    <th>テンプレート選択</th>
    <td>
      <%= select :contents, :template_id, templates_select, {:include_blank=>true},
            {:onChange => remote_function(:update=>'mail_magazine_edit',
            :url => {:action => 'template_re_search'}, :with => "'template_id='+value",
            :before => "Form.disable('edit_form')",
            :complete => "Form.enable('edit_form')")} %>
    </td>
  </tr>
</table>
<br />
<% form_for :contents, :url => {:action => 'confirm'},
    :html => {:id => 'edit_form'} do |f| %>
  <%= f.error_messages %>
  <div id="mail_magazine_edit">
    <%= render :partial => "mail_contents", :locals => {:f => f} %>
  </div>
  <%= hidden_field_tag 'customer_ids', @customer_ids %>
  <div class="btn_box">
    <%= f.submit "確認する", :class=>"btn", :onclick => "toConfirm()" %>
    <%= image_tag("btn_side.gif", :width => "6", :height => "34", :class => "btn_side") %>
  </div>

<% end %>

</div><!-- /メイン -->
