{literal}
<script language="JavaScript" type="text/JavaScript">

function PutAll() {
         var o=document.getElementsByName('select_all')	
         var i
         if (o[0].checked){                    
            o=document.getElementsByName('check')
            for (i=0; i<o.length; i++){                
                if (!o[i].disabled)
                    o[i].checked = true
            }            
         }
         else{
            o=document.getElementsByName('check')
            for (i=0; i<o.length; i++){                
                o[i].checked = false
            }            
         }             
}

function Add_sub(div, request){
	ajaxLoadingImage(1, div);
	//c = $("input[name='check']:checked").val();
	var j=0;
	var dat;
	dat = new Object();
	var res ='';
	$("input[name='check']:checked").each(function (i) {
        c = $(this).val();
		res = res + c +', ';
    });
	dat["ajax"] = 1;
	dat["id_subscribe"] = $("input[name='id_subscribe']").val();
	dat["page"] = $("input[name='page']").val();
	dat["sel"] = "adduser";
	dat["type"] = $("input[name='type']").val();
	dat["users_str"] = res;
		  
	$.post(request, dat, function(data){
		ajaxLoadingImage(0, div);
		$("#"+div).html(data);
	});

}
function PageList(id_div, par) {
	ajaxLoadingImage(1, 'users_table_div');
	$.post("index.php", par, function(data){
		ajaxLoadingImage(0, 'users_table_div');
		$('#users_table_div').html(data);
	});
}

</script>
{/literal}
{if $ajax eq 0}
	{include file="$admingentemplates/admin_top.tpl"}
	<div class="back">
		<a href="{$form.back}">{$lang.button.back}</a>
	</div>
	<div class="cr"></div>
	<div class="show_help" style="display: none;">&nbsp;</div>
	<div class="red_header">{$lang.newsletter.razdel_name}</div>
	<div class="cr">&nbsp;</div>
	<div class="cr">&nbsp;</div>
	<div class="help_text">
		<div class="close_help">
			<img src="{$site_root}{$template_root}/images/close_help.png" alt="">
		</div>
		<div class="help_body">
			<span class="help_title">{$lang.help}:</span>{$lang.admin_help.newsletter_subscribers}
		</div>
	</div>
	<div class="cr">&nbsp;</div>
	<ul class="tabs" style="line-height:0px;width: 100.5%;">
		<li>
			<a class="current">{$lang.admin_menu.nl_alerts}</a>
		</li>
		<li>
			<a href="newsletter/newsletters/index.php">{$lang.admin_menu.nl_newsletters}</a>
		</li>
		<li>
			<a href="newsletter/users/index.php">{$lang.admin_menu.nl_subscribers}</a>
		</li>
		<li>
			<a href="newsletter/lists/index.php">{$lang.admin_menu.nl_mailing_list}</a>
		</li>
{*    <li>
        <a href="newsletter/template/index.php">{$lang.admin_menu.nl_templates}</a>
    </li>
    <li>
        <a href="newsletter/forms/index.php">{$lang.admin_menu.nl_forms}</a>
    </li>*}
    <li>
        <a href="newsletter/archive/index.php">{$lang.admin_menu.nl_statistics}</a>
    </li>
{*    <li>
        <a href="newsletter/attaches/index.php">{$lang.admin_menu.nl_attachments}</a>
    </li>
    <li>
        <a href="newsletter/smtp_servers/index.php">{$lang.admin_menu.nl_smtp_servers}</a>
    </li>*}
		<li>
			<a href="newsletter/settings.php">{$lang.admin_menu.nl_settings}</a>
		</li>
	</ul>
	<div class="user_operation_line" style="width:100%;">
        <div class="uol_item" onclick="Add_sub('ajax', 'admin_newsletter.php');">
            <div class="uol_in_item">{$lang.newsletter.add_subscriber}</div>
        </div>        
	</div>
	
{*	<div>
	<a class="admin_button" href="#" onclick="javascript: location.href='{$form.back}'">{$lang.newsletter.back_to_subscribe}<span>&nbsp;</span></a>
	</div>*}
<div class="cr"></div>
	<div style="overflow:hidden;margin-bottom:10px;">
		<form name="search_form" action="{$form.action}" method="post">
			<table style="float:right;">
				<tr>
					{$form.search_hiddens}
					<td>
						<input type="text" style="width:100; height:20" name="search" value="{$search}" >
					</td>
					<td>
						<select name="s_type">
							{section name=s loop=$types}
							<option value="{$smarty.section.s.index_next}" {if $types[s].sel}selected{/if}>{$types[s].value}</option>
							{/section}
						</select>
					</td>
					<td>
						<a class="admin_button" name="search_submit" onclick="javascript: document.search_form.submit();" href="#">{$lang.button.search}<span>&nbsp;</span></a>
						<!--<input type="button" value="{$lang.button.search}" class="button" onclick="javascript: document.search_form.submit();" name="search_submit">-->
					</td>
				</tr>
			</table>
		</form>
	</div>

	<div id="ajax">
	<div>
		<form name="add_form" action="{$form.action}" method="post">
		<table cellpadding="0" cellspacing="0">
			<tr class="table_header">			
				<td width="1%" align="center"><input type="checkbox" id="select_all" name="select_all" onclick="PutAll()"></td>
				<td width="10%" align="center">{$lang.users.nick}</td>
				<td width="10%" align="center">{$lang.users.sname}</td>
				<td width="10%" align="center">{$lang.users.fname}</td>
				<td width="19%" align="center">{$lang.newsletter.email_subscriber}</td>
			</tr>
			{$form.add_hiddens}
			{if $users_arr}
				{section name=u loop=$users_arr}
				<tr {if $smarty.section.u.index mod 2 eq 1}class="table_row even"{else}class="table_row odd"{/if}>
					<td align="center">
						<input name="check" type="checkbox" value="{$users_arr[u].value}">
					</td>
					<td align="center">
						{$users_arr[u].login}
					</td>
					<td align="center">
						{$users_arr[u].sname}
					</td>
					<td align="center">
						{$users_arr[u].fname}
					</td>			
					<td align="center">
						{$users_arr[u].email}
					</td>
				</tr>
				{/section}
			{else}
				<tr bgcolor="#ffffff" height="40">
					<td class="main_error_text" align="center" colspan="5" bgcolor="#FFFFFF">{$lang.interests_spr.empty}</td>
				</tr>
			{/if}
			<tr class="table_header">			
				<td colspan="5">&nbsp;</td>			
			</tr>
		</table>
		</form>
	</div>
	<div style="width:30px;height:30px;">&nbsp;</div>
	<div>
	<table border=0 class="table_main" cellspacing="0" cellpadding="0" width="100%">	
		<tr class="table_header">
			<td align="left">{$lang.newsletter.name_subscriber}</td>
			<td align="center">{$lang.newsletter.email_subscriber}</td>
			<td align="right" width="100">{$lang.button.action}</td>
		</tr>
		{if $subscribers}
		{section name=spr loop=$subscribers}
		
			<tr {if $smarty.section.spr.index mod 2 eq 1}class="table_row even"{else}class="table_row odd"{/if}>
				<td  style="padding-left:10px;">{$subscribers[spr].name} ({$subscribers[spr].login})</td>
				<td align="center">{$subscribers[spr].email}</td>
				<td>
					<div class="block_action fr" style="display: none;">
						<!-- delete-->
						<div class="action_del" style="display: block;float:left;">
							<img height="16" alt="" src="{$site_root}{$template_root}/images/photo_delete.png"onclick="{literal}javascript: if(confirm({/literal}'{$form.confirm|escape:javascript}'{literal})){location.href={/literal}'{$subscribers[spr].deletelink}'{literal}}{/literal}">
						</div>
						<div style="width:10px;float:left;" class="fl">&nbsp;</div>
					</div>
				</td>
			</tr>
			
		{/section}
			{if $links}
			<tr bgcolor="#ffffff">
				<td height="20"  colspan=4 align="left">{$links.pages}</td>
			</tr>
			{/if}
		{else}
		<tr bgcolor="#ffffff" height="40">
			<td class="main_error_text" align="center" colspan="4" bgcolor="#FFFFFF">{$lang.newsletter.empty_users}</td>
		</tr>
		{/if}		
		<tr class="table_header">
			<td colspan="3">&nbsp;</td>			
		</tr>
	</table>
	</div>
	</div>
{else}
	<div>
		<form name="add_form" action="{$form.action}" method="post">
		<table cellpadding="0" cellspacing="0">
			<tr class="table_header">			
				<td width="1%" align="center"><input type="checkbox" id="select_all" name="select_all" onclick="PutAll()"></td>
				<td width="10%" align="center">{$lang.users.nick}</td>
				<td width="10%" align="center">{$lang.users.sname}</td>
				<td width="10%" align="center">{$lang.users.fname}</td>
				<td width="19%" align="center">{$lang.newsletter.email_subscriber}</td>
			</tr>
			{$form.add_hiddens}
			{if $users_arr}
				{section name=u loop=$users_arr}
				<tr {if $smarty.section.u.index mod 2 eq 1}class="table_row even"{else}class="table_row odd"{/if}>
					<td align="center">
						<input name="check" type="checkbox" value="{$users_arr[u].value}">
					</td>
					<td align="center">
						{$users_arr[u].login}
					</td>
					<td align="center">
						{$users_arr[u].sname}
					</td>
					<td align="center">
						{$users_arr[u].fname}
					</td>			
					<td align="center">
						{$users_arr[u].email}
					</td>
				</tr>
				{/section}
			{else}
				<tr bgcolor="#ffffff" height="40">
					<td class="main_error_text" align="center" colspan="5" bgcolor="#FFFFFF">{$lang.interests_spr.empty}</td>
				</tr>
			{/if}
			<tr class="table_header">			
				<td colspan="5">&nbsp;</td>			
			</tr>
		</table>
		</form>
	</div>
	<div style="width:30px;height:30px;">&nbsp;</div>
	<div>
	<table border=0 class="table_main" cellspacing="0" cellpadding="0" width="100%">	
		<tr class="table_header">
			<td align="left">{$lang.newsletter.name_subscriber}</td>
			<td align="center">{$lang.newsletter.email_subscriber}</td>
			<td align="right" width="100">{$lang.button.action}</td>
		</tr>
		{if $subscribers}
			{section name=spr loop=$subscribers}			
				<tr {if $smarty.section.spr.index mod 2 eq 1}class="table_row even"{else}class="table_row odd"{/if}>
					<td  style="padding-left:10px;">{$subscribers[spr].name} ({$subscribers[spr].login})</td>
					<td align="center">{$subscribers[spr].email}</td>
					<td>
						<div class="block_action fr" style="display: none;">
							<!-- delete-->
							<div class="action_del" style="display: block;float:left;">
								<img height="16" alt="" src="{$site_root}{$template_root}/images/photo_delete.png"onclick="{literal}javascript: if(confirm({/literal}'{$form.confirm|escape:javascript}'{literal})){location.href={/literal}'{$subscribers[spr].deletelink}'{literal}}{/literal}">
							</div>
							<div style="width:10px;float:left;" class="fl">&nbsp;</div>
						</div>
					</td>
				</tr>
				
			{/section}
			{if $links}
			<tr bgcolor="#ffffff">
				<td height="20"  colspan=4 align="left">{$links.pages}</td>
			</tr>
			{/if}
		{else}
			<tr bgcolor="#ffffff" height="40">
				<td class="main_error_text" align="center" colspan="4" bgcolor="#FFFFFF">{$lang.newsletter.empty_users}</td>
			</tr>
		{/if}		
			<tr class="table_header">
				<td colspan="3">&nbsp;</td>			
			</tr>
	</table>
	</div>

{/if}



{literal}
<script>
function users_add_click() {
	 var sel = document.add_form.userslist;
	 
	 var i=0;
	 var res ='';
	 var first = 0;
	 while (i<sel.options.length) {
		if(sel.options[i].selected==true)
		res = res + sel.options[i].value+', ';
	   ++i;
	 }
	 res = res.substring(0, res.length-2)
	 document.add_form.users_str.value=res;
}
</script>
{/literal}
{if $ajax eq 0}
	{include file="$admingentemplates/admin_bottom.tpl"}
{/if}