<%include spellcheck_editor.html%>
<script>
  
  /*
  // Add listeners to the subscription inputs
  document.getElementById("subscribe_to_num")
    .addEventListener("onchange", this.create_subscription_link());
  document.getElementById("subscribe_to_text")
    .addEventListener("onchange", this.create_subscription_link());
  document.getElementById("unsubscribe_to_num")
    .addEventListener("onchange", this.create_subscription_link());
  document.getElementById("unsubscribe_to_text")
    .addEventListener("onchange", this.create_subscription_link());
  document.getElementById("subscribe_move_from_num")
    .addEventListener("onchange", this.create_subscription_link());
  document.getElementById("subscribe_move_from_num")
    .addEventListener("onchange", this.create_subscription_link());
  document.getElementById("subscribe_move_text")
    .addEventListener("onchange", this.create_subscription_link());
  //*/

  function switch_mode(mode, editor_advanced, submit) {
      document.myform.emode.value = mode; 
      if (typeof(editor_advanced) != 'undefined')
        document.myform.editor_advanced.value = editor_advanced;

      if (submit) {
        if (editor_advanced == 0)
          ae.retrieveHTML();

        document.myform.switch_editor.value = 1;
        document.myform.submit();
      }
  }

  function create_subscription_link(event) {
    var targetId = event.target.id;

    // Return if null/undefined
    if(!targetId == true)
    {
      return;
    }

    // Look if this is an "ADD" subscription
    var contentToReplace = "";
    if (targetId.includes("unsubscribe_to"))
    {
      contentToReplace = "<a href=\"<%unsubscribe_list%>" + 
        document.getElementById("unsubscribe_to_num").value +
        "\">" + document.getElementById("unsubscribe_to_text").value
        + "</a>";
      document.getElementById("unsubscribe_to_link").setAttribute("value", contentToReplace);
    }
    else if(targetId.includes("subscribe_to"))
    {
      contentToReplace = "<a href=\"<%subscribe_list%>" + 
        document.getElementById("subscribe_to_num").value +
        "\">" + document.getElementById("subscribe_to_text").value
        + "</a>";
      document.getElementById("subscribe_to_link").setAttribute("value", contentToReplace);
    }
    else if (targetId.includes("subscribe_move"))
    {
      contentToReplace = "<a href=\"<%move_list%>" + 
        document.getElementById("subscribe_move_from_num").value + "-" +
        document.getElementById("subscribe_move_to_num").value +
        "\">" + document.getElementById("subscribe_move_text").value
        + "</a>";
      document.getElementById("subscribe_move_link").setAttribute("value", contentToReplace);
    }

    return;
    
  }

  function copy_to_clipboard(event) {
    var targetId = event.target.id;

    // Return if null/undefined
    if(!targetId == true)
    {
      return;
    }

    if (targetId.includes("unsubscribe_to"))
    {
      document.getElementById("unsubscribe_to_link").select();
    }
    else if(targetId.includes("subscribe_to"))
    {
      document.getElementById("subscribe_to_link").select();
    }
    else if (targetId.includes("subscribe_move"))
    {
      document.getElementById("subscribe_move_link").select();
    }

    try {
        document.execCommand('copy');
    }
    catch (err) {
        return;
    }

    return;
  }

</script>
<div>
    <a href="<%subscribe_list%>209">Unsubscribe</a>
</div>
<table onchange="create_subscription_link(event)" border="0" width="98%" cellspacing="1" cellpadding="1" align="center">
  <tr>
    <td class="body">Email Mode</td>
    <td class="body">[ <b>
      <%if emode eq 'html'%>HTML
      <%elsif emode eq 'multi'%>Text and HTML
      <%else%>Text Only<%endif%></b> ]
      <input type="hidden" name="msg_mode" value="<%if  emode eq 'html'%>html<%elsif emode eq 'multi'%>multi<%else%>text<%endif%>">
      <input type="submit" id="button_mode" class="button" name="bswitch" value="Switch To <%if emode eq 'text'%>HTML<%else%>Text<%endif%>" onclick="switch_mode('<%if emode eq 'text' and $usr_compose_mode eq 'multi'%>multi<%elsif emode eq 'text'%>html<%else%>text<%endif%>')">
    </td>
  </tr>
  <tr>
    <td class="body">Character Set:</td>
    <td>
      <select name="msg_charset" class="object">
        <option<%if msg_charset eq 'us-ascii'%> selected<%endif%>>us-ascii</option>
        <option<%if msg_charset eq 'ISO-8859-1'%> selected<%endif%>>ISO-8859-1</option>
        <option<%if msg_charset eq 'ISO-8859-2'%> selected<%endif%>>ISO-8859-2</option>
        <option<%if msg_charset eq 'ISO-8859-3'%> selected<%endif%>>ISO-8859-3</option>
        <option<%if msg_charset eq 'ISO-8859-4'%> selected<%endif%>>ISO-8859-4</option>
        <option<%if msg_charset eq 'ISO-8859-5'%> selected<%endif%>>ISO-8859-5</option>
        <option<%if msg_charset eq 'ISO-8859-6'%> selected<%endif%>>ISO-8859-6</option>
        <option<%if msg_charset eq 'ISO-8859-6-I'%> selected<%endif%>>ISO-8859-6-I</option>
        <option<%if msg_charset eq 'ISO-8859-6-E'%> selected<%endif%>>ISO-8859-6-E</option>
        <option<%if msg_charset eq 'ISO-8859-7'%> selected<%endif%>>ISO-8859-7</option>
        <option<%if msg_charset eq 'ISO-8859-8'%> selected<%endif%>>ISO-8859-8</option>
        <option<%if msg_charset eq 'ISO-8859-8-I'%> selected<%endif%>>ISO-8859-8-I</option>
        <option<%if msg_charset eq 'ISO-8859-8-E'%> selected<%endif%>>ISO-8859-8-E</option>
        <option<%if msg_charset eq 'ISO-8859-9'%> selected<%endif%>>ISO-8859-9</option>
        <option<%if msg_charset eq 'ISO-8859-10'%> selected<%endif%>>ISO-8859-10</option>
        <option<%if msg_charset eq 'ISO-8859-13'%> selected<%endif%>>ISO-8859-13</option>
        <option<%if msg_charset eq 'ISO-8859-14'%> selected<%endif%>>ISO-8859-14</option>
        <option<%if msg_charset eq 'ISO-8859-15'%> selected<%endif%>>ISO-8859-15</option>
        <option<%if msg_charset eq 'ISO-IR-111'%> selected<%endif%>>ISO-IR-111</option>
        <option<%if msg_charset eq 'ISO-2022-CN'%> selected<%endif%>>ISO-2022-CN</option>
        <option<%if msg_charset eq 'ISO-2022-KR'%> selected<%endif%>>ISO-2022-KR</option>
        <option<%if msg_charset eq 'ISO-2022-JP'%> selected<%endif%>>ISO-2022-JP</option>
        <option<%if msg_charset eq 'UTF-32BE'%> selected<%endif%>>UTF-32BE</option>
        <option<%if msg_charset eq 'UTF-32LE'%> selected<%endif%>>UTF-32LE</option>
        <option<%if msg_charset eq 'UTF-32BE'%> selected<%endif%>>UTF-32BE</option>
        <option<%if msg_charset eq 'UTF-16BE'%> selected<%endif%>>UTF-16BE</option>
        <option<%if msg_charset eq 'UTF-16LE'%> selected<%endif%>>UTF-16LE</option>
        <option<%if msg_charset eq 'UTF-16BE'%> selected<%endif%>>UTF-16BE</option>
        <option<%if msg_charset eq 'windows-1250'%> selected<%endif%>>windows-1250</option>
        <option<%if msg_charset eq 'windows-1251'%> selected<%endif%>>windows-1251</option>
        <option<%if msg_charset eq 'windows-1252'%> selected<%endif%>>windows-1252</option>
        <option<%if msg_charset eq 'windows-1253'%> selected<%endif%>>windows-1253</option>
        <option<%if msg_charset eq 'windows-1254'%> selected<%endif%>>windows-1254</option>
        <option<%if msg_charset eq 'windows-1255'%> selected<%endif%>>windows-1255</option>
        <option<%if msg_charset eq 'windows-1256'%> selected<%endif%>>windows-1256</option>
        <option<%if msg_charset eq 'windows-1257'%> selected<%endif%>>windows-1257</option>
        <option<%if msg_charset eq 'windows-1258'%> selected<%endif%>>windows-1258</option>
        <option<%if msg_charset eq 'IBM866'%> selected<%endif%>>IBM866</option>
        <option<%if msg_charset eq 'IBM850'%> selected<%endif%>>IBM850</option>
        <option<%if msg_charset eq 'IBM852'%> selected<%endif%>>IBM852</option>
        <option<%if msg_charset eq 'IBM855'%> selected<%endif%>>IBM855</option>
        <option<%if msg_charset eq 'IBM857'%> selected<%endif%>>IBM857</option>
        <option<%if msg_charset eq 'IBM862'%> selected<%endif%>>IBM862</option>
        <option<%if msg_charset eq 'IBM864'%> selected<%endif%>>IBM864</option>
        <option<%if msg_charset eq 'IBM864i'%> selected<%endif%>>IBM864i</option>
        <option<%if msg_charset eq 'UTF-8'%> selected<%endif%>>UTF-8</option>
        <option<%if msg_charset eq 'UTF-7'%> selected<%endif%>>UTF-7</option>
        <option<%if msg_charset eq 'Shift_JIS'%> selected<%endif%>>Shift_JIS</option>
        <option<%if msg_charset eq 'Big5'%> selected<%endif%>>Big5</option>
        <option<%if msg_charset eq 'EUC-JP'%> selected<%endif%>>EUC-JP</option>
        <option<%if msg_charset eq 'EUC-KR'%> selected<%endif%>>EUC-KR</option>
        <option<%if msg_charset eq 'GB2312'%> selected<%endif%>>GB2312</option>
        <option<%if msg_charset eq 'VISCII'%> selected<%endif%>>VISCII</option>
        <option<%if msg_charset eq 'KOI8-R'%> selected<%endif%>>KOI8-R</option>
        <option<%if msg_charset eq 'KOI8-U'%> selected<%endif%>>KOI8-U</option>
        <option<%if msg_charset eq 'TIS-620'%> selected<%endif%>>TIS-620</option>
        <option<%if msg_charset eq 'T.61-8bit'%> selected<%endif%>>T.61-8bit</option>
        <option<%if msg_charset eq 'HZ-GB-2312'%> selected<%endif%>>HZ-GB-2312</option>
        <option<%if msg_charset eq 'Big5-HKSCS'%> selected<%endif%>>Big5-HKSCS</option>
      </select>
    </td>
  </tr>
  <tr>
    <td class="body">Subject</td>
    <td class="body">
      <input type="text" name="msg_subject" size="<%if is_ie or is_mozilla%>54<%else%>20<%endif%>" value="<%if msg_subject%><%msg_subject%><%endif%>" class=object /><font color=green>*</font>
    </td>
  </tr>
  <tr>
    <td class="body" nowrap>From Name</td>
    <td class="body" nowrap>
      <input type="text" name="msg_from_name" size="<%if is_ie or is_mozilla%>54<%else%>20<%endif%>" value="<%if msg_from_name%><%msg_from_name%><%else%><%pro_first_name%> <%pro_last_name%><%endif%>" class=object />
    </td>
  </tr>
  <tr>
    <td class="body">From Email</td>
    <td class="body">
      <input type="text" name="msg_from_email" size="<%if is_ie or is_mozilla%>54<%else%>20<%endif%>" value="<%if msg_from_email%><%msg_from_email%><%else%><%usr_email%><%endif%>" class=object /><font color=green>*</font>
    </td>
  </tr>
  <tr>
    <td class="body">Reply to Email</td>
    <td class="body">
      <input type="text" name="msg_reply_to" size="<%if is_ie or is_mozilla%>54<%else%>20<%endif%>" value="<%if msg_reply_to%><%msg_reply_to%><%elsif usr_reply_email%><%usr_reply_email%><%else%><%usr_email%><%endif%>" class=object /><font color=green>*</font>
    </td>
  </tr>
  <tr>
    <td class="body">Bounce Email</td>
    <td class="body">
      <input type="text" name="msg_bounce_email" size="<%if is_ie or is_mozilla%>54<%else%>20<%endif%>" value="<%if msg_bounce_email%><%msg_bounce_email%><%elsif usr_bounce_email%><%usr_bounce_email%><%else%><%usr_email%><%endif%>" class=object /><font color=green>*</font>
    </td>
  </tr>
  <tr>
    <td class="body" valign="top">Attachments</td>
    <td>
      <table border="0" cellspacing="1" cellpadding="1">
        <tr>
          <td colspan=2>
            <input type=file name=attachment size="<%if is_ie or is_mozilla%>30<%else%>20<%endif%>" class=object />
            <input type=submit id="button_attach" name="add_attach" value="Upload" class=button />
          </td>
        </tr>
        <%if hits%>
        <tr>
          <td>
            <table border="0" cellspacing="1" cellpadding="1">
              <%loop attachments%>
              <tr class="body">
                <td>
                  <input type=hidden name="attach-<%fname%>" value="<%user_fname%>" />
                  <input name="del_attach" value="<%fname%>" type="checkbox" />
                </td>
                <td class="body"><%user_fname%>&nbsp;&nbsp;(<%GList::Tools::friendly_size($fsize)%>)</td>
              </tr>
              <%endloop%>
            </table>
          </td>
          <td valign="middle"><input type=submit name="sdelete" value="Delete Attachments" class=button /></td>
        </tr>
        <%endif%>
      </table>
    </td>
  </tr>
<%if emode eq 'html' or emode eq 'multi'%>
  <tr>
    <td class="body">Text</td>
    <td class="body">
      <%if emode eq 'html'%>
      [ <b>Autogenerated</b> ]
      <%elsif emode eq 'multi'%>
      [ <b>Entered Manually</b> ]
      <%endif%>
      <input type="submit" class="button" id="button_text" name="bswitch" value="<%if emode eq 'html'%>Enter text manually<%elsif emode eq 'multi'%>Autogenerate<%endif%>" onclick="switch_mode(<%if emode eq 'multi'%>'html'<%elsif emode eq 'html'%>'multi'<%endif%>)">
    </td>
  </tr>
<%endif%>
  <tr>
    <td class="body"><%if emode ne 'html'%>Text message<%else%>&nbsp;<%endif%></td>
    <td align=right class="body"><font color=green>*: required&nbsp;</font></td>
  </tr>
<%-- 
TEXT message part 
--%>
<%if emode eq 'text' or emode eq 'multi' or emode eq ''%>
  <tr>
    <td colspan=2 align="center">
      <textarea id="msg_content_text" name="msg_content_text" style="width: 100%" rows="15" wrap='on' <%if is_ie or is_mozilla%>class="object_white"<%endif%>><%if msg_content_text%><%msg_content_text%><%endif%></textarea>
    </td>
  </tr>
<%endif%>
<%--
HTML code for message having HTML and TEXT part
--%>
<%if emode eq 'html' or emode eq 'multi'%>
  <tr>
    <td class="body" colspan="2"><%if editor_advanced%>HTML message<%else%>Raw HTML<%endif%>&nbsp; <span id="url_switch">[ <a href="javascript:switch_mode('<%if emode%><%emode%><%else%>text<%endif%>', <%if editor_advanced%>0<%else%>1<%endif%>, 1)"><%if editor_advanced%>Use Text Area<%else%>Use Advanced Editor<%endif%></a> ]</span></td>
  </tr>
  <%if editor_advanced%>
    <tr height="280">
      <td align="center" colspan="2" <%if emode eq 'html'%>width="<%if msg_editor_width%><%msg_editor_width%><%else%>700<%endif%>"<%endif%>>
        <input type="hidden" id="msg_content_html" name="msg_content_html" value="<%if msg_content_html%><%msg_content_html%><%endif%>" />
        <input type="hidden" id="compose_is_html" value="1" />
        <%include editor_objects.html%>
      </td>
    </tr>
  <%else%>
    <tr>
      <td align=center colspan=2>
        <textarea id="msg_content_html" name="msg_content_html" style="width: 100%" rows="15" wrap='on' class="object_white"><%if msg_content_html%><%msg_content_html%><%endif%></textarea>
        <input type="hidden" id="compose_is_html" value="1" />
      </td>
    </tr>
  <%endif%>

    <!-- Arbitrary Subscribe/Unsubscribe/Move List Options -->
    <tr>
      <td class="body">Subscribe To List:</td>
      <td>
        <input type="number" id="subscribe_to_num" />
      </td>
    </tr>
    <tr>
      <td class="body">Subscribe To Text:</td>
      <td>
        <input type="text" id="subscribe_to_text" />
      </td>
    </tr>
    <tr>
      <td class="body"></td>
      <td>
        <input type="text" id="subscribe_to_link" readonly="readonly" value=""/>
        <input type="button" id="subscribe_to_but" value="Copy to Clipboard" onclick="copy_to_clipboard(event)"/>
      </td>
    </tr>

    <tr>
      <td class="body">Unsubscribe To List:</td>
      <td>
        <input type="number" id="unsubscribe_to_num" />
      </td>
    </tr>
    <tr>
      <td class="body">Unsubscribe To Text:</td>
      <td>
        <input type="text" id="unsubscribe_to_text" />
      </td>
    </tr>
    <tr>
      <td class="body"></td>
      <td>
        <input type="text" id="unsubscribe_to_link" readonly="readonly" value=""/>
        <input type="button" id="unsubscribe_to_but" value="Copy to Clipboard" onclick="copy_to_clipboard(event)"/>
      </td>
    </tr>

    <tr>
      <td class="body">Move Subscription To Lists:</td>
      <td>
        <input type="number" id="subscribe_move_from_num" />
      </td>
    </tr>
    <tr>
      <td class="body" />
      <td>
        <input type="number" id="subscribe_move_to_num" />
      </td>
    </tr>
    <tr>
      <td class="body">Move Subscription To Text:</td>
      <td>
        <input type="text" id="subscribe_move_text" />
      </td>
    </tr>
    <tr>
      <td class="body"></td>
      <td>
        <input type="text" id="subscribe_move_link" readonly="readonly" value=""></input>
        <input type="button" id="subscribe_move_but" value="Copy to Clipboard" onclick="copy_to_clipboard(event)"/>
      </td>
    </tr>
    <!-- END: Arbitrary Subscription Options -->

    <tr>
      <td colspan=2 class="body">
        <input type="checkbox" name="msg_track_open" value="1" <%if msg_track_open%>checked<%endif%>> Track number of users who open this message.<BR/>
        <input type="checkbox" name="msg_track_click" value="1" <%if msg_track_click%>checked<%endif%>> Track click rates.
      </td>
    </tr>
<%endif%>
</table>
<%include spellcheck_objects.html%>
<input type="hidden" name="emode" value="<%if emode%><%emode%><%else%>text<%endif%>">
<input type="hidden" name="editor_advanced" value="<%if editor_advanced%><%editor_advanced%><%endif%>">
<input type="hidden" name="switch_editor" value="">
