{include file="$admingentemplates/admin_top.tpl"}
<div class="back">
    <a href="{$form.back}">{$lang.button.back}</a>
</div>
			<font class=red_header>{$header.item_editform}</font>
			<div class="cr">&nbsp;</div>
            <div class="show_help" style="display: none;">&nbsp;</div>
			<div class="help_text" style="padding:5px;">
				<div class="close_help">
				  <img src="{$site_root}{$template_root}/images/close_help.png" alt="">
				</div>
				<span class="help_title">{$lang.help}:</span>{if $form.par eq "edit"}{$help.gs_item_edit}{else}{$help.gs_item_add}{/if}
			</div>
{*			<div style="padding:5px;">
            <font class=red_sub_header style="color: #208B2F;">{$header.item_editform}:</font>
			</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}
			<div  class="panel_section">
			<div  class="panel_content">
			<table border=0 cellspacing=0 cellpadding=0 width="100%">
                <form method="post" action="{$form.action}"  enctype="multipart/form-data" name="items_form">
                {$form.hiddens}
					<tr>
                        <td valign="top" align="left" width="17%" class="main_header_text" style="padding-top: 5px;">{$header.name}<font class=main_error_text>*</font>:&nbsp;</td>
                        <td class="main_content_text" align="left" style="padding-top:5px;"><input type="text" name="name" value="{$data.name}" size=30  style="width: 300"></td>
                        <td class="main_header_text" align="left" width="65%">&nbsp;{$header.status}&nbsp;<input type="checkbox" name="status" value="1" {if $data.status}checked{/if} ></td>
                    </tr>
					<tr>
                        <td valign="top" align="left" width="17%" class="main_header_text" style="padding-top: 5px;">{$header.comment}:&nbsp;</td>
                        <td colspan=2 class="main_content_text" align="left" style="padding-top:5px;"><textarea name="comment"  style="width: 300; height: 200">{$data.comment}</textarea></td>
                    </tr>
					<tr>
                        <td valign="top" align="left" width="17%" class="main_header_text" style="padding-top: 5px;">{$header.price}:&nbsp;</td>
                        <td colspan=2 class="main_content_text" align="left" style="padding-top:5px;"><input type="text" name="price" value="{$data.price}" size=20  style="width: 100">&nbsp;{$form.curency}</td>
                    </tr>
					<tr>
                        <td valign="top" align="left" width="17%" class="main_header_text" style="padding-top: 5px;">{$header.category}:&nbsp;</td>
                        <td colspan=2 class="main_content_text" align="left" style="padding-top:5px;">
						<!-- onchange="javascript:document.items_form.subcat.value='1'; document.items_form.submit()" -->
                        <select name="id_cat" onchange="change_category(this.options[this.selectedIndex].value);">
						<option value="0">{$button.nothing}</option>
						{section name=s loop=$category}
							<option value="{$category[s].id}" {if $data.id_category eq $category[s].id}selected{/if}>{$category[s].name}</option>
						{/section}
						</select>
						</td>
                    </tr>
					
					<tr>
                        <td valign="top" align="left" width="17%" class="main_header_text" style="padding-top: 5px;">{$header.subcategory}:&nbsp;</td>
                        <td id="subcategory_div" colspan=2 class="main_content_text" align="left" style="padding-top:5px;">
						<!-- onchange="javascript:document.items_form.subcat.value='1'; document.items_form.submit()" -->
                        <select id="subcat" name="subcat" onchange="change_subcategory(this.options[this.selectedIndex].value);">
						<option value="0">{$button.nothing}</option>
						{section name=s loop=$subcategory}
							<option value="{$category[s].id}" {if $data.id_subcat eq $subcategory[s].id}selected{/if}>{$subcategory[s].name}</option>
						{/section}
						</select>
						</td>
                    </tr>
					
					<tr>
                        <td valign="top" align="left" width="17%" class="main_header_text" style="padding-top: 5px;">{$header.sorter}:&nbsp;</td>
                        <td colspan=2 class="main_content_text" align="left" style="padding-top:5px;" id="sorter_div">
                        <select name="sorter_div">
						<option value="0">{$button.nothing}</option>
						{section name=s loop=$sorter}
							<option value="{$smarty.section.s.index_next}" {if $sorter[s].sel}selected{/if}>{$smarty.section.s.index_next}</option>
						{/section}
						</select>
						</td>
                   </tr>
					<tr>
                        <td valign="top" align="left" width="17%" class="main_header_text" style="padding-top: 5px;">{$header.icon}:&nbsp;</td>
                        <td colspan=2 class="main_content_text" align="left" style="padding-top:5px;"><input type="file"  name="icon"></td>
                    </tr>
					{if $data.icon_path}
                    <tr height="20">
			<td>&nbsp;</td>
                        <td colspan=2 class="main_content_text" align="left"><img src="{$data.icon_path}" border=1 vspace="5"><br /><a class="admin_button"  onclick="javascript: document.items_form.picdel.value = '1'; document.items_form.submit();return false;" href="#">{$button.delete}<span>&nbsp;</span></a></td>
                    </tr>
					{/if}
					{if $form.par eq "edit"}
					<tr>
                        <td valign="top" align="left" width="17%" class="main_header_text" >{$header.images}:&nbsp;</td>
                        <td colspan=2 class="main_content_text" align="left">
				<table><tr>
				<td><input type="file" name="images" style="border: 0px;" ></td>
				<td><a class="admin_button" onclick="javascript: document.items_form.imgupload.value = '1'; document.items_form.submit();return false;" href="#">{$button.upload}<span>&nbsp;</span></a></td>
				</tr></table>
			</td>
                    </tr>
					{if $data.gallery}
                    <tr height="20">
			<td>&nbsp;</td>
                        <td colspan=2 class="main_content_text" align="left">
				<table><tr>
				{foreach item=item key=key from=$data.gallery}<td align=center>
				<img src="{$item.thumb_image_path}" border=1><br>
				<a href="#" onclick="javascript: document.items_form.picdel.value = '1'; document.items_form.picdelid.value = '{$item.id}';document.items_form.submit();" class="main_content_text">[{$button.delete}]</a>
				</td>{/foreach}
				</tr></table>
			</td>
                    </tr>
					{/if}
					{/if}
                    </form>
            </table>
			</div></div>
<table width="100%"><tr height="40">
			{if $form.par eq "edit"}
			{if $data.root  ne 1}<td><a class="admin_button_major" href="#" onclick="javascript:document.items_form.submit()">{$button.save}<span>&nbsp;</span></a></td>
			<td align="right"><a href="#" onclick="{literal}{location.href={/literal}'{$form.delete}'{literal}}{/literal}; return false;" class="admin_button">{$button.delete}<span>&nbsp;</span></a></td>{/if}
			{else}
			<td><a class="admin_button_major" href="#" onclick="javascript:document.items_form.submit();">{$button.add}<span>&nbsp;</span></a></td>
			{/if}
{*			<td><a class="admin_button" href='{$form.back}'>{$button.back}<span>&nbsp;</span></a></td>*}
			</tr></table>
{include file="$admingentemplates/admin_bottom.tpl"}
{literal}
<script type="text/javascript">
$(document).ready(function() {
	var id_cat = 1;
	var id_subcat = 1;	
	var par = "sel=subcat&ajax=1&page=1&id_category="+id_cat;
	$.post("admin_giftshop.php", par, function(data){
		$('#subcategory_div').html(data);			
	});
});

	function change_category(id_cat){
		$('#id_category').val(id_cat);
		var par = "sel=subcat&ajax=1&page=1&id_category="+id_cat;
		$.post("admin_giftshop.php", par, function(data){
			$('#subcategory_div').html(data);
		});
	}
	function change_subcategory(id_subcat){
		$('#id_subcat').val(id_subcat);
		var par = "sel=get_sorter&ajax=1&page=1&id_subcat="+id_subcat;
		$.post("admin_giftshop.php", par, function(data){
			$('#sorter_div').html(data);			
		});
	}
	function change_sorter(id_sort){
		$('#sorter').val(id_sort);
	}
</script>
{/literal}