{if $object_type==1}
	<!--CATEGORY FORM-->
		<form name="add_cat" action="{$form.action}" method="POST" enctype="multipart/form-data">
		{$form.hiddens}
		<table class="panel_section" cellpadding="5" cellspacing="1" width="50%">
			<tr class="table_row">
				<td width="160px">{$lang.catalog.cat_name}</td>
				<td align="left">
					<input type="text" name="cat_name" value="{if isset($smarty.post.cat_name)}{$smarty.post.cat_name}{else}{$cat.name}{/if}" style="width:200px">
				</td>
			</tr>
			<tr class="table_row">
				<td>{$lang.catalog.add_to_cat}</td>
			 	<td align="left">
					<select name="id_root" style="width:200px">
						{foreach name=s item=item key=key from=$cats}
							<option value="{$item.id}" {if (!isset($smarty.request.id_root) && $item.id==$id_curr) || ($smarty.request.id_root==$item.id)}selected{/if}>{section name=s loop=$item.level-1}&nbsp;&nbsp;{/section}{$item.name}</option>
						{/foreach}
					</select>
				</td>
			</tr>
		</table>
		<div style="padding: 2px;" align="left">
			<a class="admin_button_major" onclick="javascript: document.add_cat.submit();">{$lang.button.save}<span>&nbsp;</span></a>
			<a class="admin_button_cancel" onclick="javascript: ClearWindow('dest_div');">{$lang.button.close}<span>&nbsp;</span></a>&nbsp;
		</div>
		</form>
	<!--CATEGORY FORM-->
{elseif $object_type==2}
	<!--PRODUCT FORM-->
		<form name="add_object" action="{$form.action}" method="POST" enctype="multipart/form-data" onsubmit="javascript: return checkObjectForm();">
		{$form.hiddens}
		<table width="100%" cellpadding="0" cellspacing="5" class="panel_section">
			<tr>
				<td width="50%" valign="top">
					<table width="100%" cellpadding="5" cellspacing="1">
						<tr class="table_row">
							<td>{$lang.catalog.add_to_cat}</td>
						 	<td align="left">
								<select name="id_root" style="width:200px" onchange="javascript: LoadCategoryForm({$id_object}, this.value, 'ado_form_div');">
									{foreach name=s item=item key=key from=$cats}
										<option value="{$item.id}" {if $item.id==$id_root}selected{/if}>{section name=s loop=$item.level-1}&nbsp;&nbsp;{/section}{$item.name}</option>
									{/foreach}
								</select>
							</td>
						</tr>
						<tr class="table_row">
							<td height="30px" class="text_head">
								{$lang.common.status}:
							</td>
							<td>
								<select name="status" style="width:200px">
									<option value="1" {if $object.status==1}selected{/if}>{$lang.common.hide}
									<option value="2" {if $object.status==2 || $object==false}selected{/if}>{$lang.common.show}
								</select>
							</td>
						</tr>
						<tr class="table_row">
							<td height="30px" class="text_head">
								{$lang.common.subject}
							</td>
							<td>
								<input type="text" name="name" value="{if isset($smarty.post.name)}{$smarty.post.name}{else}{$object.name}{/if}" style="width: 300px">
							</td>
						</tr>
						<tr class="table_row">
							<td height="30px" class="text_head" colspan="2">
								{$lang.common.body}
							</td>
						</tr>
						<tr class="table_row">
							<td colspan="2">
								<table width="100%" cellpadding="0" cellspacing="0">
									<tr>
										<td colspan="2">
											{if !$ajax}{$redactor}{/if}
											<textarea name="body" id="message" style="width: 90%; height:200px">{if isset($smarty.post.body)}{$smarty.post.body}{else}{$object.body}{/if}</textarea>
										</td>
									</tr>
								</table>
							</td>
						</tr>
					</table>
				{*</td>
				<td width="50%" valign="top">*}
					<div id="ado_form_div">
						{include file="$admingentemplates/ajax_classified.tpl"}
					</div>
				</td>
			</tr>
		</table>
		<div style="padding: 2px;" align="left">
			<a class="admin_button_major" onclick="javascript: document.add_object.submit();">{$lang.button.save}<span>&nbsp;</span></a>
			<a class="admin_button_cancel" onclick="javascript: ClearWindow('dest_div');">{$lang.button.close}<span>&nbsp;</span></a>&nbsp;
		</div>
		</form>
	<!--PRODUCT FORM-->
{/if}


<script language="javascript" type="text/javascript">
{literal}
function  CheckCatForm(){
	var form=document.add_cat;
	
	if(form.cat_name.value==''){
		{/literal}
		alert("{$lang.err.cat_name_empty|escape:javascript}");
		form.cat_name.focus();
		return false;
		{literal}
	}
}
function checkObjectForm(){
	var form=document.add_object;
	var res=checkForm();
	if(res==false) return res;
	
	if(form.name.value==''){
		{/literal}
		alert("{$lang.err.empty_subject|escape:javascript}");
		form.name.focus();
		return false;
		{literal}		
	}
	if(form.body.value==''){
		{/literal}
		alert("{$lang.err.empty_classbody|escape:javascript}");
		form.body.focus();
		return false;
		{literal}
	}
	return true;
}
{/literal}
</script>

<script type="text/javascript">
{literal}
var	smileLayer	= 0;

var	bbcode		= Array();
bbcode['b']		= Array('[b]', '[/b]');
bbcode['i']		= Array('[i]', '[/i]');
bbcode['u']		= Array('[u]', '[/u]');
bbcode['img']	= Array('[img]', '[/img]');
bbcode['url']	= Array('[url={$lang.forum.insert_link_url}]', '{$lang.forum.insert_link_name}[/url]');

bbcode['s1']	= Array(' :) ');
bbcode['s2']	= Array(' ;) ');
bbcode['s3']	= Array(' :D ');
bbcode['s4']	= Array(' 8) ');
bbcode['s5']	= Array(' :] ');
bbcode['s6']	= Array(' :O ');
bbcode['s7']	= Array(' :/ ');
bbcode['s8']	= Array(' :( ');
bbcode['s9']	= Array(' ;( ');
bbcode['s10']	= Array(' O_O ');


function insertBB(code)
{
	var tag1 = bbcode[code][0];
	var tag2 = bbcode[code][1];
	var txta = document.getElementById('message');
	txta.focus();

	if (typeof document.selection != 'undefined') {
		var range = document.selection.createRange();
		var sel = range.text;
		range.text = tag2 ? tag1 + sel + tag2 : tag1;
		range = document.selection.createRange();
		if (tag2 && !sel.length) range.move('character', -tag2.length);
		else if (tag2) range.move('character', tag1.length + sel.length + tag2.length);
		range.select();
	}
	else if (typeof txta.selectionStart != 'undefined') {
		var scroll = txta.scrollTop;
		var start  = txta.selectionStart;
		var end    = txta.selectionEnd;
		var before = txta.value.substring(0, start);
		var sel    = txta.value.substring(start, end);
		var after  = txta.value.substring(end, txta.textLength);
		txta.value = tag2 ? before + tag1 + sel + tag2 + after	: before + tag1 + after;
		var caret = sel.length == 0	? start + tag1.length : start + tag1.length + sel.length + tag2.length;
		txta.selectionStart = caret;
		txta.selectionEnd = caret;
		txta.scrollTop = scroll;
	}
	return false;
}

function displaySmileLayer()
{
	if (document.getElementById('smiles').style.display == 'none') {
		document.getElementById('smiles').style.display = 'inline';
	} else {
		document.getElementById('smiles').style.display = 'none';
	}
	return false;
}
{/literal}
</script>