{* this template is used for adding/editing/deleting Message Templates *}
{capture assign=tokenDocsRepeated}{docURL page="Mail-merge Tokens for Contact Data" text="token documentation"}{/capture}
<div id="help">
    {ts}Use this form to add or edit re-usable message templates.{/ts} {help id="id-msgTplIntro"}
</div>
<div class="form-item" id="message_templates">
<fieldset><legend>{if $action eq 1}{ts}New Message Template{/ts}{elseif $action eq 2}{ts}Edit Message Template{/ts}{else}{ts}Delete Message Template{/ts}{/if}</legend>
  
   {if $action eq 8}
      <div class="messages status">
        <dl>
          <dt><img src="{$config->resourceBase}i/Inform.gif" alt="{ts}status{/ts}" /></dt>
          <dd>
          {ts}Do you want to delete this message template?{/ts}
          </dd>
       </dl>
      </div>
   {else}
    <table class="form-layout-compressed" style="width:95%;">
        <tr>
            <td class="label">{$form.msg_title.label}</td>
            <td>{$form.msg_title.html}
                <br /><span class="description html-adjust">{ts}Descriptive title of message - used for template selection.{/ts}
            </td>
        </tr>
        <tr>
            <td class="label">{$form.msg_subject.label}</td>
            <td>
                  {$form.msg_subject.html}
	              <a href="#" onClick="return showToken('Subject', 3);">{$form.token3.label}</a>
	              {help id="id-token-text" file="CRM/Contact/Form/Task/Email.hlp"}
                  <div id='tokenSubject' style="display:none">
	                   <input  style="border:1px solid #999999;" type="text" id="filter3" size="20" name="filter3" onkeyup="filter(this, 3)"/><br />
	                   <span class="description">{ts}Begin typing to filter list of tokens{/ts}</span><br/>
	                   {$form.token3.html}
                  </div>
	           <br /><span class="description">{ts}Subject for email message.{/ts} {ts 1=$tokenDocsRepeated}Tokens may be included (%1).{/ts}
            </td>
        </tr>
        <tr>
            <td colspan="2">
                        <div class="accordion ui-accordion ui-widget ui-helper-reset">
                            <span class="helpIcon" id="helptext">
	                          <a href="#" onClick="return showToken('Text', 1);">{$form.token1.label}</a>
	                          {help id="id-token-text" file="CRM/Contact/Form/Task/Email.hlp"}
	                          <div id='tokenText' style="display:none">
	                            <input  style="border:1px solid #999999;" type="text" id="filter1" size="20" name="filter1" onkeyup="filter(this, 1)"/><br />
	                            <span class="description">{ts}Begin typing to filter list of tokens{/ts}</span><br/>
	                              {$form.token1.html}
	                          </div>
                            </span>
                            <h3 class="head"> 
	                            <span class="ui-icon ui-icon-triangle-1-s" id='text'></span><a href="#">{ts}Text Message{/ts}</a>
                            </h3>
                            <div class='text'>
                              {$form.msg_text.html|crmReplace:class:huge}<br />
                              <span class="description">{ts}Text formatted message.{/ts} {ts 1=$tokenDocsRepeated}Tokens may be included (%1).{/ts}
                            </div>
                        </div>
            </td>          
        </tr>            
        <tr>               
            <td colspan="2">
                        <div class="accordion ui-accordion ui-widget ui-helper-reset">
                            <span class="helpIcon" id="helphtml">
	                          <a href="#" onClick="return showToken('Html', 2);">{$form.token2.label}</a> 
	                          {help id="id-token-html" file="CRM/Contact/Form/Task/Email.hlp"}
	                          <div id='tokenHtml' style="display:none">
	                            <input style="border:1px solid #999999;" type="text" id="filter2" size="20" name="filter2" onkeyup="filter(this, 2)"/><br />
	                            <span class="description">{ts}Begin typing to filter list of tokens{/ts}</span><br/>
	                              {$form.token2.html}
	                          </div>
                            </span>
                            <h3 class="head"> 
	                            <span class="ui-icon ui-icon-triangle-1-e" id='html'></span><a href="#">{ts}HTML Message{/ts}</a>
                            </h3>
                            <div class='html'>
                                {$form.msg_html.html}<br />
                                <span class="description">{ts}You may optionally create an HTML formatted version of this message. It will be sent to contacts whose Email Format preference is 'HTML' or 'Both'.{/ts} {ts 1=$tokenDocsRepeated}Tokens may be included (%1).{/ts}
                            </div>  
                        </div>
            </td>
        </tr>
        <tr>
            <td class="label">{$form.is_active.label}</td>
            <td>{$form.is_active.html}</td>
        </tr>
    </table> 
  {/if}
  <dl>   
      <dt></dt><dd class="html-adjust">{$form.buttons.html}</dd>
  </dl>
  <br clear="all" />
</fieldset>
</div>
{include file="CRM/Mailing/Form/InsertTokens.tpl"}