<SCRIPT Language="JavaScript">
<!--
    var n=0,s=0,elem=null;
    function pos(e){
        elem=e;
        var sel=document.selection.createRange();
        var r=elem.createTextRange();
        r.moveToPoint(sel.offsetLeft,sel.offsetTop);
        r.moveEnd("character",sel.text.length);
        s=r.text.replace(/\r/g,"").length;
        r.moveEnd("textedit");
        n=r.text.replace(/\r/g,"").length+(elem.value.match(/(\r\n)*$/),RegExp.$1.length/2);
    }
    function insSysVar(){
        if(!elem)return;
        var r=elem.createTextRange();
        r.collapse();
        r.moveStart("character",elem.value.replace(/\r/g,"").length-n);
        r.moveEnd("character",s);
        r.text=document.frmCI.sysvars.options[document.frmCI.sysvars.selectedIndex].value;
        r.collapse(false);
        r.select();
        r.parentElement().focus();
        s=0;
        pos(elem);
    }
-->
</SCRIPT>

<h1><?php echo $this->translate("mailtemplate.title.{$this->action_prefix}input"); ?></h1>

<?php if(!empty($this->error_messages)) : ?>
<div id="errorMessage">
<ul>
<?php foreach($this->error_messages as $element_name => $element_mess) : ?>
<?php foreach($element_mess as $mess_key => $mess_value) :?>
<li><?php echo $this->translate("form.mailtemplate.$element_name") . $mess_value; ?></li>
<?php endforeach; ?>
<?php endforeach; ?>
</ul>
</div>
<?php endif; ?>

<h2><?php echo $this->translate("mailtemplate.caption.{$this->template_type}");  ?>&nbsp;&nbsp;[<?php echo $this->service['name']; ?>]</h2>
<form name="frmCI" action="<?php echo $this->appPath('controller') .'/'. $this->action_prefix; ?>confirm" method="post">
<input type="hidden" name="mailtemplate_id" value="<?php echo $this->escape($this->form_input['mailtemplate_id']); ?>"/>
<input type="hidden" name="service_id" value="<?php echo $this->escape($this->service['id']); ?>">
<table class="form_2col">
<tbody>

<tr>
<th><?php echo $this->translate('mailtemplate.label.name'); ?></th>
<td><input type="text" size="80" name="name" value="<?php echo $this->escape($this->form_input['name']); ?>"></td>
</tr>

<tr>
<th><?php echo $this->translate('mailtemplate.label.mail_from'); ?></th>
<td><input type="text" size="80" name="mail_from" value="<?php echo $this->escape($this->form_input['mail_from']); ?>"></td>
</tr>

<tr>
<th><?php echo $this->translate('mailtemplate.label.subject'); ?></th>
<td><input type="text" size="80" name="subject" value="<?php echo $this->escape($this->form_input['subject']); ?>"></td>
</tr>

<tr>
<th><?php echo $this->translate('mailtemplate.label.content'); ?></th>
<td>
<textarea cols="60" rows="20" name="content" onfocus="pos(this)" onmouseup="pos(this)" onkeyup="pos(this)"><?php echo $this->escape($this->form_input['content']); ?></textarea><br/>
<!-- 
<?php echo $this->formSelect('sysvars', null, null, $this->sysvar_options); ?>
<button type="button" onclick="insSysVar()"><?php echo $this->translate('mailtemplate.operation.insert_sysvar'); ?></button>
 -->
</td>
</tr>

</tbody>

<tfoot>
<tr>
<td colspan="2">
<input type='submit' style="width:80px;" value="<?php echo $this->translate('common.operation.register'); ?>">&nbsp;&nbsp;
<input type="reset" style="width:80px;" value="<?php echo $this->translate('common.operation.reset'); ?>">
</td>
</tr>
</tfoot>

</table>

</form>

&gt;&gt;&nbsp;&nbsp;<a href="<?php echo $this->appPath('controller'); ?>/view_list/service_id/<?php echo $this->service['id']; ?>"><?php echo $this->translate('mailtemplate.operation.back_list'); ?></a>
<br/>
&gt;&gt;&gt;&nbsp;&nbsp;<a href="<?php echo $this->appPath(''); ?>"><?php echo $this->translate('common.operation.back_toppage'); ?></a>
