{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','smtp_servers/change.php?ajax=1&id=0');">
            <div class="uol_in_item">{$lang.newsletter.smtp_servs.add}</div>
        </div>        
        <div class="uol_item" onclick="DelItems('ServerForm')">
            <div class="uol_in_item">{$lang.newsletter.button.del_selected}</div>
        </div>        
        <div class="uol_item" onclick="new_save('ServerForm');">
            <div class="uol_in_item">{$lang.newsletter.smtp_servs.save_order_nums}</div>
        </div>        
	</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" onclick="ShowEditor('2','template/index.php?ajax=1');">
            <a>{$lang.admin_menu.nl_templates}</a>
        </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_active" onclick="ShowEditor('5','smtp_servers/index.php?ajax=1');">
            {$lang.admin_menu.nl_smtp_servers}
        </div>
        <div class="cr"></div>
        <div class="panel_subtabs" style="width: 100%;">
        	<div class="panel_content" style="width: 100%; margin:0px;">
	<form id="myform" name="ServerForm" class="ServerForm" action="smtp_servers/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" style="margin-top:5px;">
		<tr>
		<td align="left">{$lang.newsletter.smtp_servs.total_smtp_servers}: {$amount}</td><td align="center" width="50%">&nbsp;</td>
		<td align="right">{$lang.newsletter.on_page}: <select name="server_page" style="width:auto" onChange="ShowBlock('show_block','smtp_servers/index.php?ajax=1&?server_page=' + document.ServerForm.server_page.value);">
		   {html_options values=$server_page_values selected=$server_page output=$server_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%">   
	<input type="hidden" name="order" id="order" value="" />
	<input type="hidden" name="id_server" id="id_server" value="" />
	<tr class="table_header">
	 <td width=1%>
		<input type="checkbox" id="select_all" name="select_all" onclick="PutAll()">
		<!--<a href="#" title="{$lang.newsletter.all_title}" href="#" onClick="setCheckboxes('ServerForm',true)">{$lang.newsletter.all}</a><br>
		<a title="{$lang.newsletter.none_title}" href="#" onClick="setCheckboxes('ServerForm',false)">{$lang.newsletter.none}</a>-->
	</td> 
	<td width="10%" onclick="PageList('users_table_div','ajax=1&order=order_num&server_page={$server_page}')">
		<a title="{$lang.newsletter.smtp_servs.by_order_title}">
			{$lang.newsletter.smtp_servs.order}
		</a>
		{if $order == "order_num" and $end == ""} 
			<img src="{$site_root}{$template_root}/images/newsletter/arrow_up.gif" border="0" height="8"> 
		{elseif $order == "order_num" and $end <> ""} 
			<img src="{$site_root}{$template_root}/images/newsletter/arrow_down.gif" border="0" height="8">
		{/if}
	</td>
	<td width="25%" onclick="PageList('users_table_div','ajax=1&order=name&server_page={$server_page}')">
		<a title="{$lang.newsletter.smtp_servs.by_serv_name}">
			{$lang.newsletter.smtp_servs.serv_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 width="25%" onclick="PageList('users_table_div','ajax=1&order=host&server_page={$server_page}')">
		<a title="{$lang.newsletter.smtp_servs.by_host}">
			{$lang.newsletter.smtp_servs.host}
		</a>
		{if $order == "host" and $end == ""} 
			<img src="{$site_root}{$template_root}/images/newsletter/arrow_up.gif" border="0" height="8"> 
		{elseif $order == "host" and $end <> ""} 
			<img src="{$site_root}{$template_root}/images/newsletter/arrow_down.gif" border="0" height="8">
		{/if}
	</td>
	<td width="15%" onclick="PageList('users_table_div','ajax=1&order=login&server_page={$server_page}')">
		<a title="{$lang.newsletter.smtp_servs.by_auth}">
			{$lang.newsletter.smtp_servs.auth}
		</a>
		{if $order == "login" and $end == ""} 
			<img src="{$site_root}{$template_root}/images/newsletter/arrow_up.gif" border="0" height="8"> 
		{elseif $order == "login" and $end <> ""} 
			<img src="{$site_root}{$template_root}/images/newsletter/arrow_down.gif" border="0" height="8">
		{/if}
	</td>
	<td width=10% align="right">{$lang.newsletter.smtp_servs.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="check[]" type="checkbox" value="{$rel[c].id}"></td>						
		<td>
			<input type="text" name="OrderNum[{$rel[c].id}]" value="{$rel[c].order_num}" size="1" maxlength="3" style="width: 30px;" onChange="change_order($(this).val());">
			<input type="hidden" name="OrderNumOld[{$rel[c].id}]" value="{$rel[c].order_num}">
		</td>						
		<td>{$rel[c].name}</td>
		<td>{$rel[c].host}</td>
		<td>{$rel[c].login}</td>						
		<td>
			<!--<table><tr height="40">
				<td>
					<a class="admin_button" onclick="document.location='change.php?id={$rel[c].id}'">{$lang.newsletter.button.edit}<span>&nbsp;</span></a>
				</td>
				<td>
					<a class="admin_button" onclick="if (confirm('Are you sure you want to delete this server?')) document.location='index.php?did={$rel[c].id}'">{$lang.newsletter.button.delete}<span>&nbsp;</span></a>
				</td>
			</tr></table>-->
			<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="ShowBlock('show_block','smtp_servers/change.php?ajax=1&id={$rel[c].id}');" onmouseout="javascript:hideToolTip();" onmouseover="javascript: showToolTip(event,'{$lang.button.view}');return false">
				</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('Are you sure you want to delete this server?')) ShowBlock('show_block','smtp_servers/index.php?ajax=1&did={$rel[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>
	</tr>
	{sectionelse}
		<tr height="40">
			<td class="main_error_text" bgcolor="#FFFFFF" align="left" colspan="11">{$lang.newsletter.smtp_servs.noservs}</td>
		</tr>
	{/section}
	
	<tr class="table_header">		
		<!--<td align="left">{$lang.newsletter.on_page}: 
			<select name="server_page1" style="width:auto" onChange="document.location='index.php?server_page=' + document.ServerForm.server_page.value">
				{html_options values=$server_page_values selected=$server_page output=$server_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.smtp_servs.total_smtp_servers}: {$amount}</td>-->
	</tr>
	</table>
</div>
</form>
{*{if $amount <= 0}
	<div align="center"><strong>{$lang.newsletter.smtp_servs.noservs}</strong></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['check[]'];
	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.smtp_servs.conf_del_list|escape:javascript}{literal}')) submit();
	}
	else alert('{/literal}{$lang.newsletter.smtp_servs.choose|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(){
					$('.ServerForm').ajaxSubmit(options);
			}

function new_save(the_form){
	$("#order").val('1');
	var elts = document.forms[the_form].elements['check[]'];
	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) {
		submit();
	}
	else alert('{/literal}{$lang.newsletter.smtp_servs.choose|escape:javascript}{literal}');
	return false;
}

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