{if $ajax eq 0}
{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.club.admin.razdel_name}</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.club_categories_list}
    </div>
</div>
<div class="cr">&nbsp;</div>
<ul class="tabs">
    <li>
        <a class="current">{$lang.admin_menu.groups_categories_list}</a>
    </li>
{*    <li>
        <a href="admin_club.php?sel=add_category">{$lang.admin_menu.groups_categories_add}</a>
    </li>*}
    <li>
        <a href="admin_club.php?sel=my_club">{$lang.admin_menu.my_groups}</a>
    </li>
{*    <li>
        <a href="admin_club.php?sel=create">{$lang.admin_menu.add_group}</a>
    </li>*}
</ul>
		<div class="user_operation_line" style="height:4px;font-size:0px;">
{*			<div onclick="javascript: add_cat_func();" class="uol_item">
				<div class="uol_in_item">{$lang.club.admin.add}</div>
			</div>
			<div onclick="javascript: location.href='{$form.add_club_link}'" class="uol_item">
				<div class="uol_in_item">{$lang.club.club_menu_3}</div>
			</div>
			<div onclick="javascript: location.href='{$form.my_clubs_link}'" class="uol_item">
				<div class="uol_in_item">{$lang.club.club_menu_1}</div>
			</div>*}
		</div>
		<div class="cr"></div>
{/if}
<table width="100%">
	<tr>
		<td>
			<div id="dest_div">
				<form method="post" action="{$form.action}" name="category_form" id="category_form" enctype="multipart/form-data">
				<table border=0 cellspacing=0 cellpadding=0 width="100%">
					<input type="hidden" name="par" id="par" value="add">
					<input type="hidden" name="id" id="id" value="">
					{if $ajax eq 0}
						<tr bgcolor="#ffffff">
						<td align="left" width="1%" nowrap class="main_header_text">{$lang.club.admin.category_name} <font class=main_error_text>*</font>:&nbsp;</td>
						<td align="left" width="200px" nowrap><input type="text" name="category_name" id="category_name" value="{$data.category_name}" style="width: 195px;"></td>
						<td width="99%">
							<a class="admin_button_major" onclick="javascript: Save('category_name', 'add', 'id');{*document.category_form_ed.submit();*}">{$lang.button.add}<span>&nbsp;</span></a>
						</td>
					</tr>
					{/if}
{*					<tr bgcolor="#ffffff">
						<td colspan="2">
						<table cellpadding="3" cellspacing="0">
							<tr height="40">
								<td>
									<a class="admin_button_major" onclick="javascript: Save('category_name', 'add', 'id');">{$lang.button.add}<span>&nbsp;</span></a>
								</td>
							</tr>
						</table>
						</td>
					</tr>*}
				</table>
				</form>
			</div>
			<div id="dest_div_ed" style="display:none;">
				<form method="post" action="{$form.action}" name="category_form_ed" id="category_form_ed" enctype="multipart/form-data">
				<table border=0 cellspacing=0 cellpadding=0 width="100%">
					<input type="hidden" name="par" id="par" value="edit">
					<input type="hidden" name="id" id="id" value="">
					<tr bgcolor="#ffffff">
						<td align="left" width="200" class="main_header_text">{$lang.club.admin.category_name} <font class=main_error_text>*</font>:&nbsp;</td>
						<td align="left"><input type="text" name="category_name_ed" id="category_name_ed" value="{$data.category_name}" style="width: 195px;"></td>
					</tr>
					<tr bgcolor="#ffffff">
						<td colspan="2">
						<table cellpadding="3" cellspacing="0">
							<tr height="40">
								<td>
									<a class="admin_button_major" onclick="javascript: Save('category_name_ed', 'edit', 'id');{*document.category_form_ed.submit();*}">{$lang.button.save}<span>&nbsp;</span></a>
								</td>
							</tr>
						</table>
						</td>
					</tr>
				</table>
				</form>
			</div>
		</td>		
	</tr>
</table>
<div id="category_table_div">
<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=0 width="100%" style="margin-top:15px;">
{*	{if $links}
	<tr bgcolor="#ffffff">
		<td height="20"  colspan=4 align="left"  class="main_content_text" style="color: #656565;">{$links}</td>
	</tr>
	{/if}*}
	<tr class="table_header">
		<td class="main_header_text" align="center" width="20">{$lang.club.admin.number}</td>
		<td class="main_header_text" align="left">{$lang.club.admin.category}</td>
		<td class="main_header_text" align="center" width="100">{$lang.club.admin.category_clubs_count}</td>
		<td class="main_header_text" align="right" width="100">{$lang.button.action}</td>
	</tr>
	{if $club_categories}
	{section name=spr loop=$club_categories}
	<tr {if $smarty.section.spr.index mod 2 eq 1}class="table_row even"{else}class="table_row odd"{/if}>
		<td class="main_content_text" align="center">{$club_categories[spr].number}</td>
		<td class="main_content_text" align="left">{*<a href="{$club_categories[spr].editlink}">*}
{*			<div style="display:none;" id="edit_{$club_categories[spr].id}">
				<div id="err{$club_categories[spr].id}" style="display:none;">
				</div>
				<div>
				<input type="text" name="name" id="edit_name_{$club_categories[spr].id}" value="{$club_categories[spr].name}" size="25">&nbsp;&nbsp;&nbsp;
				<a class="admin_button_major" name="save" onclick="Save('{$club_categories[spr].id}');">{$lang.button.save}<span>&nbsp;</span></a>
				</div>
			</div>
			<div id="{$club_categories[spr].id}">{$club_categories[spr].name}</div></a>*}
				<div id="inform_div{$club_categories[spr].id}" class="error_msg" style="display:none;float:right;"></div>
				<span id="link{$club_categories[spr].id}">{$club_categories[spr].name}</span>
				<input id="text_input{$club_categories[spr].id}" type="text" value="{$club_categories[spr].name}" style="display:none"/>
		</td>
		<td class="main_content_text" align="center">{if $club_categories[spr].clublink}<a href="{$club_categories[spr].clublink}">{/if}{$club_categories[spr].clubs_count}&nbsp;{$lang.club.admin.clubs_small}{if $club_categories[spr].clublink}</a>{/if}</td>
		<td class="main_content_text" align="right">
{*			<img height="16" alt="" src="{$site_root}{$template_root}/images/photo_delete.png" onclick="javascript: if(confirm('{$form.confirm|escape:javascript}')){literal}{{/literal}location.href='{$club_categories[spr].deletelink}'{literal}}{/literal}">
*}{*							<div class="block_action fr" style="display: none;">
								<div class="action_del" style="display: block;">
									<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('{$form.confirm|escape:javascript}')){literal}{{/literal}location.href='{$club_categories[spr].deletelink}'{literal}}{/literal}">
								</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;">				
									<img width="16" alt="" src="{$site_root}{$template_root}/images/edit.png" onmouseout="javascript:hideToolTip();" onmouseover="javascript: showToolTip(event,'{$lang.button.edit}');return false" onclick="Edit('{$club_categories[spr].id}', '{$club_categories[spr].name}');">
								</div>
							</div>		*}
                                    <div class="block_action" >  
                                        <img id="edit_button{$club_categories[spr].id}" src="{$site_root}{$template_root}/images/edit.png" onmouseout="javascript:hideToolTip();" onmouseover="javascript: showToolTip(event,'{$lang.button.edit}');return false" alt="" height="13" style="cursor: pointer;" onclick="javascript: editAction({$club_categories[spr].id});" />&nbsp;
                                        <img id="save_button{$club_categories[spr].id}" src="{$site_root}{$template_root}/images/success.png" onmouseout="javascript:hideToolTip();" onmouseover="javascript: showToolTip(event,'{$lang.button.save}');return false" alt="" height="13" style="cursor: pointer; display:none;" onclick="javascript: saveAction({$club_categories[spr].id});" />&nbsp;
                                        <img src="{$site_root}{$template_root}/images/photo_delete.png" alt="" height="13" style="cursor: pointer;" onmouseout="javascript:hideToolTip();" onmouseover="javascript: showToolTip(event,'{$lang.button.delete}');return false" onclick="javascript: if(confirm('{$form.confirm|escape:javascript}')){literal}{{/literal}location.href='{$club_categories[spr].deletelink}'{literal}}{/literal}" />&nbsp;&nbsp;
                                    </div>
		</td>
	</tr>
	{/section}
	{else}
	<tr height="40">
		<td class="main_error_text" align="left" colspan="4" bgcolor="#FFFFFF">{$lang.club.admin.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('category_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('category_table_div', '{$links.previous}');">< {$lang.content.previous} {$per_page}</a>
			{/if}
			{if $links.next}
				<a onclick="PageList('category_table_div', '{$links.next}');">{$lang.content.next} {$per_page} ></a>
			{/if}
			</div>	
		</td>
	</tr>
{*	{if $links}
	<tr bgcolor="#ffffff">
		<td height="20"  colspan=4 align="left"  class="main_content_text" >{$links}</td>
	</tr>
	{/if}*}
</table>
<script type="text/javascript">
{literal}
	function editAction(id){
		link_obj = getById('link'+id);
		text_input_obj = getById('text_input'+id);
		edit_button_ogj = getById('edit_button'+id);
		save_button_ogj = getById('save_button'+id);

		link_obj.style.display = 'none';
		text_input_obj.style.display = '';
		edit_button_ogj.style.display = 'none';
		save_button_ogj.style.display = '';

		text_input_obj.focus();
	}

	function saveAction(id){
		inform_div_obj = getById('inform_div'+id);
		link_obj = getById('link'+id);
		text_input_obj = getById('text_input'+id);
		edit_button_ogj = getById('edit_button'+id);
		save_button_ogj = getById('save_button'+id);
		value = text_input_obj.value;

		file_name = '{/literal}{$form.action}{literal}';
		str = 'sel=save_category&par=edit&id='+id+'&category_name='+value+'&e=1';
		destination_odj = inform_div_obj;
		tmp_text = 'Saving...';
		anisochronous = false;

		ajaxRequest(file_name, str, destination_odj, tmp_text, anisochronous);

		inform_div_obj.style.display = '';

		saved_obj = getById('saved'+id);
		saved = saved_obj.value;
		if (saved == '1'){
			link_obj.style.display = '';
			link_obj.innerHTML = value;
			text_input_obj.style.display = 'none';
			edit_button_ogj.style.display = '';
			save_button_ogj.style.display = 'none';
			edit_button_ogj.focus();
		}
	}
	
	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>
<script language="javascript" type="text/javascript">
{literal}
function add_cat_func(){
	$('#dest_div').css("display", "block");
	$('#dest_div_ed').css("display", "none");	
}
function Edit(id, name){
/*	$("#err"+id).html('');
	$("#"+id).hide();
	$("#edit_"+id).show();*/
	$("input:text[name='category_name_ed']").val(name);
	$("input:hidden[name='par']").val('edit');
	$("input:hidden[name='id']").val(id);
	$('#dest_div_ed').css("display", "block");	
	//$('#dest_div').css("display", "none");	
}
function Save(name, par, id){
	var cat_name = document.getElementById(name).value;
	var cat_id = document.getElementById(id).value;
	//$('#dest_div').css("display", "none");
	$('#dest_div_ed').css("display", "none");	
	ajaxLoadingImage(1, 'category_table_div');
	$.post("admin_club.php?sel=save_category", {category_name:cat_name, par:par, id:cat_id, ajax:'1'}, function(data){
		ajaxLoadingImage(0, 'category_table_div');
		$('#category_table_div').html(data);
	});
}
function PageList(id_div, par) {
        //ajaxLoadingImage(1, 'pays');
        $.post("admin_club.php", par, function(data){
            //ajaxLoadingImage(0, 'pays');
            $('#category_table_div').html(data);
        });
    }
{/literal}
</script>
{if $ajax eq 0}
{include file="$admingentemplates/admin_bottom.tpl"}
{/if}