{if !$ajax}
	{include file="$admingentemplates/admin_top.tpl"}

<div class="back">
    <a href="{$site_url}{$site_root}/admin/admin_modules.php">{$lang.button.back}</a>
</div>
<div class="cr"></div>
	<div class="show_help" style="display: none;">&nbsp;</div>

	<div class="red_header">{$lang.blog.admin.razdel_name}</div>{*<font class="red_sub_header">&nbsp;|&nbsp;{$lang.blog.admin.categories_list}</font><br><br>*}
	<div class="cr">&nbsp;</div>
	<div class="cr">&nbsp;</div>
	<div class="help_text">
		<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.blog_categories_list}
		</div>
	</div>


	<ul class="tabs">
		<li>
			<a href="admin_blog.php">{$lang.blog.blog_menu_5}</a>
		</li>
		<li>
			<a href="#" class="current">{$lang.section.blog_categories}</a>
		</li>
	</ul>

	<div class="panel">
		<div class="user_operation_line">
			<div class="uol_item" {literal}onclick="javascript: if(window.confirm('{/literal}{if $blog_categories[spr].blogs_count > 0}{$lang.blog.confirm_category_non_null|escape:javascript}{else}{$lang.blog.confirm|escape:javascript}{/if}')){literal}{DellCat();} else return false;"{/literal}>
				<div class="uol_in_item">{$lang.button.delete}</div>
			</div>
		</div>
		<div class="cr"></div>
		
<div style="float:left;">
	<form method="post" name="post_form" action="{$form.action}" id="category_form" enctype="multipart/form-data">
		<table border=0 cellspacing=0 cellpadding=3 width="auto">
			<input type="hidden" name="par" value="{$form.par}">
			{if $form.par eq 'edit'}
			<input type="hidden" name="id" value="{$data.id}">
			{/if}
			<tr bgcolor="#ffffff">
				<td align="left" width="auto">{$lang.blog.admin.category_name}:&nbsp;</td>
				<td align="left" width="200"><input type="text" name="category_name" value="{$data.category_name}" style="width: 195px;"></td>
						<td>
							{if $form.par eq 'edit'}
								<a class="admin_button_major" onclick="document.post_form.submit();" href="#">{$lang.button.save}<span>&nbsp;</span></a>
							{else}
								<a class="admin_button_major" onclick="document.post_form.submit();" href="#">{$lang.button.add}<span>&nbsp;</span></a>
							{/if}
						</td>
			</tr>
		</table>
	</form>
</div>
{/if}
		<div id="blogs_table_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}
			<table border=0 cellspacing=0 cellpadding=3 width="100%">
				<tr class="table_header">
					<td align="center" width="20"><input type="checkbox" id="select_all" name="select_all" onclick="PutAll()"></td>
					<td align="left">{$lang.blog.admin.category}</td>
					<td align="center" width="100">{$lang.blog.admin.blogs_count}</td>
					<td align="right" width="100">{$lang.button.action}</td>
				</tr>
				{if $blog_categories}
				{section name=spr loop=$blog_categories}
					<tr {if $smarty.section.spr.index mod 2 eq 1}class="table_row even"{else}class="table_row odd"{/if}>
						<td align="center"><input type="checkbox" name="delete" value="{$blog_categories[spr].id}"></td>
						<td align="left"><input type="hidden" name="id" value="{$blog_categories[spr].id}"><div id="ref_{$blog_categories[spr].id}">{$blog_categories[spr].name}</div></td>
						<td align="center">{if $blog_categories[spr].blogs_count ne '0'}<a href="{$blog_categories[spr].view}">{$blog_categories[spr].blogs_count}</a>{else}{$blog_categories[spr].blogs_count}{/if}</td>
						<td align="right">
							{*<a href="javascript:void(0)" onclick="javascript: if(confirm('{if $blog_categories[spr].blogs_count > 0}{$lang.blog.confirm_category_non_null|escape:javascript}{else}{$lang.blog.confirm|escape:javascript}{/if}')){literal}{{/literal}location.href='{$blog_categories[spr].deletelink}'{literal}}{/literal}"><img height="16" alt="" src="{$site_root}{$template_root}/images/photo_delete.png"></a>*}
							<div class="block_action fr" style="display: none;">
								<div class="action_del" style="display: block;cursor:pointer;">
									<img height="16" alt="" src="{$site_root}{$template_root}/images/photo_delete.png" onmouseout="javascript:hideToolTip();" onmouseover="javascript: showToolTip(event,'{$lang.button.delete}');return false">{* onclick="javascript: if(confirm('{if $blog_categories[spr].blogs_count > 0}{$lang.blog.confirm_category_non_null|escape:javascript}{else}{$lang.blog.confirm|escape:javascript}{/if}')){literal}{{/literal}location.href='{$blog_categories[spr].deletelink}'{literal}}{/literal}"*}
								</div>
								<div class="action_save"><img width="16" alt="" src="{$site_root}{$template_root}/images/success.png" onmouseout="javascript:hideToolTip();" onmouseover="javascript: showToolTip(event,'{$lang.button.save}');return false"></div>
							</div>
							<div style="width:10px;float:right;" class="fl">&nbsp;</div>
							<div class="block_action fr" style="display: none;">
								<div class="action_edit" style="display: block;cursor:pointer;">
									<img height="16" alt="" onmouseout="javascript:hideToolTip();" onmouseover="javascript: showToolTip(event,'{$lang.button.edit}');return false" src="{$site_root}{$template_root}/images/edit.png">{* onclick="javascript: document.location.href='{$blog_categories[spr].editlink}';"*}
								</div>
							</div>				
						</td>
					</tr>
				{/section}
				{else}
				<tr height="40">
					<td class="main_error_text" align="left" colspan="4" bgcolor="#FFFFFF">{$lang.admin_upload.empty_categories}</td>
				</tr>
				{/if}
				<tr class="table_header">
					<td colspan="4">
						&nbsp;&nbsp;
						{if $links}
						{foreach item=item from=$links.pages}
							&nbsp;<a onclick="PageList('blogs_table_div', '{$item.link}');" class="page_link" {if $item.selected} style=" font-weight: bold; text-decoration: none;" {/if}>{$item.name}</a>&nbsp;
						{/foreach}
						{/if}
						<div class="page_navigation">
						{if $links.previous}
							<a onclick="PageList('blogs_table_div', '{$links.previous}');">< {$lang.content.previous} {$per_page}</a>
						{/if}
						{if $links.next}
							<a onclick="PageList('blogs_table_div', '{$links.next}');">{$lang.content.next} {$per_page} ></a>
						{/if}
						</div>
					</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';
		}
{/literal}		
</script>
		</div>
{if !$ajax}		
	</div>
	

{literal}
<script>
function PageList(id_div, par) {
	ajaxLoadingImage(1, id_div);
	$.post("admin_blog.php", par, function(data){
		ajaxLoadingImage(0, id_div);
		$('#'+id_div).html(data);
	});
}
function PutAll() {
         var o=document.getElementsByName('select_all')	
         var i
         if (o[0].checked){                    
            o=document.getElementsByName('delete')
            for (i=0; i<o.length; i++){                
                if (!o[i].disabled)
                    o[i].checked = true
            }            
         }
         else{
            o=document.getElementsByName('delete')
            for (i=0; i<o.length; i++){                
                o[i].checked = false
            }            
         }             
}
$(document).ready(function() {
    $("tr .table_row .action_edit").click(
        function(){
            var ref_id = $("tr .select_tr").find('input[type="hidden"]').val();
            REF_OLD = $('#ref_'+ref_id).text();
            str = '<input type="text" name="ref_new" id="ref_new_'+ref_id+'" value="'+REF_OLD+'" size="28">';
            $('#ref_'+ref_id).html(str);
            $('tr .select_tr').find('div .action_edit, .action_del').css('display', 'none');
            $('tr .select_tr').find('div .action_save').css('display', 'block');
        }
    );
    $("tr .table_row .action_save").click(
        function(){
            var ref_id = $("tr .select_tr").find('input[type="hidden"]').val();
            var ref_new = $('#ref_new_'+ref_id).val();
            if (ref_new == '') return;
            ajaxIndicator(1, 'ref_'+ref_id);
            $.post('admin_blog.php', {sel:'save_category',par:'edit', id:ref_id, category_name:ref_new},
                function(data){
                    ajaxIndicator(0, 'ref_'+ref_id);
                    if (data=="")
                        $('#ref_'+ref_id).html(REF_OLD);
                    else 
                        $('#ref_'+ref_id).html(data);
                    REF_OLD = "";
                }
            );
            $('tr .select_tr').find('div .action_edit, .action_del').css('display', 'block');
            $('tr .select_tr').find('div .action_save').css('display', 'none');
        }
    );
    $("tr .table_row .action_del").click(
        function(){
            var ref_id = $("tr .select_tr").find('input[type="hidden"]').val();
            ajaxIndicator(1, 'ref_'+ref_id);
            $.post('admin_blog.php', {sel:'del_category', id:ref_id, ajax:'1'},
                function(data){
                    ajaxIndicator(0, 'ref_'+ref_id);
                    ShowReference('');
                }
            );
        }
    );
});
function ShowReference(par) {
    ajaxLoadingImage(1, 'blogs_table_div');
    if(par == '')
        $.post('admin_blog.php',{sel:'categories', ajax:'1'},function(data){
            ajaxLoadingImage(0, 'blogs_table_div');
            $('#blogs_table_div').html(data);
        });
    else
        $.post(par,'',function(data){
            ajaxLoadingImage(0, 'blogs_table_div');
            $('#blogs_table_div').html(data);
        });
}
function delReportAll(){    
	$('input[name=delete]:checked').each(function(){
	   delReport($(this).val());	  
     });
}

function delReport(id){
	par = 'ajax=1&sel=del_category&id='+id;
	$.post('admin_blog.php', par, function(data){		
			 $('#blogs_table_div').html(data);
	});
}

    function DellCat(){
	$('input[name=delete]:checked').each(function(){
	   delReport($(this).val());	  
     });
    }
</script>
{/literal}
	{include file="$admingentemplates/admin_bottom.tpl"}
{/if}