{if $ajax eq 0}
	{include file="$admin_nl_gentemplates/admin_nl_site_head.tpl"}{/if}
	<div class="user_operation_line">
        <div class="uol_item" onclick="ShowBlock('show_block','template/create_format.php?ajax=1');">
            <div class="uol_in_item">{$lang.newsletter.button.create}</div>
        </div>        
			{if $amount >= 1}
        <div class="uol_item" onclick="DelItems('TemplateForm')">
            <div class="uol_in_item">{$lang.newsletter.button.del_selected}</div>
        </div>        
			{/if}
	</div>
	<div class="cr"></div>
    <div class="user_status_line">
        <div id="tab_1" class="user_status_elem" onclick="ShowEditor('1','settings.php?ajax=1');">
            <a>{$lang.admin_menu.nl_general}</a>
        </div>
        <div id="tab_2" class="user_status_elem_active" onclick="ShowEditor('2','template/index.php?ajax=1');">
            {$lang.admin_menu.nl_templates}
        </div>
        <div id="tab_3" class="user_status_elem" onclick="ShowEditor('3','forms/index.php?ajax=1');">
            <a>{$lang.admin_menu.nl_forms}</a>
        </div>
        <div id="tab_4" class="user_status_elem" onclick="ShowEditor('4','attaches/index.php?ajax=1');">
            <a>{$lang.admin_menu.nl_attachments}</a>
        </div>
        <div id="tab_5" class="user_status_elem" onclick="ShowEditor('5','smtp_servers/index.php?ajax=1');">
            <a>{$lang.admin_menu.nl_smtp_servers}</a>
        </div>
        <div class="cr"></div>
        <div class="panel_subtabs" style="width: 100%">
        	<div class="panel_content" style="width: 100%;margin:0px;">

	<form name="TemplateForm" class="TemplateForm" id="TemplateForm" action="template/index.php?ajax=1" enctype="application/x-www-form-urlencoded" method="post" style="margin:0px">
	
	{if $amount > 0}
		<table cellpadding="2" cellspacing="2" width="100%" border="0"><tr>
		<td align="left">{$lang.newsletter.template.total_templates}: {$amount}</td>
		<td align="center" width="50%">&nbsp;</td>
		<td align="right">{$lang.newsletter.on_page}: <select name="template_page" style="width:auto" onChange="ShowBlock('show_block','template/index.php?ajax=1&template_page=' + document.TemplateForm.template_page.value);">document.location='index.php?template_page=' + document.TemplateForm.template_page.value">
		   {html_options values=$template_page_values selected=$template_page output=$template_page_output}
			</select>
		</td>
		</tr>
		</table>
	{/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 align=center width=1%>
				<input type="checkbox" id="select_all" name="select_all" onclick="PutAll()">
				<!--<a title="{$lang.newsletter.all_title}" href="#" onClick="setCheckboxes('TemplateForm',true)">{$lang.newsletter.all}</a><br>
				<a title="{$lang.newsletter.none_title}" href="#" onClick="setCheckboxes('TemplateForm',false)">{$lang.newsletter.none}</a>-->
			</td>    
		   <td align=left width="30%" onclick="PageList('users_table_div','ajax=1&order=name&template_page={$template_page}')">
				<a title="{$lang.newsletter.template.by_templ_name}">
					{$lang.newsletter.template.templ_name}
				</a>
				{if $order == "name" and $end == ""} 
					<img src="{$site_root}{$template_root}/images/newsletter/arrow_up.gif" border="0" height="8"> 
				{elseif $order == "name" and $end <> ""} 
					<img src="{$site_root}{$template_root}/images/newsletter/arrow_down.gif" border="0" height="8">
				{/if}
		   </td>   			
			<td align=center width="15%" onclick="PageList('users_table_div','ajax=1&order=date&template_page={$template_page}')">
				<a title="{$lang.newsletter.template.by_date_created}">
					{$lang.newsletter.template.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="10%" onclick="PageList('users_table_div','ajax=1&order=format&template_page={$template_page}')">
				<a title="{$lang.newsletter.template.by_format}">
					{$lang.newsletter.template.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=right width="20%">{$lang.newsletter.template.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} height=20>
			<td align=center><input name="del[]" type="checkbox" value="{$rel[c].id}" </td>						   
			<td width=30%>{$rel[c].name}</td>
			<td align=center width=15%>{$rel[c].date}</td>
			<td align=center width=10%>{$rel[c].format}</td>
			<td align=center width=20%>
					<!--<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=700,height=500,left=0,top=0');">{$lang.newsletter.button.view}<span>&nbsp;</span></a>
					</td>
					<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('{$lang.newsletter.template.conf_del|escape:javascript}'))document.location='index.php?did={$rel[c].id}'">{$lang.newsletter.button.delete}<span>&nbsp;</span></a>
					</td>
					</tr></table>-->
				<!-- view, wyswyg, textarea, delete -->
				<div class="block_action fr" style="display: none;">
					<!-- 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('template/view.php?id={$rel[c].id}','', 'resizable=yes,scrollbars=yes,location=no,directories=no,status=no,toolbar=no,menubar=no,width=700,height=500,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>
					
					<!-- 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="window.open('template/change.php?id={$rel[c].id}&form=wyswyg&ajax=1&commit=1','', 'resizable=yes,scrollbars=yes,location=no,directories=no,status=no,toolbar=no,menubar=no,width=700,height=500,left=0,top=0');" 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="window.open('template/change.php?id={$rel[c].id}&form=textarea&ajax=1&commit=1','', 'resizable=yes,scrollbars=yes,location=no,directories=no,status=no,toolbar=no,menubar=no,width=700,height=500,left=0,top=0');" 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 width="16" alt="" src="{$site_root}{$template_root}/images/photo_delete.png" onclick="if (confirm('{$lang.newsletter.template.conf_del|escape:javascript}')){literal}{{/literal}ShowBlock('show_block', 'template/index.php?did={$rel[c].id}&ajax=1'){literal}}{/literal}" onmouseover=doTooltip(event,58.5) onmouseout=hideTip()>
					</div>
					<div style="width:10px;" class="fl">&nbsp;</div>
								
				</div>
			</td>
		</tr>
		{sectionelse}
			<tr height="40">
				<td class="main_error_text" align="left" colspan="6" bgcolor="#FFFFFF">{$lang.newsletter.template.total_templates}</td>
			</tr>		
		{/section}
		<tr class="table_header">		
			<!--<td align="left">{$lang.newsletter.on_page}: 
				<select name="template_page1" style="width:auto" onChange="document.location='index.php?template_page=' + document.TemplateForm.template_page.value">
					{html_options values=$template_page_values selected=$template_page output=$template_page_output}
				</select>
			</td>-->
			<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>
			<!--<td align="right">{$lang.newsletter.template.total_templates}: {$amount}</td>-->
		</tr>
		</table>
</div>
{*{if $amount <= 0}
<div align="center" class="main_content_text"><strong>{$lang.newsletter.template.total_templates}</strong></div>*}
</form>
</div>
</div>
</div>
{*{/if}*}
{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 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.template.conf_del_sel|escape:javascript}{literal}')) submit();
	}
	else alert('{/literal}{$lang.newsletter.template.choose_items|escape:javascript}{literal}');
	return false;
}
			var options = { 
				success: function(data){
					ajaxLoadingImage(0, 'show_block');
					$('#show_block').html(data);
					/*$('#show_block').oneTime(3000, function() {
						$('#show_block').fadeOut(500);
					});*/
					return false;
				},
				beforeSubmit: function() { 
					//ajaxIndicator(1, 'show_block');
					ajaxLoadingImage(1, 'show_block');
				}
			};
			function submit(){
					$('.TemplateForm').ajaxSubmit(options);
			}

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, 'show_block');
	$.post("index.php", par, function(data){
		ajaxLoadingImage(0, 'show_block');
		$('#show_block').html(data);
	});
}
</script>
{/literal}