{if $ajax eq '0'}
	{include file="$admingentemplates/admin_top.tpl"}
{/if}
{if $par eq 'edit_subcategory' && $ajax eq '0'}
{elseif $ajax eq '0'}
	<div class="back">
		<a href="{if $par eq 'new_post' || $par eq 'edit_post'}{$file_name}?sel=subcategory&id_subcategory={$data.subcategory_id}{elseif $par ne 'new_post' && $par ne 'edit_subcategory' && $par ne 'new_subcategory'}{$site_url}{$site_root}/admin/admin_modules.php{elseif $par eq 'new_subcategory'}{$file_name}?sel=category&id_category={$data.category_id}{/if}">{$lang.button.back}</a>
	</div>
	<div class="cr"></div>
{/if}
{if $ajax eq '0'}
	<div class="show_help" style="display: none;">&nbsp;</div>
	<div class="red_header">{$lang.forum.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.forum_administration}
		</div>
	</div>
{/if}
{if ($par eq 'new_subcategory' || $par eq 'new_post' || $par eq 'edit_post' || $par eq 'edit_subcategory') && $ajax eq '0'}
{elseif $ajax eq '0'}
	<div class="cr">&nbsp;</div>
	<ul class="tabs">
		<li>
			<a class="current">{$lang.admin_menu.forum_index}</a>
		</li>
		<li>
			<a href="admin_forum.php?sel=banned">{$lang.admin_menu.forum_bans}</a>
		</li>
	</ul>
	{if $par eq 'index'}
		<div class="user_operation_line" style="height:4px;font-size:0px;">
		</div>
		<div class="cr"></div>
	{else}
		<div class="user_operation_line">
		{if $par eq 'category'}
			<div onclick="document.location.href='{$file_name}?sel=new_subcategory&amp;id_category={$data.category_id}&type={$type}'" class="uol_item">{*document.location.href='admin_forum.php?sel=add_category';*}
				<div class="uol_in_item">{$lang.forum.new_topic}</div>
			</div>
		{elseif $par eq 'subcategory'}
			<div onclick="document.location.href='{$file_name}?sel=new_post&amp;id_subcategory={$data.subcategory_id}&type={$type}'" class="uol_item">{*document.location.href='admin_forum.php?sel=add_category';*}
				<div class="uol_in_item">{$lang.forum.new_post}</div>
			</div>
		{/if}
		</div>
		<div class="cr"></div>
	{/if}
{/if}

{if $ajax ne 2}
	<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}
{/if}

{if !$ajax}
<div id="reload_div">
{/if}
	<div id="forum_table_div">
		{if $par eq 'index'}
			<table width="100%">
				<tr>
					<td>
						<div id="dest_div" style="{if $type eq "forum"}display:block;{else}display: none;{/if}">
							<form method="post" action="admin_forum.php" style="margin: 0px; padding: 0px;" name="form1_ed">
							<input type="hidden" name="sel" id="sel" value="save_new_category">
							<input type="hidden" name="category_id" id="category_id" value="">
							<table cellpadding="5" cellspacing="0">
							<tr>
								<td class="main_header_text">{$lang.forum.category_name}:&nbsp;</td>
								<td class="main_content_text"><input type="text" name="category_name" id="category_name" value="{$data.category_name}"></td>
							</tr>
							<tr>
								<td class="main_header_text">{$lang.forum.category_description}:&nbsp;</td>
								<td class="main_content_text"><textarea name="category_description" id="category_description" style="width: 250px; height: 60px;">{$data.category_description}</textarea></td>
							</tr>
							<tr>
								<td colspan="2">
								<a class="admin_button_major" onclick="Save('category_name', 'category_description', 'save_new_category', 'category_id');{*document.form1_ed.submit();*}">{$lang.button.add}<span>&nbsp;</span></a>&nbsp;	
								</td>
							</tr>
							</table>
							</form>
						</div>
						<div id="dest_div_ed" style="display:none;">
							<form method="post" action="admin_forum.php" style="margin: 0px; padding: 0px;" name="form1">
							<input type="hidden" name="sel" id="sel" value="save_edited_category">
							<input type="hidden" name="category_id_ed" id="category_id_ed" value="{$data.id_category}">
							<table cellpadding="5" cellspacing="0">
							<tr>
								<td class="main_header_text">{$lang.forum.category_name}:&nbsp;</td>
								<td class="main_content_text"><input type="text" name="category_name_ed" id="category_name_ed" value="{$data.category_name}"></td>
							</tr>
							<tr>
								<td class="main_header_text">{$lang.forum.category_description}:&nbsp;</td>
								<td class="main_content_text"><textarea name="category_description_ed" id="category_description_ed" style="width: 250px; height: 60px;">{$data.category_description}</textarea></td>
							</tr>
							<tr>
								<td colspan="2">
								<a class="admin_button_major" onclick="Save('category_name_ed', 'category_description_ed', 'save_edited_category', 'category_id_ed');{*document.form1.submit();*}">{$lang.button.save}<span>&nbsp;</span></a>&nbsp;	
								</td>
							</tr>
							</table>
							</form>
						</div>
					</td>		
				</tr>
			</table>
		{/if}

		{strip}

		<table width="100%" border="0" cellpadding="0" cellspacing="1">
		<tr>
			<td valign=top>
				<div style="margin: 0px; padding-bottom: 10px;">
				{include file="$admingentemplates/admin_forum_top.tpl"}
				</div>
				<div>
				{if $par eq 'index'}
				<div id="forum_list" {if $type eq "forum"} class="user_status_elem_active" {else}class="user_status_elem" onclick="/*document.location.href='admin_forum.php?type=forum'*/ Select('forum');"{/if} width="80px">
					{if $type eq "forum"}{$lang.forum.forum_index_page}{else}<a>{$lang.forum.forum_index_page}</a>{/if}
				</div>
				<div id="club_list" {if $type eq "club"} class="user_status_elem_active" {else}class="user_status_elem" onclick="/*document.location.href='admin_forum.php?type=club'*/Select('club');"{/if} width="80px">
					{if $type eq "club"}{$lang.forum.club_index_page}{else}<a>{$lang.forum.club_index_page}</a>{/if}
				</div>
				<div id="list_category_table" style="float: left; width: 100%;">
					<table cellpadding="0" cellspacing="0" width="100%" border="0">
						<tr class="table_header">
							<td width="20%" height="27"  valign="middle" align="left" style="padding-left: 13px; padding-right: 13px;" class="index_quick_search"><b>{$lang.forum.categories}</b></td>
							<td width="51%" valign="middle" align="left" style="padding-left: 13px; padding-right: 13px;" class="index_quick_search"><b>{$lang.forum.category_description}</b></td>    
							<td width="7%" valign="middle" align="left" style="padding-left: 13px; padding-right: 13px;" class="index_quick_search"><b>{$lang.forum.topics}</b></td>
							<td width="7%" valign="middle" align="left" style="padding-left: 13px; padding-right: 13px;" class="index_quick_search"><b>{$lang.forum.posts}</b></td>
							<td width="15%" valign="middle" align="right" style="padding-left: 13px; padding-right: 13px;" class="index_quick_search"><b>{$lang.forum.actions}</b></td>
						</tr>
						{section name=f loop=$forum}
						<tr {if $smarty.section.f.index mod 2 eq 1}class="table_row even"{else}class="table_row odd"{/if}>
							<td height="27" class="main_content_text" align="left" style="padding-left: 13px; padding-right: 13px; padding-top: 5px; ">
								<a href="{$file_name}?sel=category&amp;id_category={$forum[f].id}&type={$type}">{$forum[f].category}</a>
								{*<div id="inform_div{$forum[f].id}" class="error_msg" style="display:none;float:right;"></div>
								<a href="{$file_name}?sel=category&amp;id_category={$forum[f].id}" id="link{$forum[f].id}">{$forum[f].category}</a>
								<input id="text_input{$forum[f].id}" type="text" value="{$forum[f].category}" style="display:none"/>*}
							</td>
							<td width="53%" align="left" class="main_content_text" style="padding-top: 5px;">
								{$forum[f].description}
							</td>
							<td align="left" class="main_content_text" style="padding-top: 5px;padding-left: 13px; ">&nbsp;{$forum[f].total_subcategories}</td>
							<td align="left" class="main_content_text" style="padding-top: 5px;padding-left: 13px; ">&nbsp;{$forum[f].total_posts}</td>
							<td align="right" style="padding-left: 13px; padding-right: 13px; padding-top: 5px;">
								<div class="block_action fr" style="display: none;">
									<div class="action_del" style="display: block;">				
										<img width="16" alt="" onmouseout="javascript:hideToolTip();" onmouseover="javascript: showToolTip(event,'{$lang.button.delete}');return false" src="{$site_root}{$template_root}/images/photo_delete.png" onclick="{literal}if (confirm('{/literal}{$lang.forum.del_confirm|escape:javascript}{literal}')) {document.location.href='admin_forum.php?sel=del_category&id_category={/literal}{$forum[f].id}{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('{$forum[f].id}', '{$forum[f].category}', '{$forum[f].description}');">
									</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="10" alt="" src="{$site_root}{$template_root}/images/arrow_sort_down.png" onmouseout="javascript:hideToolTip();" onmouseover="javascript: showToolTip(event,'{$lang.button.down}');return false" onclick="document.location.href='{$file_name}?sel=move_down&id_category={$forum[f].id}'; 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;">
										<img width="10" alt="" src="{$site_root}{$template_root}/images/arrow_sort_up.png" onmouseout="javascript:hideToolTip();" onmouseover="javascript: showToolTip(event,'{$lang.button.up}');return false" onclick="document.location.href='{$file_name}?sel=move_up&id_category={$forum[f].id}'; return false;">
									</div>
								</div>
							</td>
						</tr>
						{sectionelse}
							<tr height="40">
								<td class="main_error_text" align="left" colspan="6">{$lang.interests_spr.empty}</td>
							</tr>
						{/section}
							<tr class="table_header">
								<td colspan="7">
									&nbsp;&nbsp;
									{if $links}
									{foreach item=item from=$links.pages}
										&nbsp;<a onclick="PageList('bad_words', '{$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('bad_words', '{$links.previous}');">< {$lang.content.previous} {$per_page}</a>
									{/if}
									{if $links.next}
										<a onclick="PageList('bad_words', '{$links.next}');">{$lang.content.next} {$per_page} ></a>
									{/if}
									</div>
								</td>
							</tr>
					</table>
				</div>
				{elseif $par eq 'category'}
					{include file="$admingentemplates/admin_forum_category_table.tpl"}
				{elseif $par eq 'new_subcategory' || $par eq 'new_post' || $par eq 'quote' || $par eq 'edit_post'}
					{include file="$admingentemplates/admin_forum_edit_form.tpl"}
				{elseif $par eq 'subcategory'}
					{include file="$admingentemplates/admin_forum_subcategory_table.tpl"}
				{elseif $par eq 'edit_subcategory'}
					{include file="$admingentemplates/admin_forum_edit_subcategory_table.tpl"}
				{elseif $par eq 'new_category' || $par eq 'edit_category'}
					{include file="$admingentemplates/admin_forum_edit_category_table.tpl"}
				{/if}
				</div>
			</td>
		</tr>
		</table>
	</div>
	

	<!-- end main cell -->
	<script type="text/javascript">
	{literal}

	function PageList(id_div, par) {
		ajaxLoadingImage(1, 'reload_div');
		$.post("admin_forum.php", par, function(data){
			ajaxLoadingImage(0, 'reload_div');
			$('#reload_div').html(data);
		});
	}

	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_edited_category&par=edit&category_id='+id+'&category_name='+value+'&e=1';
		destination_odj = inform_div_obj;
		tmp_text = 'Saving...';
		anisochronous = false;
		ShowAjaxError(tmp_text, '', 'info');

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

		CloseAjaxError(1);
		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>
	{/strip}

{if $ajax == '0'}
</div>
{/if}

<script language="javascript" type="text/javascript">
	{literal}
	function Select(type){
		ajaxLoadingImage(1, 'reload_div');
		$.post("admin_forum.php", {type : type, ajax:'2'}, function(data){
			ajaxLoadingImage(0, 'reload_div');
			$('#reload_div').html(data);
		});
	}
	function add_cat_func(){
		$("input:hidden[name='sel']").val('save_new_category');
		$('#dest_div').css("display", "block");
		$('#dest_div_ed').css("display", "none");	
	}
	function Edit(id, name, desc){
	/*	$("#err"+id).html('');
		$("#"+id).hide();
		$("#edit_"+id).show();*/
		$("input:text[name='category_name_ed']").val(name);	
		$("textarea[name='category_description_ed']").val(desc);
		$("input:hidden[name='sel']").val('save_edited_category');
		$("input:hidden[name='category_id_ed']").val(id);
		$('#dest_div_ed').css("display", "block");	
		$('#dest_div').css("display", "none");	
	}
	function Save(name, desc, par, id){
		var cat_name = document.getElementById(name).value;
		var cat_desc = document.getElementById(desc).value;
		var cat_id = document.getElementById(id).value;
		$('#dest_div').css("display", "none");
		$('#dest_div_ed').css("display", "none");	
		ajaxLoadingImage(1, 'forum_table_div');
		$.post("admin_forum.php", {category_name:cat_name, category_description:cat_desc, sel:par, category_id:cat_id, ajax:'1'}, function(data){
			ajaxLoadingImage(0, 'forum_table_div');
			$('#forum_table_div').html(data);
		});
	}
	function Save2(par, id_user, id_subcategory, id_category){
		ajaxLoadingImage(1, 'forum_table_div2');
		$.post("admin_forum.php", {sel:par, id_user:id_user, id_subcategory:id_subcategory, id_category:id_category, ajax:'1'}, function(data){
			ajaxLoadingImage(0, 'forum_table_div2');
			$('#forum_table_div2').html(data);
		});
	}
	{/literal}
</script>

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