{include file="$admingentemplates/admin_top.tpl"}
<div class="back">
    <a href="{$form.back}">{$lang.button.back}</a>
</div>
	<font class=red_header>{$header.category_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_category_edit}{else}{$help.gs_category_add}{/if}
	</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" style="width:60%;">
	<table border=0 cellspacing=0 cellpadding=0 width="100%" >
		<form method="post" action="{$form.action}"  enctype="multipart/form-data" name="category">
		{$form.hiddens}
			<input type="hidden" name="region_id" id="region_id" value="0" />
			<input type="hidden" name="city_id" id="city_id" value="0" />
			<tr>
				<td valign="top" align="left" width="17%" class="main_header_text" valign="top" 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" valign="top" 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;padding-top:5px;">{$data.comment}</textarea></td>
			</tr>
			<tr>
				<td valign="top" align="left" width="17%" class="main_header_text" valign="top" style="padding-top: 5px;">{$header.sorter}:&nbsp;</td>
				<td colspan=2 class="main_content_text" align="left" style="padding-top:5px;">
				<select name="sorter">
				{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" valign="top" 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 valign="top" colspan=2 class="main_content_text" align="left"><img src="{$data.icon_path}" border=1 vspace="5"><br /><a href="#" class="admin_button" onclick="javascript: document.category.picdel.value = '1'; document.category.submit();">{$button.delete}<span>&nbsp;</span></a></td>
			</tr>
			{/if}
			<tr><td colspan="2" valign="top" align="left" width="17%" class="main_content_text" style="padding: 10px 0 5px;">{$lang.banners.show_for}:</td></tr>
			<tr>
				<td valign="top" align="left" class="main_header_text" style="padding: 5px 0px;" colspan="2">
					{$lang.targeting.show_only}
				</td>
			</tr>
			<tr>
				<td valign="top" align="left" width="17%" class="main_header_text" style="padding-top: 5px;">
					{$lang.banners.usertype}:&nbsp;
				</td>
				<td colspan=2 class="main_content_text" align="left" style="padding-top: 5px;">
					<select name="id_user_type">
						<option value="0"></option>
						{foreach item=item from=$user_types name=user_type}
							<option type="radio" name="im" value="{$item.id}" {if $id_user_type && $item.id eq $id_user_type}selected{/if} id="user_type_{$smarty.foreach.user_type.iteration}" >
								{$item.name}
							</option>
						{/foreach}
					</select>
				</td>
			</tr>
			<tr>
				<td align="left" width="17%" class="main_header_text" valign="top" style="padding-top: 5px;">
					{$lang.country.country}:&nbsp;
				</td>
				<td colspan=2 class="main_content_text" align="left" style="padding-top:5px;">
					<select name="id_country" style="width: 195px;" onchange="ChangeLocation(this);">
						<option value="0"></option>
						{foreach item=item from=$country}<option value="{$item.id}" {if $item.sel}selected{/if}>{$item.value}</option>{/foreach}
					</select>
				</td>
			</tr>
			<tr>
				<td align="left" width="17%" class="main_header_text" valign="top" style="padding-top: 5px;">
					{$lang.country.region}:&nbsp;
				</td>
				<td colspan=2 class="main_content_text" align="left" id="region_div" style="padding-top:5px;">
					<select name="region" style="width: 195px;" onchange="ChangeLocation(this);">
						<option value="0"></option>
						{foreach item=item from=$region}<option value="{$item.id}" {if $item.sel}selected{/if}>{$item.value}</option>{/foreach}
					</select>
				</td>
			</tr>
			<tr>
				<td align="left" width="17%" class="main_header_text" valign="top" style="padding-top: 5px;">
					{$lang.country.city}:&nbsp;
				</td>
				<td colspan=2 class="main_content_text" align="left" id="city_div" style="padding-top:5px;">
					<select name="city" style="width: 195px;">
						<option value="0"></option>
							{foreach item=item from=$city}<option value="{$item.id}" {if $item.sel}selected{/if}>{$item.value}</option>{/foreach}
					</select>
				</td>
			</tr>					
		</form>
	</table>
	</div>
	</div>
	<table width="100%">
	<tr height="40">
		{if $form.par eq "edit"}
		{if $data.root  ne 1}
			<td>
				<a href="#" class="admin_button_major" onclick="Save()" href="#">{$button.save}
					<span>&nbsp;</span>
				</a>
			</td>
		<td align="right">
			<a href="#" class="admin_button" onclick="{literal}javascript: if(confirm({/literal}'{$form.confirm}'{literal})){location.href={/literal}'{$form.delete}'{literal}}{/literal}">
				{$button.delete}<span>&nbsp;</span>
			</a>
		</td>{/if}
		{else}
		<td><a href="#" class="admin_button_major" onclick="Save()">{$button.add}<span>&nbsp;</span></a></td>
		{/if}
	</tr>
	</table>
<script>
{literal}
function Save() {
	$('#region_id').val($('select[name=region]').val());
	$('#city_id').val($('select[name=city]').val());
	document.category.submit();
}

function ChangeLocation(obj){
    if($(obj).attr('name') == 'id_country'){
	     SelectRegion($(obj).val(), document.getElementById('region_div'), document.getElementById('city_div'));
		 return 1;
    }
    if($(obj).attr('name') == 'region'){
		SelectCity($(obj).val(), document.getElementById('city_div'));
		region = $("select[name=region]").val();
		$("#region_id").val(region);
		return 1;
    }

}
{/literal}
{$javascript}
</script>
{include file="$admingentemplates/admin_bottom.tpl"}