{include file="page_header.htm"}
{insert_scripts files="../js/utils.js"}
<form enctype="multipart/form-data" name="theForm" action="mail_template.php?act=update" method="post" onsubmit="return validate()">
<table width="100%"  border="0" cellspacing="0" cellpadding="0" class="table_form1" >	
	<tr>
	<td class="label">请选择邮件模版:</td>
	<td>
		<select id="selTemplate" onchange="loadTemplate(this.options[this.options.selectedIndex].value)" class="select_input">
		{foreach from=$mail_templates item=list}
		<option value="{$list.template_id}" {if $list.template_id == $template.template_id}selected{/if}>{$list.template_subject} [{$list.template_code}]</option>
		{/foreach}	
		</select>
	</td>
	</tr>
	<tr>
	<td class="label">邮件主题:</td>
	<td>
	<input type="text" name="subject" class="FormSmall" id="subject" value="{$template.template_subject|escape}" style="width: 300px" />
	</td>
	</tr>
	
	<tr>
	<td class="label">邮件类型:</td>
	<td>
		<label><input type="radio" name="mail_type" value="0" {if $template.is_html==0} checked="true" {/if} onclick="javascript:change_editor();"  /> 纯文本邮件</label>　
		<label><input type="radio" name="mail_type" value="1" {if $template.is_html==1} checked="true" {/if} onclick="javascript:change_editor();" /> HTML 邮件</label>
	</td>
	</tr>
	
	<tr>
	<td colspan="2">
		{if $template.is_html==0}
		<textarea id="content" name="content" style="width:90%;padding-left:5px;padding-right:5px;" rows="16">{$template.template_content}</textarea>		
		{else}
		{$template.template_content}
		{/if}
	</td>
	</tr>
	
	<tr>
	<td style="border:none;"></td>
	<td style="border:none;">
	<input type="hidden" value="{$template.template_id}" name="template_id" id="template_id" />
	<input type="submit" value="提交" class="bginput" />
	<input type="reset" value="重置" class="bginput" />
	</td>
	</tr> 
</table>
</form>

<script language="JavaScript">
{literal}
function loadTemplate(id) {
	document.theForm.action="mail_template.php?act=list&id="+id;
	document.theForm.submit();
}

function change_editor(id) {
	var em = document.forms['theForm'].elements;
	var em_radio = em['mail_type'];
	for (i = 0; i < em_radio.length; i++){
		if (em_radio[i].checked){
			type = em_radio[i].value;
			break;
		}
	}
	var tpl = document.getElementById('selTemplate').value;
	document.theForm.action="mail_template.php?act=list&id="+tpl+"&mail_type="+type;
	document.theForm.submit();
}
{/literal}
</script>
{insert_scripts files="validator.js"}
{include file="page_footer.htm"}