{if $ajax eq 0}
	{include file="$admin_nl_gentemplates/admin_nl_site_head.tpl"}
	<div class="user_operation_line">
        <div class="uol_item" onclick="javascript: location.href='create_format.php'">
            <div class="uol_in_item">{$lang.newsletter.button.create}</div>
        </div>        
        <div class="uol_item" onclick="javascript: location.href='schedule.php'">
            <div class="uol_in_item">{$lang.newsletter.nls.delivery_schedule}</div>
        </div>        
			{if $amount >= 1}
        <div class="uol_item" onclick="DelItems('NewsletterForm')">
            <div class="uol_in_item">{$lang.newsletter.button.del_selected}</div>
        </div>        
			{/if}
	</div>
	<div class="cr"></div>
	<br/><br/><br/>
	<form name="NewsletterForm" action="index.php" enctype="application/x-www-form-urlencoded" method="post" style="margin:0px">
	<div style="width:30px;" >&nbsp;</div>
	<!--<input type=button class=button onClick='document.location.href="image.php"' value="Image manager">-->
	{if $amount > 0}
		<div style="float:right;">{$lang.newsletter.on_page}: 
			<select name="newsletter_page" style="width:auto" onChange="document.location='index.php?newsletter_page=' + document.NewsletterForm.newsletter_page.value">
				{html_options values=$newsletter_page_values selected=$newsletter_page output=$newsletter_page_output}
			</select>&nbsp;
			<A onmouseover=doTooltip(event,6) onmouseout=hideTip() href="#">
				<IMG src="{$site_root}{$template_root}/images/newsletter/icot.gif" width="12" height="12" border=0 align="absmiddle">
			</A>
		</div>
		<div style="float:left;">{$lang.newsletter.nls.total_newsletters}: {$amount}</div>
		<div style="width:30px;" >&nbsp;</div>
	{/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%;margin-top: 4px;">
			<table border=0 cellspacing=0 cellpadding=0 width="100%">
			<tr class="table_header">
				<td align=center  width=1%>
					<input type="checkbox" id="select_all" name="select_all" onclick="PutAll()">
					<!--<a href="#" title="{$lang.newsletter.all_title}" onClick="setCheckboxes('NewsletterForm',true)">{$lang.newsletter.all}</a><br>
					<a href="#" title='Untick the items' onClick="setCheckboxes('NewsletterForm',false)">{$lang.newsletter.none}</a>-->
				</td>
				<td width=4% align="left" onclick="PageList('users_table_div','ajax=1&order=priority')">	
					&nbsp;&nbsp;
					<a title="{$lang.newsletter.nls.by_priority}">
						<img src="{$site_root}{$template_root}/images/newsletter/unsent_high.gif" border="0" height="15" align="absmiddle">
					</a>
					{if $order == "priority" and $end == ""} 
						<img src="{$site_root}{$template_root}/images/newsletter/arrow_up.gif" border="0" height="8"> 
					{elseif $order == "priority" and $end <> ""} 
						<img src="{$site_root}{$template_root}/images/newsletter/arrow_down.gif" border="0" height="8">
					{/if}
				</td>
				<td align=center  width="3%" onclick="PageList('users_table_div','ajax=1&order=is_attach')">
					<a title="{$lang.newsletter.nls.by_attach}">
						<img src="{$site_root}{$template_root}/images/newsletter/attach.gif" border="0">
					</a>
					{if $order == "is_attach" and $end == ""} 
						<img src="{$site_root}{$template_root}/images/newsletter/arrow_up.gif" border="0" height="8"> 
					{elseif $order == "is_attach" and $end <> ""} 
						<img src="{$site_root}{$template_root}/images/newsletter/arrow_down.gif" border="0" height="8">
					{/if}
				</td>
				<td align=left  width="20%" onclick="PageList('users_table_div','ajax=1&order=subject&newsletter_page={$newsletter_page}')">
					<a title="{$lang.newsletter.nls.by_subject}">
						{$lang.newsletter.nls.subject}
					</a>
					{if $order == "subject" and $end == ""} 
						<img src="{$site_root}{$template_root}/images/newsletter/arrow_up.gif" border="0" height="8"> 
					{elseif $order == "subject" and $end <> ""} 
						<img src="{$site_root}{$template_root}/images/newsletter/arrow_down.gif" border="0" height="8">
					{/if}
				</td>
				<td align=center width="8%" onclick="PageList('users_table_div','ajax=1&order=date&newsletter_page={$newsletter_page}')">
					<a title="{$lang.newsletter.nls.by_date_created}">
						{$lang.newsletter.nls.date_created}
					</a>
					{if $order == "date" and $end == ""} 
						<img src="{$site_root}{$template_root}/images/newsletter/arrow_up.gif" border="0" height="8"> 
					{elseif $order == "date" and $end <> ""} 
						<img src="{$site_root}{$template_root}/images/newsletter/arrow_down.gif" border="0" height="8">
					{/if}
				</td>
				<td align=center  width="6%" onclick="PageList('users_table_div','ajax=1&order=format&newsletter_page={$newsletter_page}')">
					<a title="{$lang.newsletter.nls.by_format}">
					{$lang.newsletter.nls.format}
					</a>
					{if $order == "format" and $end == ""} 
						<img src="{$site_root}{$template_root}/images/newsletter/arrow_up.gif" border="0" height="8"> 
					{elseif $order == "format" and $end <> ""} 
						<img src="{$site_root}{$template_root}/images/newsletter/arrow_down.gif" border="0" height="8">
					{/if}
				</td>
				<td align=center width="6%" onclick="PageList('users_table_div','ajax=1&order=is_sent&newsletter_page={$newsletter_page}')">
					<a title="{$lang.newsletter.nls.by_status}">
						{$lang.newsletter.nls.status}
					</a>
					{if $order == "is_sent" and $end == ""} 
						<img src="{$site_root}{$template_root}/images/newsletter/arrow_up.gif" border="0" height="8"> 
					{elseif $order == "is_sent" and $end <> ""} 
						<img src="{$site_root}{$template_root}/images/newsletter/arrow_down.gif" border="0" height="8">
					{/if}
				</td>
				<td align=right width=25%>
					{$lang.newsletter.nls.action} 							
				</td>
			</tr>

			{section name=c loop=$rel}
			<tr {if $smarty.section.c.index mod 2 eq 1}class="table_row even"{else}class="table_row odd"{/if}>
				<td align=center><input name="del[]" type="checkbox" value="{$rel[c].id}" ></td>
				<td align=center height=20 align="left">&nbsp;
				{if $rel[c].priority}
					<img 
					{if $rel[c].priority == 1 and $rel[c].is_sent} src="{$site_root}{$template_root}/images/newsletter/sent_high.gif" 
					{elseif $rel[c].priority == 3 and $rel[c].is_sent} src="{$site_root}{$template_root}/images/newsletter/sent_mail.gif"
					{elseif $rel[c].priority == 5 and $rel[c].is_sent} src="{$site_root}{$template_root}/images/newsletter/sent_low.gif"
					{elseif $rel[c].priority == 1 and !$rel[c].is_sent} src="{$site_root}{$template_root}/images/newsletter/unsent_high.gif" 
					{elseif $rel[c].priority == 3 and !$rel[c].is_sent} src="{$site_root}{$template_root}/images/newsletter/unsent_mail.gif"
					{elseif $rel[c].priority == 5 and !$rel[c].is_sent} src="{$site_root}{$template_root}/images/newsletter/unsent_low.gif"
					{/if}
					>
				{/if}
				</td>
				<td align=center>{if $rel[c].is_attach == 1}<img src="{$site_root}{$template_root}/images/newsletter/attach.gif" border="0">{/if}</td>
				<td align="left">{$rel[c].subject}</td>
				<td align=center>{$rel[c].date}</td>
				<td align=center>{$rel[c].format}</td>
				<td align=center>{$rel[c].sent}</td>
				<td align=center>
					<!--<table cellspacing=1 cellpadding=0 width="100%"><tr>
					<td>
						<a class="admin_button" onCLick="window.open('view.php?id={$rel[c].id}','', 'resizable=yes,scrollbars=yes,location=no,directories=no,status=no,toolbar=no,menubar=no,width=600,height=400,left=0,top=0');">{$lang.newsletter.button.view}<span>&nbsp;</span></a>
					</td>
					{if $rel[c].is_sent != 2}
					<td>
						<a class="admin_button" onclick="document.location='send.php?id={$rel[c].id}&is_test=false'">{$lang.newsletter.button.send}<span>&nbsp;</span></a>
					</td>
					{else}
					<td>
						<a class="admin_button" onclick="if (confirm('Are you sure you want to stop sending process of this newsletter?')) document.location='send.php?id={$rel[c].id}&is_test=false&is_stop=1'">{$lang.newsletter.button.stop}<span>&nbsp;</span></a>
					</td>
					{/if}
					<td>
						<a class="admin_button" onclick="document.location='change.php?id={$rel[c].id}&form=wyswyg'">{$lang.newsletter.button.wyswyg}<span>&nbsp;</span></a>
					</td>
					<td>
						<a class="admin_button" onclick="document.location='change.php?id={$rel[c].id}&form=textarea'">{$lang.newsletter.button.textarea}<span>&nbsp;</span></a>
					</td>
					<td>
						<a class="admin_button" onclick="if (confirm('Are you sure you want to delete this newsletter?'))document.location='index.php?did={$rel[c].id}'">{$lang.newsletter.button.delete}<span>&nbsp;</span></a>
					</td>
					<td>
						<a class="admin_button" onclick="document.location='send.php?id={$rel[c].id}&is_test=true'">{$lang.newsletter.button.test}<span>&nbsp;</span></a>
					</td>
					</tr></table>-->
					<!-- view, send, stop, wyswyg, textarea, delete, test-->
					<div class="block_action fr" style="display: none;">
						<!-- test -->				
						<div class="action_del" style="display: block;float:left;">
							<img height="16" alt="" src="{$site_root}{$template_root}/images/newsletter/mail.gif" onclick="document.location='send.php?id={$rel[c].id}&is_test=true'" onmouseover=doTooltip(event,58.6) onmouseout=hideTip()>
						</div>
						<div style="width:10px;" class="fl">&nbsp;</div>
						<!-- view -->
						<div class="action_edit" style="display: block;float:left;">
							<img width="16" alt="" src="{$site_root}{$template_root}/images/icn_view.png" onCLick="window.open('view.php?id={$rel[c].id}','', 'resizable=yes,scrollbars=yes,location=no,directories=no,status=no,toolbar=no,menubar=no,width=600,height=400,left=0,top=0');" onmouseout="javascript:hideToolTip();" onmouseover="javascript: showToolTip(event,'{$lang.button.view}');return false">
						</div>
						<div style="width:10px;" class="fl">&nbsp;</div>
						<!-- send, stop -->
						{if $rel[c].is_sent != 2}
							<div class="action_save" style="display: block;float:left;">
								<img width="16" style="padding-top:2px;" alt="" src="{$site_root}{$template_root}/images/newsletter/sent_mail.gif" onclick="document.location='send.php?id={$rel[c].id}&is_test=false'" onmouseover=doTooltip(event,58.2) onmouseout=hideTip()>
							</div>
						{else}
							<div class="action_save" style="display: block;float:left;">
								<img width="16" alt="" src="{$site_root}{$template_root}/images/menu/icons/forum_stop.gif" onclick="if (confirm('Are you sure you want to stop sending process of this newsletter?')) document.location='send.php?id={$rel[c].id}&is_test=false&is_stop=1'" onmouseover=doTooltip(event,58.2) onmouseout=hideTip()>
							</div>
						{/if}
						<div style="width:10px;" class="fl">&nbsp;</div>
						
						<!-- wyswyg -->				
						<div class="action_edit" style="display: block;float:left;">
							<img width="16" alt="" src="{$site_root}{$template_root}/images/newsletter/icn_admin_wyswyg.png" onclick="document.location='change.php?id={$rel[c].id}&form=wyswyg'" onmouseover=doTooltip(event,58.3) onmouseout=hideTip()>
						</div>	
						<div style="width:10px;" class="fl">&nbsp;</div>
						<!-- textarea -->
						<div class="action_edit" style="display: block;float:left;">
							<img width="16" alt="" src="{$site_root}{$template_root}/images/newsletter/icn_admin_text_area.png" onclick="document.location='change.php?id={$rel[c].id}&form=textarea'" onmouseover=doTooltip(event,58.4) onmouseout=hideTip()>
						</div>
						<div style="width:10px;" class="fl">&nbsp;</div>
						
						<!-- delete-->
						<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 newsletter?'))document.location='index.php?did={$rel[c].id}'" onmouseover=doTooltip(event,58.5) onmouseout=hideTip()>
						</div>
						
					</div>
				</td>
			</tr>
			{sectionelse}
				<tr height="40">
					<td class="main_error_text" bgcolor="#FFFFFF" align="left" colspan="10">{$lang.newsletter.nls.no_newsletters}</td>
				</tr>
			{/section}

			<tr class="table_header">
				<td class="listHeader" colspan="10">
					{*$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>				
					
				<!--<td align="right">{$lang.newsletter.nls.total_newsletters}: {$amount}</td>-->
			</tr>
		</table>
	</div>
{*
{if $amount <= 0}
	<div align="center"><strong>{$lang.newsletter.nls.no_newsletters}</strong></div>
{/if}*}
</form>
<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>		
{if $ajax eq 0}
{include file="$admin_nl_gentemplates/admin_nl_site_foot.tpl"}
{/if}
{literal}
<script language="JavaScript" type="text/JavaScript">
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 (confirm('{/literal}{$lang.newsletter.nls.conf_del_sel_nls|escape:javascript}{literal}')) document.forms[the_form].submit();
	}
	else alert('{/literal}{$lang.newsletter.nls.newlr_not_chosen|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);
	});
}
/*$(document).ready(function() {   
    $(".even, .odd").live("mouseover mouseout", function() {
    	$(this).toggleClass("select_tr");
        $('.block_action', this).toggle();
	});
});*/
</script>
{/literal}