{include file="$admingentemplates/admin_top.tpl"}
<div class="back">
    <a href="{$file_name}?sel=games_list&id_category={$id_category}">{$lang.button.back}</a>
</div>
<div class="cr"></div>
<div class="show_help" style="display: none;">&nbsp;</div>
<div class="red_header">{$lang.admin_games.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>{$help.admin_games_edit}
    </div>
</div>
<div class="cr">&nbsp;</div>
<div class="panel_section">
<div class="panel_content">
	<form action="{$file_name}" name="add_game" method="POST"  enctype="multipart/form-data">
	<input type="hidden" name="id_games" value="{$games.id}">
	<input type="hidden" name="id_category" value="{$id_category}">
	<input type="hidden" name="sel" value="add_games">
	<input type="hidden" name="file_path" id="file_path" value="{$games.id}">
	<div style="padding-top: 10px;">
		<table border=0 cellspacing=1 cellpadding=5 width="100%">
			<tr>
				<td class="main_header_text" align="left">
					{$lang.admin_games.categories}:&nbsp;<font class="error_msg">*</font>
				</td>
				<td align="left" colspan="2">
					<select name="category">
					{foreach item=item from=$category}
						<option value="{$item.id_category}" {if $item.sel eq '1'}selected{/if}>{$item.name}</option>
					{/foreach}
					</select>
				</td>
			</tr>
			<tr>
				<td class="main_header_text" align="left">
					{$lang.admin_games.name}:&nbsp;<font class="error_msg">*</font>
				</td>
				<td align="left" colspan="2">
					<input type="text" name="name" size="35" value="{$games.name}">
				</td>
			</tr>
			<tr>
				<td class="main_header_text" align="left">
					{$lang.admin_games.code}:&nbsp;<font class="error_msg">*</font>
				</td>
				<td align="left">
					<textarea name="code" id="code" cols="60" rows="2">{$games.code}</textarea>
				</td>
				<td align="left">
					<div style="padding-top:10px;padding-right:10px;float:left"><input type="checkbox" name="arhiv" value="1" id="arhiv">{$lang.admin_games.games_import}</div>
					<div style="padding-top:10px;"><input disabled type="file" name="import" id="import"></div>
				</td>
			</tr>
			<tr>
				<td class="main_header_text" align="left">
					{$lang.admin_games.games_is_paid}:&nbsp;
				</td>
				<td align="left" colspan="2">
					<input type="checkbox" name="paid" id="paid" value="1" {if $games.paid eq 1}checked{/if} {if $games_settings.use_paid eq 0} disabled {/if}>
				</td>
			</tr>
{*			<tr>
				<td colspan="3">
					<div class="help_text" style="margin:0px;">{$lang.admin_help.admin_games_edit_descr}</div>
					<div class="help_text" style="display:block;margin:0px;">
						<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.admin_games_edit_descr}
						</div>
					</div>
				</td>
			</tr>*}
			<tr>
				<td class="main_header_text" align="left">
					{$lang.admin_games.games_description}:
				</td>
				<td align="left" colspan="2">
					<textarea name="description" cols="60" rows="5">{$games.description}</textarea>
				</td>
			</tr>
			<tr>
				<td class="main_header_text" align="left">
					{$lang.admin_games.games_instruction}:
				</td>
				<td align="left" colspan="2">
					<textarea name="instruction" cols="60" rows="5">{$games.instruction}</textarea>
				</td>
			</tr>
			<tr>
				<td class="main_header_text" align="left">
					{$lang.admin_games.games_icon}:
				</td>
				<td align="left">
					<div style="padding-top:10px;padding-right:10px;float:left"><input type="radio" name="icon_type" value="1" id="upload" checked>{$lang.admin_games.upload_icon}</div>
					<div style="padding-top:10px;"><input type="file" name="icon" id="icon"></div>
					<div style="padding-top:10px"><input type="radio" name="icon_type" value="2" id="select">{$lang.admin_games.select_icon}</div>
				</td>
				<td>
					<div id="def_icon">
						<img src="{$games.icon}" height="100" width="100" style="border: 1px solid #cccccc;">
					</div>
					<div id="set_icon" style="display:none;">
					</div>
				</td>
			</tr>
		</table>
	</div>
		<div id="icon_list" style="height:260px;padding:5px 0px;display:none;overflow-y:auto;">
			<table cellpadding="0" cellspacing="0" border="0" width="100%" align="left">
				{section name=c loop=$files}
				{if $smarty.section.c.index is div by 8}<tr>{/if}
					<td width="12.5%" valign="top" align="center" class="text" style="padding-top: 25px;">
						<img src="{$files[c].path}" height="100" width="100" style="border: 1px solid #cccccc;" class="icon" onclick="SetIcon('{$files[c].name}','{$files[c].path}');">
					</td>
				{if $smarty.section.c.index_next is div by 8 || $smarty.section.c.last}</tr>{/if}
				{/section}
			</table>
		</div>
	<div>
	</div>
	</form>
</div>
</div>
	<div align="left">		
{*		<a class="admin_button" name="back" onclick="javascript: document.location.href='{$file_name}?sel=games_list&id_category={$id_category}'">{$lang.button.back}<span>&nbsp;</span></a>&nbsp;&nbsp;&nbsp;*}
		<a class="admin_button_major" name="send" onclick="document.add_game.submit();">{$lang.button.save}<span>&nbsp;</span></a>
	</div>
<script language="JavaScript" type="text/javascript">
{literal}
$(document).ready(function() {		
	$('#upload').click(function () {
		$("#icon_list").hide();
		$("#icon").removeAttr("disabled");
		$("#def_icon").show();
		$("#set_icon").hide();
	});
	$('#select').click(function () {
		$("#icon_list").show();
		$("#icon").attr("disabled","disabled");
	});
	$('#arhiv').click(function () {
		if($('#arhiv').is(':checked')) {
			$("#code").attr("disabled","disabled");
			$("#import").removeAttr("disabled");
		} else {
			$("#code").removeAttr("disabled");
			$("#import").attr("disabled","disabled");
		}
		
	});
});
function SetIcon(par,path){
	$("#file_path").val(par);
	$("#set_icon").html("<img src="+path+" height=\"100\" width=\"100\" style=\"border: 1px solid #cccccc;\">");
	$("#def_icon").hide();
	$("#set_icon").show();
}

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