<script type="text/javascript">
var cfWrongExt = "{{$lang.cf_wrong_value}}";
$(document).ready(function(){
	$("form#banners-form").validate();
	$("form#banners-form #banner-width").rules("add", {required: true});
	$("form#banners-form #banner-height").rules("add", {required: true});
	$("form#banners-form #banner-color").rules("add", {required: true});
	$("form#banners-form #banner-view-max").rules("add", {required: true});
	$("form#banners-form #banner-clicks-max").rules("add", {required: true});
	$("form#banners-form #banner-views").rules("add", {required: true});
	$("form#banners-form #banner-clicks").rules("add", {required: true});
	$("form#banners-form #banner-type").rules("add", {required: true});
	$("form#banners-form textarea[name='sText']").rules('add', {maxbytes: 65535});
	{{if !$aBanner.sFile}}
		$("form#banners-form #banner-file").rules("add", {required: true});
	{{/if}}
});
</script>
<h1>{{$lang.Banner_form}}</h1>
<form action="?p={{$_GET.p}}" id="banners-form" method="post" enctype="multipart/form-data">
	<fieldset>
		<input type="hidden" name="iBanner" value="{{$aBanner.iBanner}}" />
		<div class="block50">
			<h2>&nbsp;</h2>
			<table class="details">
				{{if $aBanner.sFile}}
					<tr>
						<td colspan="3"><img src="{{$config.dir_files}}{{$aBanner.sFile}}" style="max-width: 670px;"/></td>
					</tr>
					<tr>
						<th class="name">{{$lang.File}}</th><td class="value"><a href="{{$config.dir_files}}{{$aBanner.sFile}}" target="_blank">{{$aBanner.sFile}}</a><input type="hidden" name="sFile" value="{{$aBanner.sFile}}" /></td><td class="help"></td>
					</tr>
				{{else}}
					<tr>
						<th class="name">{{$lang.File}}</th><td class="value"><input id="banner-file" type="file" name="sFile" size="30" class="finput" alt="extension;jpg|gif|jpeg|png" /></td><td class="help"></td>
					</tr>
				{{/if}}
				<tr>
					<th class="name">{{$lang.Address}}</th><td class="value"><input class="input" type="text" name="sLink" value="{{$aBanner.sLink}}" maxlength="100" size="40" /></td><td class="help"><img class="tTip info" src="templates/images/info.png"  title="{{$lang.help_banners_address}}" /></td>
				</tr><tr>
					<th class="name">{{$lang.Width}}</th><td class="value"><input id="banner-width" class="input" type="text" name="iWidth" value="{{$aBanner.iWidth}}" maxlength="4" size="10" />px</td><td class="help"><img class="tTip info" src="templates/images/info.png"  title="{{$lang.help_banners_width}}" /></td>
				</tr><tr>
					<th class="name">{{$lang.Height}}</th><td class="value"><input id="banner-height" class="input" type="text" name="iHeight" value="{{$aBanner.iHeight}}" maxlength="4" size="10" />px</td><td class="help"><img class="tTip info" src="templates/images/info.png"  title="{{$lang.help_banners_height}}" /></td>
				</tr><tr>
					<th class="name">{{$lang.Color}}</th><td class="value"><input id="banner-color" class="input" type="text" name="sColor" value="{{$aBanner.sColor}}" maxlength="7" size="10" /></td><td class="help"><img class="tTip info" src="templates/images/info.png"  title="{{$lang.help_banners_color}}" /></td>
				</tr><tr>
					<th class="name">{{$lang.Views_max}}</th><td class="value"><input id="banner-view-max" class="input" type="text" name="iMax" value="{{$aBanner.iMax}}" maxlength="7" size="10" /></td><td class="help"><img class="tTip info" src="templates/images/info.png"  title="{{$lang.help_banners_views_max}} 0 - {{$lang.no_limits}}" /></td>
				</tr><tr>
					<th class="name">{{$lang.Clicks_max}}</th><td class="value"><input id="banner-clicks-max" class="input" type="text" name="iMaxClicks" value="{{$aBanner.iMaxClicks}}" maxlength="7" size="10" /></td><td class="help"><img class="tTip info" src="templates/images/info.png"  title="{{$lang.help_banners_clicks_max}} 0 - {{$lang.no_limits}}" /></td>
				</tr><tr>
					<th class="name">{{$lang.Date_from}}</th><td class="value"><input id="banner-time-from" class="input datetime" type="text" name="sTimeFrom" value="{{$aBanner.sTimeFrom}}" size="10" /></td><td class="help"><img class="tTip info" src="templates/images/info.png"  title="{{$lang.help_banners_time_from}}" /></td>
				</tr><tr>
					<th class="name">{{$lang.Date_to}}</th><td class="value"><input id="banner-time-to" class="input datetime" type="text" name="sTimeTo" value="{{$aBanner.sTimeTo}}" size="10" /></td><td class="help"><img class="tTip info" src="templates/images/info.png"  title="{{$lang.help_banners_time_to}}" /></td>
				</tr><tr>
					<th class="name">{{$lang.Views}}</th><td class="value"><input id="banner-views" class="input" type="text" name="iViews" value="{{$aBanner.iViews}}" maxlength="7" size="10" /></td><td class="help"><img class="tTip info" src="templates/images/info.png"  title="{{$lang.help_banners_views}}" /></td>
				</tr><tr>
					<th class="name">{{$lang.Clicks}}</th><td class="value"><input id="banner-clicks" class="input" type="text" name="iClicks" value="{{$aBanner.iClicks}}" maxlength="7" size="10" /></td><td class="help"><img class="tTip info" src="templates/images/info.png"  title="{{$lang.help_banners_clicks}}" /></td>
				</tr><tr>
					<th class="name">{{$lang.Type}}</th>
					<td class="value">
						<select id="banner-type" name="iType">
							{{foreach from=$aBannersTypes item=sOption}}
								<option value="{{$sOption@key}}" {{if $sOption@key == $aBanner.iType}}selected="selected"{{/if}}>{{$sOption}}</option>
							{{/foreach}}
						</select>
					</td>
					<td class="help"><img class="tTip info" src="templates/images/info.png"  title="{{$lang.help_banners_type}}" /></td>
				</tr><tr>
					<th class="name">{{$lang.Position}}</th><td class="value"><input id="banner-position" class="input" type="text" name="iPosition" value="{{$aBanner.iPosition}}" maxlength="7" size="10" /></td><td class="help"><img class="tTip info" src="templates/images/info.png"  title="{{$lang.help_banners_position}}" /></td>
				</tr><tr>
					<th class="name">{{$lang.Active}}</th><td class="value"><input type="checkbox" {{if $aBanner.iStatus}}checked="checked"{{/if}} value="1" name="iStatus" /></td><td class="help"><img class="tTip info" src="templates/images/info.png"  title="{{$lang.help_banners_status}}" /></td>
				</tr><tr>
					<th class="name">{{$lang.Target_blank}}</th><td class="value"><input type="checkbox" {{if $aBanner.iTargetBlank}}checked="checked"{{/if}} value="1" name="iTargetBlank" /></td><td class="help"><img class="tTip info" src="templates/images/info.png"  title="{{$lang.help_banners_target_blank}}" /></td>
				</tr>
			</table>
		</div>
		<div class="block50">
			<h2>&nbsp;</h2>
			<table class="details">
				<tr>
					<th class="name">{{$lang.Text}}</th><td class="value">{{htmleditor sName='sText' iH='280px' iW='100%' sContent=$aBanner.sText}}</td>
				</tr>
				<tr>
					<th class="name">{{$lang.Pages}}</th>
					<td class="value">
						<table id="pages-multiselect">
							<thead>
								<tr><th class="id">{{$lang.Id}}</th><th class="name">{{$lang.Name}}</th><th class="del">{{$lang.Delete}}</th></tr>
								<tr class="item" style="display: none">
									<td class="id">%iId%</td>
									<td class="name">%sName%</td>
									<td class="del"><a class="page-delete" href="#" ><img src="{{$config.dir_templates}}admin/images/ico/delete.png" alt="{{$lang.Delete}}" title="{{$lang.Delete}}"/></a></td>
									<td class="value" style="display: none"><input type="hidden" value="%iId%" name="aPages[]" /></td>
								</tr>
							</thead>
							<tfoot>
								<tr><td></td><td colspan="3"><a href="admin.php?p=p-multiselect&amp;request_type=pages-multiselect&amp;getFull=1" class="pages-select new_element">{{$lang.Add_related_pages}}</a></td></tr>
							</tfoot>
							<tbody>
								{{foreach from=$aBanner.aPages item=iPage}}
									<tr>
										<td class="id">{{$iPage}}</td>
										<td class="name">{{$aGeneralInfo.aPagesFull[$iPage]}}</td>
										<td class="del"><a class="page-delete" href="#" ><img src="{{$config.dir_templates}}admin/images/ico/delete.png" alt="{{$lang.Delete}}" title="{{$lang.Delete}}"/></a></td>
										<td class="value" style="display: none"><input type="hidden" value="{{$iPage}}" name="aPages[]" /></td>
									</tr>
								{{/foreach}}
							</tbody>
						</table>
					</td>
				</tr>
				<tr>
					<th class="name">{{$lang.Producer}}</th>
					<td class="value">
						<table id="producers-multiselect">
							<thead>
								<tr><th class="id">{{$lang.Id}}</th><th class="name">{{$lang.Name}}</th><th class="del">{{$lang.Delete}}</th></tr>
								<tr class="item" style="display: none">
									<td class="id">%iId%</td>
									<td class="name">%sName%</td>
									<td class="del"><a class="page-delete" href="#" ><img src="{{$config.dir_templates}}admin/images/ico/delete.png" alt="{{$lang.Delete}}" title="{{$lang.Delete}}"/></a></td>
									<td class="value" style="display: none"><input type="hidden" value="%iId%" name="aProducers[]" /></td>
								</tr>
							</thead>
							<tfoot>
								<tr><td></td><td colspan="3"><a href="admin.php?p=producers-multiselect&amp;request_type=producers-multiselect&amp;getFull=1" class="producer-select new_element">{{$lang.Add_related_producer}}</a></td></tr>
							</tfoot>
							<tbody>
								{{foreach from=$aBanner.aProducers item=iProducer}}
									<tr>
										<td class="id">{{$iProducer}}</td>
										<td class="name">{{$aGeneralInfo.aProducersFull[$iProducer]}}</td>
										<td class="del"><a class="page-delete" href="#" ><img src="{{$config.dir_templates}}admin/images/ico/delete.png" alt="{{$lang.Delete}}" title="{{$lang.Delete}}"/></a></td>
										<td class="value" style="display: none"><input type="hidden" value="{{$iProducer}}" name="aProducers[]" /></td>
									</tr>
								{{/foreach}}
							</tbody>
						</table>
					</td>
				</tr>
			</table>
		</div>

		<div class="save float"><div class="save floatcontainer">
			<input type="submit" class="submit" value="&laquo; {{$lang.return}}" onclick="location.href = '?p=banners-list'; return false;"> <input type="submit" class="submit" value="{{$lang.Save}} &raquo;" name="sOption" />
		</div></div>
	</fieldset>
</form>