{include file="$gentemplates/$header_tpl"}
<h2>{$lang.banners.properties}</h2>
<p>{$lang.help}:&nbsp;{$lang.banners.help_banners_edit}</p>
<div id="banners_edit">
	<form name="edit_banner" enctype="multipart/form-data" method="post" action="{$site_root}/{$seo.banners}">
		{$form.hiddens}
		<p>
			{$lang.banners.name} <font class="error_msg">*</font>:<br />
			<input type="text" name="banner_name" id="banner_name" onkeyup="BadWords('banner_name');" size="40" value="{$one_banner.name}">
            <div id="bad_div_banner_name" class="bad_div_left"></div>
		</p>
		<p>
			{$lang.banners.type}:<br />
			<select name="edit" onchange="javascript:ChangeInputType()">
			<option value="image">{$lang.banners.type_image}  </option>
				<option value="html" {if $edit_type eq "html"}selected="selected"{/if}>{$lang.banners.type_html}  </option>
			</select>
		</p>
		{if $edit_type eq "html"}
		<p>
			{$lang.banners.place_and_size}:<br />
			<select name="place_size_select">
			 {foreach from=$posible_sizes item=one_size}
			  {$one_size}
			 {/foreach}
			 </select>
		</p>
		<p>
			{$lang.banners.html_code} <font class="error_msg">*</font>:<br />
			<textarea style="width: 100%;" name="banner_html_code" rows="15" wrap="VIRTUAL">{$one_banner.html_code}</textarea>
		</p>
		{else}
		<p>
			{$lang.banners.image_path}:<br />
			<input type="text" name="img_file_path" size="40" value="{$one_banner.short_img_file_path}">
		</p>
		<p>
			{$lang.banners.upload_image} <font class="error_msg">*</font>:<br />
			<input name="file" type="file" value="{$site_root}/uploades/banners/{$one_banner.short_img_file_path}">
		</p>
		<p>
			{$lang.banners.place_and_size}:<br />
			<select name="place_size_select">
			 {foreach from=$posible_sizes item=one_size}
			  {$one_size}
			 {/foreach}
			 </select>
		</p>
		<p>
			{$lang.banners.link_to_profile}:<br />
			<input type="radio" name="link_type" value="profile_link" {if $one_banner.link_type == 'profile_link' || $one_banner.link_type == ''}checked="checked"{/if} onclick="javascript: document.getElementById('b_url1').disabled=false; document.getElementById('b_url2').disabled=true;"/>&nbsp;
			<input type="text" name="banner_url" id="b_url1" size="40" value="{$one_banner.myprofile_link}" readonly="readonly" {if $one_banner.link_type == 'own_link'}disabled="disabled"{/if}>
		</p>
		<p>
			{$lang.banners.own_link}:<br />
			<input type="radio" name="link_type" value="own_link" {if $one_banner.link_type == 'own_link'}checked="checked"{/if} onclick="javascript: document.getElementById('b_url1').disabled=true; document.getElementById('b_url2').disabled=false;"/>&nbsp;
			<input type="text" name="banner_url" id="b_url2" size="40" value="{$one_banner.banner_url}" {if $one_banner.link_type == 'profile_link' || $one_banner.link_type==''}disabled=true{/if}>
		</p>
		{/if}
		<p>
			<input type="button" value="{$lang.button.save}" onclick="SubmitMyForm();">
			<input type="button" value="{$lang.banners.back_to_list}" onclick="javascript:document.location='{$site_root}/{$seo.banners}';">
		</p>
	</form>
</div>
<script>
{literal}
$(document).ready(function(){
	{/literal}{if $form.error ne ''}ShowAjaxError('','{$form.error}');{/if}{literal}
});
function CheckForm()
{
	if (document.getElementsByName('banner_name').value == '')
     {
      {/literal}
      alert('{$lang.banners.enter_name|escape:javascript}.');
      {literal}
      return 0;
     }
  return 1;
}
function SubmitMyForm()
{
  if (CheckForm()==1)
     {
       document.forms['edit_banner'].submit();
     }
}

function ChangeInputType()
{
{/literal}
  {if $is_add_mode eq "1"}
{literal}
  document.forms['edit_banner'].sel.value="add";
  document.forms['edit_banner'].submit();
{/literal}
  {else}
{literal}
  document.forms['edit_banner'].sel.value="edit";
  document.forms['edit_banner'].submit();
{/literal}
  {/if}
{literal}
}

{/literal}
</script>
{include file="$gentemplates/$footer_tpl"}