{{function name="selectOptions" aOptions=0 mOption=0}}
	{{foreach from=$aOptions item=sOption}}
		<option value="{{$sOption@key}}" {{if ( is_array( $mOption ) && in_array( $sOption@key, $mOption ) ) || ( isset( $mOption ) && $sOption@key == $mOption )}}selected="selected"{{/if}}>{{$sOption}}</option>
	{{/foreach}}
{{/function}}

<script type="text/javascript">
	$(document).ready(function(){
		$("form#boxes-form").validate();
		$("form#boxes-form textarea[name='sContent']").rules('add', {maxbytes: 65535});
		
		{{if isset( $smarty.get.activeTabId )}}$('ul.tab-headers li a[href="#{{$smarty.get.activeTabId}}"]').trigger('click');{{/if}}
	});
</script>
<form action="?p={{$_GET.p}}" method="post" id="boxes-form" enctype="multipart/form-data">
	<fieldset class="tabbed">
		<input type="hidden" name="iBox" value="{{$aBox.iBox}}" />
		
		<div class="clear"></div>

		<ul class="tab-headers">
			<li><a href="#box-basic">{{$lang.Description}}</a></li>
			<li><a href="#box-files">{{$lang.Files_and_images}}</a></li>
		</ul>
	
		<h1>{{$lang.Boxes_form}}</h1>
		
		<div class="tab" id="box-basic">
			<div class="block50">
				<table class="details">
					<tbody>
						<tr>
							<th class="name">{{$lang.Name}}</th><td class="value"><input id="boxes-name" type="text" name="sName" value="{{$aBox.sName}}" size="80" maxlength="50" class="input" alt="simple" /></td><td class="help"><img class="tTip info" src="templates/images/info.png"  title="{{$lang.help_boxes_name}}" /></td>
						</tr><tr>
							<th class="name">{{$lang.Active}}</th><td class="value"><input type="checkbox" name="iStatus" value="1" {{if $aBox.iStatus}}checked="checked"{{/if}} /></td><td class="help"><img class="tTip info" src="templates/images/info.png"  title="{{$lang.help_boxes_status}}" /></td>
						</tr><tr>
							<th class="name">{{$lang.Type}}</th><td class="value"><select name="iType">{{foreach from=$aBoxesDisplay item=sType}}<option value="{{$sType@key}}" {{if $aBox.iType == $sType@key}}selected="selected"{{/if}}>{{$sType}}</option>{{/foreach}}</select></td><td class="help"><img class="tTip info" src="templates/images/info.png"  title="{{$lang.help_boxes_type}}" /></td>
						</tr><tr>
							<th class="name">{{$lang.Position}}</th><td class="value"><input type="text" name="iPosition" value="{{$aBox.iPosition}}" /></td><td class="help"><img class="tTip info" src="templates/images/info.png"  title="{{$lang.help_boxes_position}}" /></td>
						</tr>
					</tbody>
				</table>
			</div>
			<div class="block50">
				<table class="details">
					<tr>
						<th>{{$lang.Content}}</th>
						<td>
							{{htmleditor sName='sContent' iH='200px' iW='100%' sContent=$aBox.sContent}}
						</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=$aBox.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>
				</table>
			</div>
		</div>
		<div class="tab" id="box-files">
			{{include file='files_form_list.tpl' aFiles=$aBox.aFiles}}
		</div>
		<div class="save float"><div class="save floatcontainer">
			<input type="submit" class="submit" value="&laquo; {{$lang.return}}" onclick="location.href = '?p=boxes-list'; return false;"> <input type="submit" class="submit" value="{{$lang.Save}} &raquo;" name="sOption" />
		</div></div>
	</fieldset>
</form>