{if $ajax eq 0}
	{include file="$admin_nl_gentemplates/admin_nl_site_head.tpl"}
	<div class="user_operation_line">
        <div class="uol_item_nl" onclick="javascript: location.href='change.php?id=0'" style="width:150px;">
            <div class="uol_in_item_nl"><div>{$lang.newsletter.button.create}</div></div>
        </div>        
			{if $amount >= 1}
        <div class="uol_item_nl" onclick="DelItems('SubscribersForm')" style="width:150px;">
            <div class="uol_in_item_nl"><div>{$lang.newsletter.button.del_selected}</div></div>
        </div>        
			{/if}
        <div class="uol_item_nl" onclick="InactiveItems('SubscribersForm',1)" style="width:150px;">
            <div class="uol_in_item_nl"><div>{$lang.newsletter.users.deactivate_sel}</div></div>
        </div>        
        <div class="uol_item_nl" onclick="InactiveItems('SubscribersForm',0)" style="width:150px;">
            <div class="uol_in_item_nl"><div>{$lang.newsletter.users.activate_sel}</div></div>
        </div>        
        <div class="uol_item_nl" onclick="javascript: location.href='import_csv.php'" style="width:150px;">
            <div class="uol_in_item_nl"><div>{$lang.newsletter.users.import_from_csv}</div></div>
        </div>        
        <div class="uol_item_nl" onclick="javascript: location.href='export_csv.php'" style="width:150px;">
            <div class="uol_in_item_nl"><div>{$lang.newsletter.users.export_to_csv}</div></div>
        </div>        
	</div>
	<div class="cr"></div>
	<form name="SubscribersForm" id="SubscribersForm" action="index.php?list_id={$list_id}" method="post" enctype="application/x-www-form-urlencoded" onSubmit="set_unsub('SubscribersForm');" style="margin:0px;float:left;width:100%;">
	{if $amount > 0}
		<table border=0 cellspacing=0 cellpadding=0 width="100%" style="margin-top:-10px;">
		<tr class="listHeader" bgcolor="#FFFFFF">
		{if $amount > 0}
		<td valign="bottom">
				<table cellpadding="2" cellspacing="2" border="0">
				<tr>
					<td>
					<B>{$lang.newsletter.users.list}:</B> 
					<select name="Lists" onChange="location.href='index.php?list_id='+document.SubscribersForm.Lists.value" >
						<option value="0">{$lang.newsletter.users.all_subscribers}</option>
						{html_options selected=$list_id values=$list.id selected=$list_id output=$list.name}
					</select>
					<input type="hidden" name="sub_click" value="0">
					</td>
					
					{if $list_id >= 1}
					<td>
						<a class="admin_button" onclick="document.SubscribersForm.sub_click.value = 1; document.SubscribersForm.submit();">{$lang.newsletter.users.subscribe_selected}<span>&nbsp;</span></a>
					</td>
					<td>
						&nbsp;<A onmouseover=doTooltip(event,21) onmouseout=hideTip() href="#"><IMG src="{$site_root}{$template_root}/images/newsletter/icot.gif" width="12" height="12" border=0 align="absmiddle"></A>
					</td>
					{/if}
				</tr>
				</table>
			</td>{/if}<td>
			<!-- begin on page blok -->
			<table cellpadding="2" cellspacing="2" width="100%" border="0"><tr>
				<td align="center" width="50%">&nbsp;</td>
				<td align="right">{$list_name}&nbsp;{$lang.newsletter.users.total_subscribers}: {$total}&nbsp;&nbsp;&nbsp;{$lang.newsletter.users.total_users}: {$total_users}</td>
			</tr>
			<tr>
				<td align="right" colspan="2">{$lang.newsletter.on_page}: <select name="user_page" style="width:auto" onChange="document.location='index.php?user_page=' + document.SubscribersForm.user_page.value + '&lid={$lid}'+ '&list_id={$list_id}'">
				   {html_options values=$user_page_values selected=$user_page output=$user_page_output}
					</select>
				</td>
			</tr>
			</table>
			<!-- end on page blok -->
		</td></tr></table>
		
	{/if}
{/if}
<div id="tooltip" onclick="hideToolTip()" style="text-align:center; background-color: #FEF2CB; border: 1px dotted; text-align: {$default_left}; position:absolute; display:none; padding:5px;"></div>
{literal}
<script type="text/javascript">
	$(function() {
		$('#tool_tip_4 *').tooltip();
	});
</script>
{/literal}

	<div id="users_table_div" style="width:100%;">
		<table border=0 cellspacing=0 cellpadding=0 width="100%">
		<tr class="table_header">
			 <td width=1% align=center>
				<input type="checkbox" id="select_all" name="select_all" onclick="PutAll()">
				<!--<a href="#" title="{$lang.newsletter.all_title}" onClick="setCheckboxes('SubscribersForm',true)">{$lang.newsletter.all}</a><br>
				<a href="#" title="{$lang.newsletter.none_title}" onClick="setCheckboxes('SubscribersForm',false)">{$lang.newsletter.none}</a>-->
			</td>
			 <td width=13% align=left onclick="PageList('users_table_div','ajax=1&order=firstname&user_page={$user_page}&{$filter_url}')">
				<a title="{$lang.newsletter.users.by_first_name}">
					{$lang.newsletter.users.first_name}
				</a>
				{if $order == "firstname" and $end == ""} 
					<img src="{$site_root}{$template_root}/images/newsletter/arrow_up.gif" border="0" height="8"> 
				{elseif $order == "firstname" and $end <> ""} 
					<img src="{$site_root}{$template_root}/images/newsletter/arrow_down.gif" border="0" height="8">
				{/if}
			 </td>		
			 <td width=14% align=center onclick="PageList('users_table_div','ajax=1&order=secondname&user_page={$user_page}&{$filter_url}')">
				<a title="{$lang.newsletter.users.by_second_name}">
					{$lang.newsletter.users.second_name}
				</a>
				{if $order == "secondname" and $end == ""} 
					<img src="{$site_root}{$template_root}/images/newsletter/arrow_up.gif" border="0" height="8"> 
				{elseif $order == "secondname" and $end <> ""} 
					<img src="{$site_root}{$template_root}/images/newsletter/arrow_down.gif" border="0" height="8">
				{/if}
			 </td>
			 <td width=13% align=center onclick="PageList('users_table_div','ajax=1&order=company&user_page={$user_page}&{$filter_url}')">
				<a title="{$lang.newsletter.users.by_company}">
					{$lang.newsletter.users.company}
				</a>
				{if $order == "company" and $end == ""} 
					<img src="{$site_root}{$template_root}/images/newsletter/arrow_up.gif" border="0" height="8"> 
				{elseif $order == "company" and $end <> ""} 
					<img src="{$site_root}{$template_root}/images/newsletter/arrow_down.gif" border="0" height="8">
				{/if}
			</td>
			 <td width=11% align=center onclick="PageList('users_table_div','ajax=1&order=email1&user_page={$user_page}&{$filter_url}')">
				<a title="{$lang.newsletter.users.by_email}">
					{$lang.newsletter.users.email}
				</a>
				{if $order == "email1" and $end == ""} 
					<img src="{$site_root}{$template_root}/images/newsletter/arrow_up.gif" border="0" height="8"> 
				{elseif $order == "email1" and $end <> ""} 
					<img src="{$site_root}{$template_root}/images/newsletter/arrow_down.gif" border="0" height="8">
				{/if}
			 </td>
			 <td width=13% align=center>{$lang.newsletter.users.comment}</td>
			 <td width=20% align=center>{$lang.newsletter.users.list}</td>
			 <td width=20% align=right>{$lang.newsletter.users.action}</td>
		</tr>
						

		{section name=c loop=$users}
		<tr {if $smarty.section.c.index mod 2 eq 1}class="table_row even"{else}class="table_row odd"{/if} height=20>
		<td align=center>
			<input name="unsub[]" type="hidden" value="0">
			<input name="item[]" type="hidden" value="{$users[c].ID}">
			<input name="del[]" type="checkbox" value="{$users[c].ID}" 
			{section name=j loop=$users[c].LISTID}
				{if ( ($users[c].LISTID[j] == $list_id) and ($users[c].STATUS_SUBSCRIBE[j] != $config.status_subscribe_val.unsubscribe) ) } checked {/if}
			{/section} >{$c}
		</td>
		<td align=left>{$users[c].FIRSTNAME} </td>
		<td align=center>{$users[c].SECONDNAME}</td>
		<td align=center>{$users[c].COMPANY}</td>
		<td align=center>{$users[c].EMAIL1}</td>
		<td align=center>{$users[c].COMMENT}</td>
		<td align=center valign="middle">
		{section name=j loop=$users[c].LIST}
		  {if ( $users[c].STATUS_SUBSCRIBE[j] != $config.status_subscribe_val.unsubscribe) }  {$users[c].LIST[j]} ({$users[c].DATE_STATUS[j]|date_format:"%b %d, %Y"})<br>{/if}
		{/section}</td>
		<td align=right>				
				<div class="block_action fr" style="display: none;">
					<div class="action_edit" style="display: block;float:left;">{if $users[c].STATUS}<img src="{$site_root}{$template_root}/images/newsletter/subs.gif" onmouseover=doTooltip(event,51) onmouseout=hideTip()>{else}<img src="{$site_root}{$template_root}/images/newsletter/subs_inactive.gif"  onmouseover=doTooltip(event,51) onmouseout=hideTip()>{/if}</div>
					<div style="width:10px;" class="fl">&nbsp;</div>
					<div class="action_edit" style="display: block;float:left;">
						<img height="16" alt="" src="{$site_root}{$template_root}/images/edit.png" onclick="document.location='change.php?id={$users[c].ID}'" onmouseout="javascript:hideToolTip();" onmouseover="javascript: showToolTip(event,'{$lang.button.edit}');return false">
					</div>
					<div style="width:10px;" class="fl">&nbsp;</div>
					<div class="action_del" style="display: block;float:left;">
						<img height="16" alt="" src="{$site_root}{$template_root}/images/photo_delete.png" onclick="if (confirm('Are you sure you want to delete this user?')) document.location='index.php?did={$users[c].ID}'" onmouseout="javascript:hideToolTip();" onmouseover="javascript: showToolTip(event,'{$lang.button.delete}');return false">
					</div>
					<div style="width:10px;" class="fl">&nbsp;</div>
				</div>
		</td>
		{sectionelse}
		<tr height="40">
			<td class="main_error_text" bgcolor="#FFFFFF" align="left" colspan="11">{$lang.newsletter.users.no_subscribers}</td>
		</tr>
		{/section}
		</tr>

		<tr class="table_header">
			<td class="listHeader" colspan="11">
				{*$navigation*}
				{foreach item=item from=$navigation.pages}
					&nbsp;<a onclick="PageList('users_table_div', '{$item.link}');" class="page_link" {if $item.selected} style=" font-weight: bold; text-decoration: none;" {/if}>{$item.name}</a>&nbsp;
				{/foreach}	
				<div class="page_navigation">
					{if $navigation.previous}
						<a onclick="PageList('users_table_div', '{$navigation.previous}');">< {$lang.content.previous} {$per_page}</a>
					{/if}
					{if $navigation.next}
						<a onclick="PageList('users_table_div', '{$navigation.next}');">{$lang.content.next} {$per_page} ></a>
					{/if}
				</div>			
			</td>
		</tr>
		</table>
	</div>
{*{if $amount <= 0}
<div align="center"><strong>{$lang.newsletter.users.no_subscribers}</strong></div>
{/if}*}

</form>
{if $ajax eq 0}
{include file="$admin_nl_gentemplates/admin_nl_site_foot.tpl"}
{/if}
<script type="text/javascript">
{literal}
		function showToolTip(e,text){
			if(document.all)e = event;
			var obj = document.getElementById('tooltip');
			obj.innerHTML = text;
			obj.style.display = 'block';
			var st = Math.max(document.body.scrollTop,document.documentElement.scrollTop);
			if(navigator.userAgent.toLowerCase().indexOf('safari')>=0)st=0;
			var leftPos = e.clientX - $('#tooltip').width()-10;
			if(leftPos<0)leftPos = 0;
			obj.style.left = leftPos + 'px';
			obj.style.top = e.clientY - obj.offsetHeight +40 + st + 'px';
		}
		function hideToolTip(){
			document.getElementById('tooltip').style.display = 'none';
		}
{/literal}		
</script>		
{literal}
<script>
function set_unsub(the_form) {
    var elts       = document.forms[the_form].elements['del[]'];
    var elts_unsub = document.forms[the_form].elements['unsub[]'];
    var elts_cnt = 0
	if (typeof(elts.length) != 'undefined') {
		elts_cnt = elts.length
		for (var i = 0; i < elts_cnt; i++) {
            if (elts[i].checked) {		
				elts_unsub[i].value = 1;
			}
        }
	} 
	else if (typeof(elts.value) != 'undefined') {
		if (elts.checked) {		
			elts_unsub.value = 1;
		}	
	}
    return true;
}
function check_chekboxes(the_form) {
    var elts       = document.forms[the_form].elements['del[]'];
	var is_ok = false;
    var elts_cnt = 0;

	if (typeof(elts.length) != 'undefined') {
		elts_cnt = elts.length
		for (var i = 0; i < elts_cnt; i++) {
            if (elts[i].checked) {		
				is_ok = true;
				break;
			}
        }
	}	
	else if (typeof(elts.value) != 'undefined') {
		if (elts.checked) {		
			is_ok = true;			
		}	
	}
	return is_ok;
}

function DelItems(the_form) {
    var elts       = document.forms[the_form].elements['del[]'];
	var is_ok = false;
    var elts_cnt = 0;

	if (typeof(elts.length) != 'undefined') {
		elts_cnt = elts.length
		for (var i = 0; i < elts_cnt; i++) {
            if (elts[i].checked) {		
				is_ok = true;
				break;
			}
        }
	}	
	else if (typeof(elts.value) != 'undefined') {
		if (elts.checked) {		
			is_ok = true;			
		}	
	}
	if (is_ok) {
		if (document.SubscribersForm.sub_click.value == 0) {
			if (confirm('{/literal}{$lang.newsletter.users.conf_del_sel|escape:javascript}{literal}')) document.SubscribersForm.submit();
		}
	}
	else alert('{/literal}{$lang.newsletter.users.choose_subscr|escape:javascript}{literal}');
	return false;
}
function InactiveItems(the_form, is_inactive) {
	if (check_chekboxes(the_form)) {
		if (is_inactive) {
			document.SubscribersForm.sub_click.value = "inactive";
			text = '{/literal}{$lang.newsletter.users.conf_deactiv_sel_subscr|escape:javascript}{literal}';
		}
		else {
			document.SubscribersForm.sub_click.value = "active";
			text = '{/literal}{$lang.newsletter.users.conf_activ_sel_subscr|escape:javascript}{literal}';
		}
		
		if (confirm(text)) document.SubscribersForm.submit();
	}
	else alert('{/literal}{$lang.newsletter.users.choose_subscr|escape:javascript}{literal}');
	return false;
}

function PutAll() {
         var o=document.getElementsByName('select_all')	
         var i
         if (o[0].checked){                    
            o=document.getElementsByName('del[]')
            for (i=0; i<o.length; i++){                
                if (!o[i].disabled)
                    o[i].checked = true
            }            
         }
         else{
            o=document.getElementsByName('del[]')
            for (i=0; i<o.length; i++){                
                o[i].checked = false
            }            
         }             
}
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}