{if $ajax eq 0}
{include file="$admingentemplates/admin_top.tpl"}
<div class="show_help" style="display: none;">&nbsp;</div>
<div class="red_header">{$lang.admin_menu.admin_tags}</div>
<div class="cr">&nbsp;</div>
<div class="cr">&nbsp;</div>
<div class="help_text" style="display:block;">
    <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.admin_tags}
    </div>
</div>	
	<div style="width:100%;">
<div id="tooltip" onclick="hideToolTip()" style="text-align:center; background-color: #FFFFFF; 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 style="margin:10px 0;">
		<input type="checkbox" name="use_tags" id="use_tags" value="1" {if $use_tags eq 1} checked {/if} onclick="Tags();"/>
		&nbsp;{$lang.admin_tags.use_tags}
		<span style="padding-left:100px;" class="error_box_blue" id="save"></span>
	</div>
{/if}	
		<table cellpadding="0" cellspacing="0" width="100%" id="use_tags_admin">
    		<tr class="table_header">
    			<td width="30%">{$lang.admin_menu.admin_tags}</td>
    			<td width="30%">{$lang.admin_tags.tag_count}</td>
                <td width="30%">{$lang.admin_tags.tag_seo}</td>
    			<td width="10%" align="right">{$lang.users.actions}</td>
    		</tr>
		{foreach name=t from=$tags item=item}
		<tr id="name_{$smarty.foreach.t.iteration}" {if $smarty.foreach.t.iteration mod 2 eq 0}class="even"{else}class="odd"{/if}>
			<td class="main_content_text" id="td_tag{$smarty.foreach.t.iteration}">{$item.tag}</td>
			<td class="main_content_text">{$item.tag_count}</td>
                        <td class="main_content_text">
                            <input type="checkbox" id="allow_index_{$smarty.foreach.t.iteration}" onclick="saveTag('{$item.tag}','{$smarty.foreach.t.iteration}');" {if $item.allow_index eq 1}checked=""{/if}>
                        </td>
			<td class="main_content_text">
                <div class="block_action" style="float:right; padding-right: 20px;">
                    <img src="{$site_root}{$template_root}/images/photo_delete.png" alt="" height="13" onmouseout="javascript:hideToolTip();" onmouseover="javascript: showToolTip(event,'{$lang.button.delete}');return false" style="cursor: pointer;" onclick="delTag($('#td_tag{$smarty.foreach.t.iteration}').html(),'{$smarty.foreach.t.iteration}'); return false;" />
                </div>
            </td>
		</tr>
		{foreachelse}
		<tr height="40">
			<td class="main_error_text" align="left" colspan="4" bgcolor="#FFFFFF">{$lang.admin_tags.no_tags}</td>
		</tr>
		{/foreach}
		<tr class="table_header"><td colspan="4">
			&nbsp;&nbsp;
			{if $links}
				{foreach item=item from=$links.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 $links.previous}
					<a onclick="PageList('users_table_div', '{$links.previous}');">< {$lang.content.previous} {$per_page}</a>
				{/if}
				{if $links.next}
					<a onclick="PageList('users_table_div', '{$links.next}');">{$lang.content.next} {$per_page} ></a>
				{/if}
			{else}
				&nbsp;
			{/if}
		</td>
		</tr>
		</table>
<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 -10 + st + 'px';
		}
		function hideToolTip(){
			document.getElementById('tooltip').style.display = 'none';
		}
		function Tags(){
			var use = $("#use_tags").is(":checked") ? 1 : 0;	
			data = 'ajax=1&sel=usetags&use='+use;
			$.post('admin_tags.php',data,function(data){
				if (data == "ok"){
					ShowAjaxError("{/literal}{$lang.country.saved}{literal}",'','success');
				}
			});
		}
		function PageList(id_div, par) {
			ajaxLoadingImage(1, 'use_tags_admin');
			$.post("admin_tags.php", par, function(data){
				ajaxLoadingImage(0, 'use_tags_admin');
				$('#use_tags_admin').html(data);
			});
		}
{/literal}		
</script>
	</div>
{if $ajax eq 0}	
{include file="$admingentemplates/admin_bottom.tpl"}
{/if}
<script type="text/javascript">
var page={$page};
{literal}
function delTag(tag_name, iteration){
	data = 'ajax=1&sel=deltag&name='+tag_name;
	$.post('admin_tags.php',data,function(data){
		$('#name_'+iteration).fadeOut("slow", function(){
			if (!$(".tags_str:visible").css("display"))
				if (page > 1)
					location.href ='admin_tags.php?page='+(page-1);
				else
					location.href = 'admin_tags.php';
		});
	});
}
function saveTag(tag, item) {
    var tag_value = $("#allow_index_"+item).attr('checked')?1:0;
    $.post('admin_tags.php',{sel:'save_tag_seo',tag:tag, tag_value:tag_value},
        function(data){
        }
    );
}
{/literal}
</script>