{include file="$admingentemplates/admin_top.tpl"}
<script language="JavaScript" type="text/javascript" src="{$site_root}{$template_root}/js/classifieds.js"></script>
<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.catalog.razdel_name}</div>
<div class="cr">&nbsp;</div>
<div class="cr">&nbsp;</div>
<div class="help_text" style="display:block;-moz-border-radius: 10px 10px 10px 10px;">
    <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>{if $id_cat==1}{$lang.admin_help.catalog_root_hint}{else}{$lang.admin_help.catalog_cat_hint}{/if}
    </div>
</div>
<div class="cr">&nbsp;</div>
<ul class="tabs">
    <li>
        <a class="current">{$lang.admin_menu.cat_manager}</a>
    </li>
    <li>
        <a href="admin_form_blocks.php">{$lang.admin_menu.form_blocks}</a>
    </li>
    <li>
        <a href="admin_patterns.php">{$lang.admin_menu.patterns}</a>
    </li>
    <li>
        <a href="admin_datasources.php">{$lang.admin_menu.ref_datasources}</a>
    </li>
</ul>
<div class="user_operation_line">
	{if $id_cat!=1}
		<div onclick="javascript: LoadCatForm(0, {$id_cat}, 'dest_div');" class="uol_item">
			<div class="uol_in_item">{$lang.catalog.add_subcat}</div>
		</div>
		<div onclick="javascript: LoadObjectForm(0, {$id_cat}, 'dest_div');" class="uol_item">
			<div class="uol_in_item">{$lang.catalog.add_object}</div>
		</div>
		<div onclick="javascript: loadscript();" class="uol_item">
			<div class="uol_in_item">{$lang.catalog.edit_cat_form}</div>
		</div>
	{else}
		<div onclick="javascript: LoadCatForm(0, {$id_cat}, 'dest_div');" class="uol_item">
			<div class="uol_in_item">{$lang.catalog.add_cat}</div>
		</div>
	{/if}
</div>
<div class="cr"></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}

<!--FORM-->
	<table width="100%">
		<tr class="table_row">
			<td align="left" valign="top">
				<span class="main_header_text">{$lang.catalog.cat_level}:</span>&nbsp;
				{section name=s loop=$level}
					{if $smarty.section.s.last}
						<font>{$level[s].name}</font>
					{else}
						<a href="{$view_link}?id_cat={$level[s].id}">{$level[s].name}>&nbsp;</a>
					{/if}
				{/section}
				<br><br><font class="red_sub_header" style="color:#208B2F;">
						{if $id_cat==1}{$lang.catalog.category_cats}{else}{$lang.catalog.category_subcats}{/if}
					</font>
			</td>
			<td align="right">
				<span class="main_header_text">{$lang.catalog.jump_to}:</span>&nbsp;
				<select id="jump_cat">
					{foreach name=t item=item key=key from=$tree}
						<option value="{$item.id}" {if $item.id==$id_cat}selected{/if}>{section name=s loop=$item.level-1}&nbsp;&nbsp;{/section}{$item.name}
					{/foreach}
				</select>&nbsp;
				<br><a href="#" class="admin_button_major" onclick="javascript: id_cat=document.getElementById('jump_cat').value; location.href='{$view_link}?id_cat='+id_cat;">{$lang.button.jump}<span>&nbsp;</span></a>
			</td>
		</tr>
{*		<tr>
			<td colspan="2">
			</td>
		</tr>*}
		<tr>
			<td colspan="2">
				<div id="dest_div">
					{$content}
				</div>
			</td>
		</tr>
	</table>
<!--FORM-->

{if $subcats_count>0}
{*	<div style="margin-top: -35px; margin-left: 3px;"><font class="red_sub_header" style="color:#208B2F;">
		{if $id_cat==1}{$lang.catalog.category_cats}{else}{$lang.catalog.category_subcats}{/if}
	</font></div><br>*}
<div id="general_div">
<!--SUBCATS TABLE-->
<div id="catalog_table_div">
{*	<table cellpadding="0" cellspacing="0" width="100%">*}
	<table border=0 cellspacing=0 cellpadding=3 width="100%">
		<tr class="table_header">
			<td width="75px" class="main_header_text" colspan="2" align="right">N/N</td>
			<td class="main_header_text" align="left">{$lang.catalog.cat_name}</td>
			<td width="200px" align="right">{$lang.button.action}</td>
		</tr>
		{foreach name=sub item=item key=key from=$subcats}
		<tr {if $smarty.foreach.sub.iteration mod 2 eq 1} class="odd" {else} class="even" {/if}>
			<td class="main_content_text" align="center" width="60px">
{*					<table width="100%" cellpadding="0" cellspacing="0">
					<tr>
						<td align="center">
						<div class="block_action fr" style="display: none;">
							<div class="action_edit" style="display: block;cursor:pointer;">
								<img height="16" alt="" src="{$site_root}{$template_root}/images/newsletter/arrow_up.gif" onclick="javascript: location.href='{$up_link}&id_obj={$item.id}'">
							</div>
						</div>*}
{*							<a class="admin_button_major" onclick="javascript: location.href='{$up_link}&id_obj={$item.id}'">{$lang.button.up}<span>&nbsp;</span></a>*}
{*							</td>
					</tr>
					<tr>
						<td align="center">*}
{*							<a class="admin_button_major" onclick="javascript: location.href='{$down_link}&id_obj={$item.id}'">{$lang.button.down}<span>&nbsp;</span></a>*}
{*							<div style="width:10px;float:right;" class="fl">&nbsp;</div>
							<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/newsletter/arrow_down.gif" onclick="javascript: location.href='{$down_link}&id_obj={$item.id}'">
							</div>
						</div>*}
{*						</td>
					</tr>
				</table>*}
							<table>
								<tr>
									<td align="center">
										<div style="cursor: pointer;" onclick="javascript: location.href='{$up_link}&id_obj={$item.id}'"><img onmouseout="javascript:hideToolTip();" onmouseover="javascript: showToolTip(event,'{$lang.button.up}');return false" src="{$site_root}{$template_root}/images/arrow_sort_up.png" border="0"></div>
									</td>
								</tr>
								<tr>
									<td align="center">
										<div style="cursor: pointer;" onclick="javascript: location.href='{$down_link}&id_obj={$item.id}'"><img src="{$site_root}{$template_root}/images/arrow_sort_down.png" onmouseout="javascript:hideToolTip();" onmouseover="javascript: showToolTip(event,'{$lang.button.down}');return false" border="0"></div>
									</td>
								</tr>
							</table>
			</td>
			<td class="main_content_text" width="15px">{$item.sorter}</td>
			<td class="main_content_text" align="left">
				<a href="{$view_link}?id_cat={$item.id}">{$item.name}</a>
			</td>
			<td class="main_content_text" align="center">
						<div class="block_action fr" style="display: none;">
							<div class="action_edit" style="display: block;float:left;cursor:pointer;">
								<img height="16" alt="" src="{$site_root}{$template_root}/images/edit.png" onmouseout="javascript:hideToolTip();" onmouseover="javascript: showToolTip(event,'{$lang.button.edit}');return false" onclick="javascript: LoadCatForm({$item.id}, {$id_cat}, 'dest_div'); window.scroll(0,0);">
							</div>
							<div style="width:10px;" class="fl">&nbsp;</div>
							<div class="action_edit" style="display: block;float:left;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 (window.confirm('{$lang.confirm.del_cat|escape:javascript}')) location.href='{$del_cat_link}&id_object={$item.id}'; else return false;">
							</div>
						</div>
{*					<a class="admin_button" onclick="javascript: LoadCatForm({$item.id}, {$id_cat}, 'dest_div'); window.scroll(0,0);">{$lang.button.edit}<span>&nbsp;</span></a>
				<a class="admin_button" onclick="javascript: if (window.confirm('{$lang.confirm.del_cat|escape:javascript}')) location.href='{$del_cat_link}&id_object={$item.id}'; else return false;">{$lang.button.delete}<span>&nbsp;</span></a>*}
				</td>
		</tr>
		{foreachelse}
		<tr height="40">
			<td class="main_error_text" align="left" colspan="5">{$lang.catalog.no_subcats}</td>
		</tr>
		{/foreach}	
		<tr class="table_header"><td colspan="4"></td></tr>		
	</table>
</div>
<!--SUBCATS TABLE-->
	<br>
{/if}

{if $objects_count>0}
	<div><font class="red_sub_header" style="color: #208B2F;font-size: 14px;">{$lang.catalog.category_ads}</font></div><br>

<!--OBJECTS TABLE-->
	<table cellpadding="0" cellspacing="0" width="100%">
		<tr class="table_header">
			<td width="20px" class="main_header_text">N/N</td>
			<td class="main_header_text" align="left" width="200px">{$lang.catalog.posted_by}</td>
			<td class="main_header_text" align="left">{$lang.common.subject}</td>
			<td width="200px" align="right">{$lang.button.action}</td>
		</tr>
		{foreach name=obj item=item key=key from=$objects}
			<tr {if $smarty.foreach.obj.iteration mod 2 eq 1}class="even"{else}class="odd"{/if}>
				<td class="main_header_text">{$smarty.foreach.obj.iteration}</td>
				<td class="main_content_text" align="left">
					{$users[$item.id_user].fname}&nbsp;{$users[$item.id_user].sname}({$users[$item.id_user].login})
				</td>
				<td class="main_content_text" align="left">
					<a href="{$view_plink}&id_p={$item.id}">{$item.name}</span>
				</td>
				<td align="center">
{*					<a class="admin_button" onclick="javascript: LoadObjectForm({$item.id}, {$id_cat}, 'dest_div'); window.scroll(0,0);">{$lang.button.edit}<span>&nbsp;</span></a>
					<a class="admin_button" onclick="javascript: if (window.confirm('{$lang.confirm.del_object|escape:javascript}')) location.href='{$del_obj_link}&id_object={$item.id}'; else return false;">{$lang.button.delete}<span>&nbsp;</span></a>
*}							<div class="block_action fr" style="display: none;">
								<div class="action_edit" style="display: block;float:right;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 (window.confirm('{$lang.confirm.del_object|escape:javascript}')) location.href='{$del_obj_link}&id_object={$item.id}'; else return false;">
								</div>
								<div style="width:10px;float:right;" class="fl">&nbsp;</div>
								<div class="action_edit" style="display: block;float:right;cursor:pointer;">
									<img height="16" alt="" src="{$site_root}{$template_root}/images/edit.png" onmouseout="javascript:hideToolTip();" onmouseover="javascript: showToolTip(event,'{$lang.button.edit}');return false" onclick="javascript: LoadObjectForm({$item.id}, {$id_cat}, 'dest_div'); window.scroll(0,0);">
								</div>
							</div>
				</td>
			</tr>
		{foreachelse}
			<tr height="40">
				<td class="main_error_text" align="left" colspan="4">{$lang.catalog.no_objects}</td>
			</tr>
		{/foreach}
		<tr class="table_header"><td colspan="4"></td></tr>
	</table>
<!--PRODUCTS TABLE-->
{/if}

{if $cat.id!=1}
	<div align="left" style="padding:2px;margin-top:13px;">
		<a class="admin_button_major" onclick="javascript: location.href='{$view_link}?id_cat={$cat.id_parent}';">{$lang.button.up_level}<span>&nbsp;</span></a>
		<a class="admin_button_major" onclick="javascript: location.href='{$view_link}'">{$lang.button.up_root}<span>&nbsp;</span></a>
	</div>
{/if}
</div>
<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>
<script language="javascript" type="text/javascript">
{literal}
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 loadscript(){
	var script = document.createElement('script');
	script.onload = function() {
	  LoadFormManager('{/literal}{$id_cat}{literal}', 'dest_div')
	};
    script.src="{/literal}{$site_root}{$template_root}{literal}/js/forms.js";
    document.body.appendChild(script);
	var sc=document.createElement("SCRIPT");
    sc.src="{/literal}{$site_root}{$template_root}{literal}/js/scriptaculous/prototype.js";
    document.body.appendChild(sc);
	var sc1=document.createElement("SCRIPT");
    sc1.src="{/literal}{$site_root}{$template_root}{literal}/js/scriptaculous/scriptaculous.js";
    document.body.appendChild(sc1);
	var sc2=document.createElement("SCRIPT");
    sc2.src="{/literal}{$site_root}{$template_root}{literal}/js/scriptaculous/builder.js";
    document.body.appendChild(sc2);
	var sc3=document.createElement("SCRIPT");
    sc3.src="{/literal}{$site_root}{$template_root}{literal}/js/scriptaculous/effects.js";
    document.body.appendChild(sc3);
	var sc4=document.createElement("SCRIPT");
    sc4.src="{/literal}{$site_root}{$template_root}{literal}/js/scriptaculous/dragdrop.js";
    document.body.appendChild(sc4);
	var sc5=document.createElement("SCRIPT");
    sc5.src="{/literal}{$site_root}{$template_root}{literal}/js/scriptaculous/controls.js";
    document.body.appendChild(sc5);
	var sc6=document.createElement("SCRIPT");
    sc6.src="{/literal}{$site_root}{$template_root}{literal}/js/scriptaculous/slider.js";
    document.body.appendChild(sc6);
	$('#general_div').css("display", "none");
}
{/literal}
</script>
<script language="JavaScript" type="text/javascript" src="{$site_root}{$template_root}/js/classifieds.js"></script>
<script language="JavaScript" type="text/javascript" src="{$site_root}{$template_root}/js/common.js"></script>


{*<script language="JavaScript" type="text/javascript" src="{$site_root}{$template_root}/js/scriptaculous/prototype.js"></script>
<script language="JavaScript" type="text/javascript" src="{$site_root}{$template_root}/js/scriptaculous/scriptaculous.js"></script>
<script language="JavaScript" type="text/javascript" src="{$site_root}{$template_root}/js/scriptaculous/builder.js"></script>
<script language="JavaScript" type="text/javascript" src="{$site_root}{$template_root}/js/scriptaculous/effects.js"></script>
<script language="JavaScript" type="text/javascript" src="{$site_root}{$template_root}/js/scriptaculous/dragdrop.js"></script>
<script language="JavaScript" type="text/javascript" src="{$site_root}{$template_root}/js/scriptaculous/controls.js"></script>
<script language="JavaScript" type="text/javascript" src="{$site_root}{$template_root}/js/scriptaculous/slider.js"></script>
<script language="JavaScript" type="text/javascript" src="{$site_root}{$template_root}/js/forms.js"></script>*}
{include file="$admingentemplates/admin_bottom.tpl"}