{include file="$admin_nl_gentemplates/admin_nl_site_head.tpl"}
{literal}
<script>
function DeleteAttach(id_attach){
	if (confirm("{/literal}{$lang.newsletter.nls.conf_del_attach|escape:javascript}{literal}")){
		document.location = "change.php?del_attach="+id_attach;
	}
}
</script>
{/literal}
<div>
        <div class="panel_section" style="width: 100%">
        	<div class="panel_content" style="width: 97%">			
<form method="POST" action="change.php?id={$id}" enctype="multipart/form-data" onSubmit="return CheckForm()" name="myform" style="margin:0px">
<input type="hidden" name="action" value="change">
<input type="hidden" name="format" value="html">
{if $message != ""}<font  class="main_header_text" color="red"><b>{$message}</b></font><br>{/if}
<table border=0 cellspacing=0 cellpadding=0 width="100%">
	<tr>
		<td style="padding-bottom: 20px;">
			{$lang.newsletter.nls.send_date} {$smarty.now|date_format:"%A, %B %d, %Y"}):<br>
			<table>
			<tr>
				<td>
					<input style="width: 220px; margin-top: 10px;" type="text" name="date_send" value="{if $date_send == NULL} Newsletter is sent manually {else}{$date_send}{/if}" size=40 class="inpBox">
					<a href="#" title="{$lang.newsletter.nls.ind_send_date}" onClick="var CalendarWin = window.open('../calendar/calendar.htm','', 'resizable=no,scrollbars=no,location=no,directories=no,status=no,toolbar=no,menubar=no,width=165,height=165,left=250,top=150'); return false"><img src="{$site_root}{$template_root}/images/newsletter/c2.jpg" border="0" align="absmiddle"></a>
				</td>
				<td>
					<a class="admin_button" onClick="document.myform.date_send.value='Newsletter is sent manually'">{$lang.newsletter.nls.nl_send_manual}<span>&nbsp;</span></a>
				</td>
				<td>&nbsp;
					<A onmouseover="doTooltip(event,9)" onmouseout=hideTip() href="#">
						<IMG src="{$site_root}{$template_root}/images/newsletter/icot.gif" width="12" height="12" border=0 align="absmiddle">
					</A>
				</td>
			</tr>
			</table>
		</td>
	</tr>
	<tr>
		<td style="padding-bottom: 20px;">
			{$lang.newsletter.nls.mailing_lists}:<br>
			<select style="width: 220px; margin-top: 10px;" name=list[] tabindex="3" multiple size=5 class="inpBox">
				{if $lists}
				{section name=k loop=$lists}
				<option value="{$lists[k].id}" {section name=j loop=$list_array} {if $lists[k].id == $list_array[j]} selected {/if} {/section}>{$lists[k].name} ({$lists[k].count} subscribers)
				</option>
				{/section}
				{else}
				<option style="width: 135px;">&nbsp;</option>
				{/if}
			</select>
			&nbsp;
			<A style="vertical-align:top;" onmouseover=doTooltip(event,10) onmouseout=hideTip() href="#">
				<IMG src="{$site_root}{$template_root}/images/newsletter/icot.gif" width="12" height="12" border=0 align="absmiddle">
			</A>
			<!--<b>Mailing lists:</b><br>
			<select name=list[] multiple size=5 class="inpBox" style="width: 200px">
			{section name=k loop=$lists}
				<option value="{$lists[k].id}" 
					{section name=j loop=$list_array}
						{if $lists[k].id == $list_array[j]} selected {/if}
					{/section}	
				>{$lists[k].name} ({$lists[k].count} subscribers)</option>
			{/section}
			</select>
			&nbsp;<A onmouseover=doTooltip(event,10) onmouseout=hideTip() href="#"><IMG src="{$site_root}{$template_root}/images/newsletter/icot.gif" width="12" height="12" border=0 align="absmiddle"></A>-->	
		</td>
	</tr>
	<tr>
		<td style="padding-bottom: 20px;">
			{$lang.newsletter.nls.list_status}:<br>
			<select style="width: 220px; margin-top: 10px;" name=match_confirm id="match_list" class="inpBox" tabindex="2">
				<option value="0" {if $rel.match_confirm eq 0}selected{/if}>{$lang.newsletter.both}</option>
				<option value="1" {if $rel.match_confirm eq 1}selected{/if}>{$lang.newsletter.nls.confirm_subscr}</option>
				<option value="2" {if $rel.match_confirm eq 2}selected{/if}>{$lang.newsletter.nls.unconfirm_subscr}</option>
			</select>&nbsp;
			<A style="vertical-align:top;" onmouseover=doTooltip(event,71) onmouseout=hideTip() href="#">
				<IMG src="{$site_root}{$template_root}/images/newsletter/icot.gif" width="12" height="12" border=0 align="absmiddle">
			</A>
		</td>
	</tr>
	<tr>
		<td style="padding-bottom: 20px;">
			{$lang.newsletter.nls.general_status}:&nbsp;<br>
			<select style="width: 220px; margin-top: 10px;" name=match_status id="match_status" class="inpBox" tabindex="3">
				<option value="0" {if $rel.match_status eq 0}selected{/if}>{$lang.newsletter.both}</option>
				<option value="1" {if $rel.match_status eq 1}selected{/if}>{$lang.newsletter.nls.active}</option>
				<option value="2" {if $rel.match_status eq 2}selected{/if}>{$lang.newsletter.nls.inactive}</option>
			</select>&nbsp;
			<A style="vertical-align:top;" onmouseover=doTooltip(event,72) onmouseout=hideTip() href="#">
				<IMG src="{$site_root}{$template_root}/images/newsletter/icot.gif" width="12" height="12" border=0 align="absmiddle">
			</A>
		</td>
	</tr>
	<tr>
		<td style="padding-bottom: 20px;">
			{$lang.newsletter.nls.subject}:<br>
			<input type="text" name="subject" value="{$rel.subject}"  style="width: 550px; margin-top: 10px;" class="inpBox">
			 &nbsp;
			 <A style="vertical-align:top;" onmouseover=doTooltip(event,12) onmouseout=hideTip() href="#">
				<IMG src="{$site_root}{$template_root}/images/newsletter/icot.gif" width="12" height="12" border=0 align="absmiddle">
			</A>
			<br>
		</td>
	</tr>
	<tr>
		<td style="padding-bottom: 20px;">
			{$lang.newsletter.nls.message}:<br/>
			<div style="width: 562px; float: left; padding: 10px 0;">
                <input type="radio" name="bodyfrom" id="rad1" value="text" checked>&nbsp;{$lang.newsletter.nls.from_wyswyg}
    			&nbsp;
            </div>
			<A onmouseover="doTooltip(event,13)" onmouseout="hideTip()" href="#">
				<IMG src="{$site_root}{$template_root}/images/newsletter/icot.gif" width="12" height="12" border=0 align="absmiddle">
			</A>
			<br/>
			{$redactor}
			<textarea id="body" name="body" class="redactor_normal"></textarea>
			<p style="padding-left: 388px">
				[ <a href="javascript:void(0)" onClick="toggleMergePopup(1,1)">{$lang.newsletter.nls.insert_html_merge_field}</a> ]
				&nbsp;
				<A onmouseover="doTooltip(event,14)" onmouseout="hideTip()" href="#">
					<IMG src="{$site_root}{$template_root}/images/newsletter/icot.gif" width="12" height="12" border=0 align="absmiddle">
				</A>
			</p>
            
            <div style="margin-bottom: 10px;">
			<div style="float: left; width: 150px; margin-right: 10px;"><input type="radio" name="bodyfrom" id="rad2" value="file">&nbsp;{$lang.newsletter.nls.insert_html_merge_field_from_file}: </div>
			<input type="file" name="bodyfile" onClick="javascript:rad2.checked=true;" class="inpBox" size="17" style="width: 200px">
			&nbsp;
			<A onmouseover="doTooltip(event,15)" onmouseout="hideTip()" href="#">
				<IMG style="vertical-align:top;" src="{$site_root}{$template_root}/images/newsletter/icot.gif" width="12" height="12" border=0 align="absmiddle">
			</A>
			</div>
            

			<div style="float: left; width: 150px; margin-right: 10px;"><input type="radio" name="bodyfrom" id="rad3" value="link">&nbsp;{$lang.newsletter.nls.OR_from_URL}: </div>
			<input type="text" name="bodyurl" value="http://" onClick="javascript:rad3.checked=true;" class="inpBox" style="width: 200px">
			&nbsp;
			<A style="vertical-align:top;" onmouseover="doTooltip(event,16)" onmouseout="hideTip()" href="#">
				<IMG style="vertical-align:top;" src="{$site_root}{$template_root}/images/newsletter/icot.gif" width="12" height="12" border=0 align="absmiddle">
			</A>
			<br>

			<!--Attach file: <input type="file" name="attach" class="inpBox" style="width: 200px">
			&nbsp;<A onmouseover="doTooltip(event,17)" onmouseout="hideTip()" href="#"><IMG src="{$site_root}{$template_root}/images/newsletter/icot.gif" width="12" height="12" border=0 align="absmiddle"></A>
			<br> 
			{if $count_attach > 0}
			Attached file(s):
			&nbsp;<A onmouseover="doTooltip(event,20)" onmouseout="hideTip()" href="#"><IMG src="{$site_root}{$template_root}/images/newsletter/icot.gif" width="12" height="12" border=0 align="absmiddle"></A>
			<br> 

			<table cellpadding="2" cellspacing="5">
			{section name=j loop=$attach}
			<tr><td><a href="{$url_file}{$attach[j].file_name}" target="_blank">{$attach[j].file_name} ({$attach[j].file_size})</a></td><td><a href="#" onClick="DeleteAttach({$attach[j].id})">Delete file</a></td></tr>
			{/section}
			</table>
			{/if}-->
			<br>
		</td>
	</tr>
	<tr>
		<td style="padding-bottom: 20px;">
			{$lang.newsletter.nls.attachments}:<br>
			<select name="attaches[]" id="attaches" multiple size=5  tabindex="10" class="inpBox" style="width:220px; margin-top: 10px;">
				{section name=k loop=$attaches}
					<option value="{$attaches[k].id}" {section name=j loop=$attach_array} {if $attaches[k].id == $attach_array[j]} selected {/if} {/section}>
				{$attaches[k].name} ({$attaches[k].file_size}). Description: {$attaches[k].description}
				</option>
				{/section}
			</select>
			&nbsp;
			<A style="vertical-align:top;" onmouseover=doTooltip(event,17) onmouseout=hideTip() href="#">
				<IMG style="margin-top: 10px;" src="{$site_root}{$template_root}/images/newsletter/icot.gif" width="12" height="12" border=0 align="absmiddle">
			</A>
		</td>
	</tr>
	<tr>
		<td style="padding-bottom: 20px;">
			{$lang.newsletter.nls.priority}:<br>
				<select name="priority" class="inpBox" id="priority" style="width: 220px; margin-top: 10px;">
				{html_options values=$priority_values selected=$priority output=$priority_output}
				</select>
			&nbsp;<A style="vertical-align:text-top;" style="vertical-align:top;" onmouseover=doTooltip(event,11) onmouseout=hideTip() href="#"><IMG src="{$site_root}{$template_root}/images/newsletter/icot.gif" width="12" height="12" border=0 align="absmiddle"></A>
		</td>
	</tr>
	<tr>
		<td style="padding-bottom: 20px;">
		{$lang.newsletter.nls.from_email}:<br>
		<input style="width: 220px; margin-top: 10px;" type="text" name="from_email" value="{$rel.from_email}" size=40 tabindex="11" class="inpBox" maxlength="255">
		&nbsp;<A style="vertical-align:text-top;"   style="vertical-align:text-top;" onmouseover=doTooltip(event,73) onmouseout=hideTip() href="#"><IMG src="{$site_root}{$template_root}/images/newsletter/icot.gif" width="12" height="12" border=0 align="absmiddle"></A>
		</td>
	</tr>
	<tr>
		<td style="padding-bottom: 20px;">
		{$lang.newsletter.nls.from_name}:<br>
		<input style="width: 220px; margin-top: 10px;" type="text" name="from_name" value="{$rel.from_name}" size=40 tabindex="12" class="inpBox" maxlength="255">
		&nbsp;<A style="vertical-align:text-top;" onmouseover=doTooltip(event,74) onmouseout=hideTip() href="#"><IMG src="{$site_root}{$template_root}/images/newsletter/icot.gif" width="12" height="12" border=0 align="absmiddle"></A>
		</td>
	</tr>
	<tr>
		<td style="padding-bottom: 20px;">
		{$lang.newsletter.nls.reply_to_email}:<br><input style="width: 220px;" type="text" name="reply_to" value="{$rel.reply_to}" size=40 class="inpBox" tabindex="13" maxlength="255">
		&nbsp;<A style="vertical-align:text-top;" onmouseover=doTooltip(event,75) onmouseout=hideTip() href="#"><IMG src="{$site_root}{$template_root}/images/newsletter/icot.gif" width="12" height="12" border=0 align="absmiddle"></A>
		</td>
	</tr>
	<tr>
		<td style="padding-bottom: 20px;">
		<div style="float: left; width: 220px;">{$lang.newsletter.nls.notify_sending_starts}:<input style="margin-left: 35px;" type="checkbox" name="notify_start" value="1" {if $rel.notify_start}checked{/if}></div>
	 &nbsp;&nbsp;<A onmouseover=doTooltip(event,76) onmouseout=hideTip() href="#"><IMG src="{$site_root}{$template_root}/images/newsletter/icot.gif" width="12" height="12" border=0 align="absmiddle"></A>
		</td>
	</tr>
	<tr>
		<td style="padding-bottom: 20px;">
		<div style="float: left; width: 220px;">{$lang.newsletter.nls.notify_sending_finished}:<input type="checkbox" name="notify_end" value="1" {if $rel.notify_end}checked{/if}></div>
	 &nbsp;&nbsp;<A onmouseover=doTooltip(event,77) onmouseout=hideTip() href="#"><IMG src="{$site_root}{$template_root}/images/newsletter/icot.gif" width="12" height="12" border=0 align="absmiddle"></A>
		</td>
	</tr>
	<tr>
		<td style="padding-bottom: 20px;">
		<div style="float: left; width: 220px;">{$lang.newsletter.nls.email_for_notifications}:<br><input style="width: 200px;" type="text" name="notify_email" value="{$rel.notify_email}" size=40 class="inpBox" maxlength="255"></div>
		&nbsp;&nbsp;<A style="vertical-align:top;" onmouseover=doTooltip(event,78) onmouseout=hideTip() href="#"><IMG src="{$site_root}{$template_root}/images/newsletter/icot.gif" width="12" height="12" border=0 align="absmiddle"></A>	
		</td>
	</tr>
</table>
	{literal}
	<script language="JavaScript" src="editor_js/genmove.js"></script>
	<div id="mergeDiv" style="position:absolute; overflow-y:auto; top:10; width: 420; height:180; border: solid 1px black; z-index: 10; background: #fff;" >
		<div class="handle" handlefor="mergeDiv" id="title" style="padding: 3px; background-color:#0066CC; height:20px; color:#FFFFFF; border-bottom: 1px solid #999999">
			&nbsp;{/literal}{$lang.newsletter.nls.html_merge_fields}{literal}
		</div>
		<table width="100%" cellpadding="0">
			<tr>
				<td colspan="3" class="main_header_text">
					<div style="position: absolute; right:0px;" align="right">[<a class="menutext" href="javascript:void(0)" onClick="mergeDiv.style.display='none';">{/literal}{$lang.newsletter.button.cancel}{literal}</a>]&nbsp;</div>
					Basic Tags
				</td>
			</tr>
			<tr>
				<td class="main_content_text">{/literal}{$lang.newsletter.nls.html_merge_fields}{literal}</td>
				<td class="main_content_text">%BASIC:EMAIL%</td>
				<td class="main_content_text"><a href="javascript: InsertCode('BASIC:EMAIL')">{/literal}{$lang.newsletter.button.insert}{literal}</a></td>
			</tr>
			<tr><td colspan="3"></td></tr>
			<tr>
				<td class="main_content_text">{/literal}{$lang.newsletter.nls.first_name}{literal}</td>
				<td class="main_content_text">%BASIC:FIRSTNAME%</td>
				<td class="main_content_text"><a href="javascript: InsertCode('BASIC:FIRSTNAME')">{/literal}{$lang.newsletter.button.insert}{literal}</a></td>
			</tr>
			<tr><td colspan="3"></td></tr>
			<tr>
				<td class="main_content_text">{/literal}{$lang.newsletter.nls.second_name}{literal}</td>
				<td class="main_content_text">%BASIC:SECONDNAME%</td>
				<td class="main_content_text"><a href="javascript: InsertCode('BASIC:SECONDNAME')">{/literal}{$lang.newsletter.button.insert}{literal}</a></td>
			</tr>
			<tr><td colspan="3"></td></tr>
			<tr>
				<td class="main_content_text">{/literal}{$lang.newsletter.nls.unsubscribe_link}{literal}</td>
				<td class="main_content_text">%BASIC:UNSUBLINK%</td>
				<td class="main_content_text"><a href="javascript: InsertCode('BASIC:UNSUBLINK')">{/literal}{$lang.newsletter.button.insert}{literal}</a></td>
			</tr>
			<!--tr><td colspan="3"></td></tr>
			<tr><td colspan="3" class="main_header_text">{/literal}{$lang.newsletter.nls.unsubscribe_link}{literal}</td></tr-->
		{/literal}
		{section name=c loop=$images}
			<tr>
				<td class="main_content_text">{$images[c].name}</td>
				<td class="main_content_text">%IMAGE:{$images[c].id}%</td>
				<td class="main_content_text"><a href="javascript: InsertCode('IMAGE:{$images[c].id}')">{$lang.newsletter.button.insert}</a></td>
			</tr>
			<tr><td colspan="3"></td></tr>
		{/section}    
		</table>
	</div>

       {literal}<script>

            var whichField = 0;
            var whichWYSIWYG = 1;
            var whichText = 0;

            mergeDiv.style.display = "none";

            function toggleMergePopup(which, whichEditor)
            {
                whichField = which;
                whichWYSIWYG = whichEditor;
                whichText = whichEditor;

                var x = ((document.body.clientWidth / 2) - 210) + document.body.scrollLeft;
                var y = ((document.body.clientHeight / 2) - 150) + document.body.scrollTop;

                mergeDiv.style.left = x;
                mergeDiv.style.top = y;
                mergeDiv.style.display = "inline";

                whichField = which;
            }

            function InsertCode(theCode)
            {
                window.frames[0].focus();
				if(document.selection){ //stupid IE
					var sel = document.selection;
					var r = sel.createRange();
					r.pasteHTML("%" + theCode + "%");
				}else{ //BROWSERS
					$body.execCommand('inserthtml', "%" + theCode + "%");
				}
				mergeDiv.style.display = "none";
            }

        </script>
    

                <script language="JavaScript">

                    function addUnsubscribeLink(whichBox)
                    {
                        if(whichBox == 1) //HTML
                        {
                            window.frames['wysiwyg_rEdit'].focus();     

                            var sel = document.selection;
                            var r = sel.createRange();
                            r.pasteHTML("%BASIC:UNSUBLINK%");
                            mergeDiv.style.display = "none";
                        }
                        else //Text
                        {
                            var t = document.getElementById("TEXTBODY");
                            t.value += "%BASIC:UNSUBLINK%";
                            t.focus();
                        }
                    }

                    function PreparePreview()
                    {
                        if(CheckForm())
                        {
                            document.forms[0].target = "_blank";
                            prevAction = document.forms[0].action;
                            document.forms[0].action = "/";
                            document.forms[0].submit();
                            document.forms[0].target = "";
                            document.forms[0].action = prevAction;
                        }
                    }

                    function extractHTMLtoText()
                    {
                        var f = document.forms[0];
                        f.TEXTBODY.value = document.body.innerText;
                    }

                    function CheckForm()
                    {
                        var f = document.forms[0];
                       
                        if((f.wysiwyg.value == "") && (f.bodyurl.value == "" || f.bodyurl.value == "http://")&& f.bodyfile.value == "")
                        {
                            alert("{/literal}{$lang.newsletter.nls.enter_html_or_spec_file|escape:javascript}{literal}");
                            return false;
                        }
              
                        return true;
                    }
                
                </script>



<!-- WYSIWYG end -->
{/literal}
</form>
</div>
</div>
<br>
<a class="admin_button_major" onclick="document.myform.submit();">{$lang.newsletter.button.save}<span>&nbsp;</span></a>
</div>
{include file="$admin_nl_gentemplates/admin_nl_site_foot.tpl"}
