<script type="text/javascript">
	$(document).ready(function(){
		{{if isset( $smarty.get.activeTabId )}}$('ul.tab-headers li a[href="#{{$smarty.get.activeTabId}}"]').trigger('click');{{/if}}
	});
</script>

<div class="tabbed">
	<div class="clear"></div>
	<ul class="tab-headers">
	<li><a href="#newsletter-list">{{$lang.Newsletter}}</a></li>
	<li><a href="#newsletter-edit">{{$lang.Newsletter_edit}}</a></li>
	<li><a href="#newsletter-config">{{$lang.Newsletter_config}}</a></li>
	</ul>
	<h1>{{$lang.Newsletter}}</h1>

	<div class="tab" id="newsletter-list">
	<script type="text/javascript">
	$(document).ready(function(){
		$("form#newsletter-list-form").validate();
		$("form#newsletter-list-form #newsletter-list-title").rules("add", {required: true});
	});
	</script>
	<h1>{{$lang.Newsletter_list}}</h1>
	<form action="?p={{$_GET.p}}" method="post" id="newsletter-list-form">
	<fieldset>
	<table class="details">
	<tr>
		<th class="name">{{$lang.Send_to}}</th>
		<td class="value">
			<select multiple="multiple" class="multiselect" size="10" name="aSendTo[]">
				<option value="subscribers" selected="selected">{{$lang.Subscribers}}</option>
				{{foreach from=$aUserGroups item=aGroup}}
					<option value="group-{{$aGroup.iGroup}}">{{$lang.Group_users}}: {{$aGroup.sName}}</option>
				{{/foreach}}
				<option value="all-clients">{{$lang.All_users}}</option>
				<option value="buyers">{{$lang.Buyers}}</option>
			</select>
		</td>
		<td class="help"></td>
	</tr>
	<tr>
	<th class="name">{{$lang.Newsletter_title}}</th><td class="value"><input id="newsletter-list-title" name="sTitle" type="text" class="input" alt="simple" size="150" value="{{$config.newsletter_def_title}}" maxlength="200" /></td><td class="help"></td>
	</tr><tr>
	<th class="name">{{$lang.Newsletter_body}}</th><td class="value" colspan="2">{{htmlEditor sName='newsletter_content' iH='280px' iW='100%' sContent=$newsletter_content}}</td>
	</tr><tr class="actions">
	<td colspan="3" class="save"><input type="submit" class="submit" value="{{$lang.Send_newsletter}}" name="sOption" /></td>
	</tr>
	</table>
	</fieldset>
	</form>
	</div>
	<div class="tab" id="newsletter-edit">
	<h1>{{$lang.Newsletter_edit}}</h1>
	{{if count( $aNewsletterEmails ) > 0}}
	<table class="list">
		<thead>
			<tr>
				<th class="name">{{$lang.Email}}</th>
				<th class="actions">{{$lang.Actions}}</th>
			</tr>
		</thead>
		{{foreach from=$aNewsletterEmails item=sEmail}}
			<tr>
				<td class="name">{{$sEmail}}</td>
				<td class="actions">
					<a href="?p={{$aActions.f}}-delete&amp;sEmail={{$sEmail}}" onclick="return del( );"><img src="{{$config.dir_templates}}admin/images/ico/delete.png" alt="{{$lang.Delete}}" title="{{$lang.Delete}}"/></a>
				</td>
			</tr>
		{{/foreach}}
		<tr class="actions">
			<td class="left" colspan="3"><input type="submit" class="submit" value="&laquo; {{$lang.return}}"  onclick="location.href = '?p=newsletter-form'; return false;"></td>
		</tr>
	</table>
	{{else}}
		<div class="msg" id="error">
			<img src="{{$config.dir_templates}}admin/images/ico/msg_error.png" class="imgv" alt="" /> {{$lang.Data_not_found}}
		</div>
	{{/if}}
	</div>
	<div class="tab" id="newsletter-config">
	<form action="?p={{$_GET.p}}" method="post" name="form">
	<fieldset>
	<table class="details">
	<tr>
	<th class="name">{{$lang.Newsletter_email}}</th><td class="value"><input type="text" alt="email" class="input" name="newsletter_email" value="{{$config.newsletter_email}}" /></td><td class="help"><img class="tTip info" src="templates/images/info.png"  title="{{$lang.help_newsletter_email}}" /></td>
	</tr><tr>
	<th class="name">{{$lang.Newsletter_def_title}}</th><td class="value"><input type="text" class="input" name="newsletter_def_title" value="{{$config.newsletter_def_title}}" /></td><td class="help"><img class="tTip info" src="templates/images/info.png"  title="{{$lang.help_newsletter_def_title}}" /></td>
	</tr><tr>
	<th class="name">{{$lang.Newsletter_def_content}}</th><td class="value" colspan="2">{{htmlEditor sName='newsletter_def_content' iH='280px' iW='100%' sContent=$newsletter_def_content}}</td>
	</tr><tr class="actions">
	<td colspan="3" class="save"><input type="submit" class="submit" value="{{$lang.Save}} &raquo;" name="sOption" /></td>
	</tr>
	</table>
	</fieldset>
	</form>
	</div>
	<div class="clear"></div>
</div>