{include file="$admingentemplates/admin_top.tpl"}
<div class="back">
    <a href="{$site_url}{$site_root}/admin/admin_events.php">{$lang.button.back}</a>
</div>
<div class="cr"></div>
<div class="show_help" style="display: none;">&nbsp;</div>
<div class="red_header">{$lang.events.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>{if $form.par eq "edit"}{$lang.admin_help.events_edit}{else}{$lang.admin_help.events_add}{/if}
    </div>
</div>
<div class="cr">&nbsp;</div>

	{if $form.err}{else}
	{if $err}<font class="main_error_text">*{$err}</font><br><br>{/if}
<table border=0 cellspacing=0 cellpadding=0 width="100%" style="margin-bottom: 10px">
	<tr>
		<td>
                <form method="POST" action="{$form.action}" name="eventform" enctype="multipart/form-data">
				<div class="panel_section"><div class="panel_content"><table>
                {$form.hiddens}
                <input type="hidden" name="region_id" id="region_id">
                <input type="hidden" name="city_id" id="city_id">
				<tr>
					<td align="left" class="main_header_text" width="160px" style="padding-left:10px;">{$lang.events.event_name}<font class=main_error_text>*</font>:&nbsp;</td>
					<td class="main_content_text" align="left"><input type="text" name="name" value="{$data.name}" size=30 style="width: 195"></td>
				</tr>
				<tr>
					<td align="left" class="main_header_text" width="160px" style="padding-left:10px;">{$lang.events.type}<font class=main_error_text>*</font>:&nbsp;</td>
					<td class="main_content_text" align="left">
						<select style="width: 195px" name="type">
							<option value="0">{$lang.home_page.select_default}</option>
							{section name=s loop=$types}
							<option value="{$types[s].id}" {if $types[s].sel}selected{/if}>{$types[s].name}</option>
							{/section}
						</select>
					</td>
				</tr>
				<tr>
					<td align="left" class="main_header_text" width="160px" style="padding-left:10px;">{$lang.events.members_can_invite}:&nbsp;</td>
					<td class="main_content_text" align="left"><input type="checkbox" name="members_can_invite" value="1" {if $data.members_can_invite}checked{/if}></td>
				</tr>
				<tr>
					<td align="left" class="main_header_text" width="160px" style="padding-left:10px;">{$lang.events.members_can_post_images}:&nbsp;</td>
					<td class="main_content_text" align="left"><input type="checkbox" name="members_can_post_images" value="1" {if $data.members_can_post_images}checked{/if}></td>
				</tr>
				<tr>
					<td align="left" class="main_header_text" width="160px" style="padding-left:10px;">{$lang.events.country}<font class=main_error_text>*</font>:&nbsp;</td>
					<td class="main_content_text" align="left">
						<select style="width: 195px" name="country" onchange="SelectRegion(this.value, document.getElementById('region_div'), document.getElementById('city_div'));">
							<option value="0">{$lang.home_page.select_default}</option>
							{section name=s loop=$countries}
							<option value="{$countries[s].id}" {if $countries[s].sel}selected{/if}>{$countries[s].name}</option>
							{/section}
						</select>
					</td>
				</tr>
				<tr>
					<td align="left" class="main_header_text" width="160px" style="padding-left:10px;">{$lang.events.region}<font class=main_error_text>*</font>:&nbsp;</td>
					<td class="main_content_text" align="left">
						<div id="region_div">
						<select style="width: 195px" name="region" id="region" onchange="SelectCity(this.value, document.getElementById('city_div'));">
							<option value="0">{$lang.home_page.select_default}</option>
							{section name=s loop=$regions}
							<option value="{$regions[s].id}" {if $regions[s].sel}selected{/if}>{$regions[s].name}</option>
							{/section}
						</select>
						</div>
					</td>
				</tr>
				<tr>
					<td align="left" class="main_header_text" width="160px" style="padding-left:10px;">{$lang.events.city}<font class=main_error_text>*</font>:&nbsp;</td>
					<td class="main_content_text" align="left">
						<div id="city_div">
						<select style="width: 195px" name="city" id="city">
							<option value="0">{$lang.home_page.select_default}</option>
							{section name=s loop=$cities}
							<option value="{$cities[s].id}" {if $cities[s].sel}selected{/if}>{$cities[s].name}</option>
							{/section}
						</select>
						</div>
					</td>
				</tr>
				<tr>
					<td align="left" class="main_header_text" width="160px" style="padding-left:10px;">{$lang.events.event_place}<font class=main_error_text>*</font>:&nbsp;</td>
					<td class="main_content_text" align="left"><input type="text" name="place" value="{$data.place}" size=30 style="width: 195"></td>
				</tr>				
				<tr>
					<td align="left" class="main_header_text" width="160px" style="padding-left:10px;">{$lang.events.event_date_begin}<font class=main_error_text>*</font>:&nbsp;</td>
					<td class="main_content_text" align="left">
                        <select name="s_day" >
						{section name=d loop=$s_day}
							<option value="{$s_day[d].value}" {if $s_day[d].sel}selected{/if}>{$s_day[d].value}</option>
						{/section}
						</select>&nbsp;
                        <select name="s_month" >
						{section name=m loop=$s_month}
							<option value="{$s_month[m].value}" {if $s_month[m].sel}selected{/if}>{$s_month[m].name}</option>
						{/section}
						</select>&nbsp;
                        <select name="s_year" >
						{section name=y loop=$s_year}
							<option value="{$s_year[y].value}" {if $s_year[y].sel}selected{/if}>{$s_year[y].value}</option>
						{/section}
						</select>&nbsp;
						<select name="s_hour" >
						{section name=h loop=$s_hour}
							<option value="{$s_hour[h].value}" {if $s_hour[h].sel}selected{/if}>{$s_hour[h].value}</option>
						{/section}
						</select>&nbsp;
						<select name="s_min" >
						{section name=i loop=$s_min}
							<option value="{$s_min[i].value}" {if $s_min[i].sel}selected{/if}>{$s_min[i].value}</option>
						{/section}
						</select>
					</td>
				</tr>
				<tr>
					<td align="left" class="main_header_text" width="160px" style="padding-left:10px;">{$lang.events.event_date_end}<font class=main_error_text>*</font>:&nbsp;</td>
					<td class="main_content_text" align="left">
                        <select name="f_day" >
						{section name=d loop=$f_day}
							<option value="{$f_day[d].value}" {if $f_day[d].sel}selected{/if}>{$f_day[d].value}</option>
						{/section}
						</select>&nbsp;
                        <select name="f_month" >
						{section name=m loop=$f_month}
							<option value="{$f_month[m].value}" {if $f_month[m].sel}selected{/if}>{$f_month[m].name}</option>
						{/section}
						</select>&nbsp;
                        <select name="f_year" >
						{section name=y loop=$f_year}
							<option value="{$f_year[y].value}" {if $f_year[y].sel}selected{/if}>{$f_year[y].value}</option>
						{/section}
						</select>&nbsp;
						<select name="f_hour" >
						{section name=h loop=$f_hour}
							<option value="{$f_hour[h].value}" {if $f_hour[h].sel}selected{/if}>{$f_hour[h].value}</option>
						{/section}
						</select>&nbsp;
						<select name="f_min" >
						{section name=i loop=$f_min}
							<option value="{$f_min[i].value}" {if $f_min[i].sel}selected{/if}>{$f_min[i].value}</option>
						{/section}
						</select>
					</td>
				</tr>
				<tr>
					<td align="left" class="main_header_text" width="160px" style="padding-left:10px;">{$lang.events.event_periodicity}:&nbsp;</td>
					<td class="main_content_text" align="left">
						<input type="radio" name="periodicity" value="none" {if $data.periodicity == "none"}checked{/if} onclick="javascript: document.getElementById('die_date').style.display='none';"> {$lang.events.event_period.none}
						<input type="radio" name="periodicity" value="daily" {if $data.periodicity == "daily"}checked{/if} onclick="javascript: document.getElementById('die_date').style.display='inline';"> {$lang.events.event_period.daily}
						<input type="radio" name="periodicity" value="weekly" {if $data.periodicity == "weekly"}checked{/if} onclick="javascript: document.getElementById('die_date').style.display='inline';"> {$lang.events.event_period.weekly}
						<input type="radio" name="periodicity" value="monthly" {if $data.periodicity == "monthly"}checked{/if} onclick="javascript: document.getElementById('die_date').style.display='inline';"> {$lang.events.event_period.monthly}
						<input type="radio" name="periodicity" value="yearly" {if $data.periodicity == "yearly"}checked{/if} onclick="javascript: document.getElementById('die_date').style.display='inline';"> {$lang.events.event_period.yearly}
						<div id="die_date" style="display:{if $data.periodicity == "none"}none{else}inline{/if}">
						&nbsp;&nbsp;&nbsp;{$lang.events.until}:&nbsp;
                        <select name="d_day" >
						<option value="0" ></option>
						{section name=d loop=$d_day}
							<option value="{$d_day[d].value}" {if $d_day[d].sel}selected{/if}>{$d_day[d].value}</option>
						{/section}
						</select>&nbsp;
                        <select name="d_month" >
						<option value="0" ></option>
						{section name=m loop=$d_month}
							<option value="{$d_month[m].value}" {if $d_month[m].sel}selected{/if}>{$d_month[m].name}</option>
						{/section}
						</select>&nbsp;
                        <select name="d_year" >
						<option value="0" ></option>
						{section name=y loop=$d_year}
							<option value="{$d_year[y].value}" {if $d_year[y].sel}selected{/if}>{$d_year[y].value}</option>
						{/section}
						</select>&nbsp;
						</div>
					</td>
				</tr>
				<tr>
					<td align="left" valign="top" class="main_header_text" width="160px" style="padding-left:10px;padding-top:5px;">{$lang.events.event_descr}:&nbsp;</td>
					<td class="main_content_text" align="left" style="padding-top:5px;padding-bottom:5px;">
						{$redactor}
						<textarea id="redactor" name="contain" class="redactor_normal">{*$data.contain*}</textarea> 
					</td>
				</tr>
				<tr>
					<td align="left" class="main_header_text" width="160px" style="padding-left:10px;">{$lang.events.flyer}:&nbsp;</td>
					<td>{if $data.flyer}<img src="{$data.flyer}"><br><br>{/if}<input type="file" name="flyer"></td>
				</tr></table></div></div><table style="float:left;" width="100%">
					<tr height="40">
					{if $form.par eq "edit"}
					<td>
						<a class="admin_button_major" onclick="javascript:document.eventform.sel.value='save';Save()">{$lang.button.save}<span>&nbsp;</span></a>
					</td>
					<td align="right">
						<a class="admin_button" onclick="{literal}javascript: if(confirm('Delete this event?')){location.href={/literal}'{$form.delete_link}'{literal}}{/literal}">{$lang.button.delete}<span>&nbsp;</span></a>
					</td>
					{else}
					<td>
						<a class="admin_button_major" onclick="javascript:document.eventform.sel.value='add';Save()">{$lang.button.add}<span>&nbsp;</span></a>
					</td>
					{/if}
{*					<td>
						<a class="admin_button" onclick="javascript:location.href='{$form.back}'">{$lang.button.back}<span>&nbsp;</span></a>
					</td>
*}					</tr>
				</table>
				</form>
				</td></tr>
    </table>     
    {/if}
    <script type="text/javascript">
{literal}
function Save() {
	$('#region_id').val($('#region').val());
	$('#city_id').val($('#city').val());
	document.eventform.submit();
}
{/literal}
</script>
{include file="$admingentemplates/admin_bottom.tpl"}