{{**************************************************************** PRZED USUNIĘCIEM ENTERÓW *******************************************************
{{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}}

{{function name="selectPageOptions" aOptions=0 mOption=0 sPrefix="" iSkip=0}}
	{{foreach from=$aOptions item=aOption}}
		{{if $iSkip !== true && $aOption.iPage != $iSkip}}
			{{if isset( $aOption.iPage ) && $aOption.iPage !== 0}}
				<option value="{{$aOption.iPage}}"{{if ( is_array( $mOption ) && in_array( $aOption.iPage, $mOption ) ) || ( $aOption.iPage == $mOption )}} selected="selected"{{/if}}>{{$sPrefix}}{{$aOption.sName|escape}}</option>
			{{/if}}
			{{if isset( $aOption.aChildren )}}
				{{selectPageOptions aOptions=$aOption.aChildren mOption=$mOption sPrefix="`$sPrefix`&nbsp;&nbsp;" iSkip=$iSkip}}
			{{/if}}
		{{else}}
			{{if isset( $aOption.iPage ) && $aOption.iPage !== 0}}
				<option value="{{$aOption.iPage}}" disabled="disabled">{{$sPrefix}}{{$aOption.sName|escape}}</option>
			{{/if}}
			{{if isset( $aOption.aChildren )}}
				{{selectPageOptions aOptions=$aOption.aChildren mOption=$mOption sPrefix="`$sPrefix`&nbsp;&nbsp;" iSkip=true}}
			{{/if}}
		{{/if}}
	{{/foreach}}
{{/function}}
**************************************************************** PRZED USUNIĘCIEM ENTERÓW *******************************************************}}

{{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}}

{{function name="selectPageOptions" aOptions=0 mOption=0 sPrefix="" iSkip=0}}{{foreach from=$aOptions item=aOption}}{{if $iSkip !== true && $aOption.iPage != $iSkip}}{{if isset( $aOption.iPage ) && $aOption.iPage !== 0}}<option value="{{$aOption.iPage}}"{{if ( is_array( $mOption ) && in_array( $aOption.iPage, $mOption ) ) || ( $aOption.iPage == $mOption )}} selected="selected"{{/if}}>{{$sPrefix}}{{$aOption.sName|escape}}</option>{{/if}}{{if isset( $aOption.aChildren )}}{{selectPageOptions aOptions=$aOption.aChildren mOption=$mOption sPrefix="`$sPrefix`&nbsp;&nbsp;" iSkip=$iSkip}}{{/if}}{{else}}{{if isset( $aOption.iPage ) && $aOption.iPage !== 0}}<option value="{{$aOption.iPage}}" disabled="disabled">{{$sPrefix}}{{$aOption.sName|escape}}</option>{{/if}}{{if isset( $aOption.aChildren )}}{{selectPageOptions aOptions=$aOption.aChildren mOption=$mOption sPrefix="`$sPrefix`&nbsp;&nbsp;" iSkip=true}}{{/if}}{{/if}}{{/foreach}}{{/function}}

<script type="text/javascript">
var tags = {{$json_tags}};

$(document).ready(function(){
	$("form#pages-form").validate();
	$("form#pages-form #page-name").rules("add", {required: true});
	$("form#pages-form textarea[name='sDescriptionShort']").rules('add', {maxbytes: 65535});
	
	/* Obsługa page layout */
	$('#page-layout').sortable({
		stop: function(event, ui){
			$('input.currentposition').each(function(idx){
				$(this).val(idx);
			});
			if( ui && ui != -1 ){
				var moved = ui.item.prop('id');
				var previous = ui.item.prev();
				var TinyMCEId = $('#text_'+moved+' textarea').prop('id');
				tinymce.EditorManager.execCommand('mceRemoveEditor',true, TinyMCEId);
				if( previous.length > 0 ){
					$('#text_'+previous.prop('id')).after($('#text_'+moved));
				} else{
					$('#text_'+moved).detach().prependTo('#page-description');
				}
				tinymce.EditorManager.execCommand('mceAddEditor',true, TinyMCEId);
			}
			$('#theme-selection').remove();
		},
		cancel: 'a, input, select, textarea'
	});
	$('#page-layout').on('click', '.delete-block', function(e){
		e.preventDefault();
		var block = $(this).closest('div.block');
		var id = block.prop( 'id' );
		var TinyMCEEditorId = $( '#text_' + id + ' textarea').prop('id');
		if( tinyMCE.get(TinyMCEEditorId).getContent().length > 0 ){
			alert('Nie można usunąć boksu zawierającego treść.');
		} else{
			block.remove();
			$('#text_'+id).remove();
		}
		$('#theme-selection').remove();
	});
	$('#page-layout').on('change', '.widthtype', function(){
		$(this).closest('div.block').removeClass('block50 block100').addClass('block'+$(this).val());
	});
	$('#page-layout').on('change', '.title', function(){
		var block = $(this).closest('div.block');
		var id = block.prop( 'id' );
		$( '#text_' + id + ' > label > span').html($(this).val());
	});
	$('#page-layout').on('change', '.blocktype', function(){
		var block = $(this).closest('div.block');
		block.removeClass('TEXT FORM FORUM COMMENTS FILTER ADVSEARCHER GALLERY SUBPAGES EXT_SUBPAGES SITEMAP POLL PRODUCTS FILES VIDEO AUDIO HL BOX BANNER');
		block.addClass($(this).val());
		var id = block.prop( 'id' );
		block.find('label.hide').hide().find('input, select, textarea').prop('disabled', true);
		block.find('label.'+$(this).val()).show().find('input, select, textarea').prop('disabled', false);
		if( $(this).val() == 'TEXT' ){
			$( '#text_' + id ).show();
		} else{
			$( '#text_' + id ).hide();
		}
	});
	$('#page-layout .widthtype').trigger('change');
	$('#page-layout .blocktype').trigger('change');
	$('#page-layout .title').trigger('change');

	{{if !isset( $aPage.iPage )}}
		var iNewBlock = {{count( $aPage.aBlocks ) + 1}};
	{{else}}
		var iNewBlock = 1;
	{{/if}}

	$('#new_block').click(function(e){
		e.preventDefault();
		$(this).before('<div class="block" id="newblock_'+iNewBlock+'"><a class="delete-block" href="#">X</a><input type="hidden" class="currentposition" name="aNewBlocks['+iNewBlock+'][iPosition]" value="0" /><label><input type="hidden" name="aNewBlocks['+iNewBlock+'][iStatus]" value="0" /><input type="checkbox" name="aNewBlocks['+iNewBlock+'][iStatus]" value="1" checked="checked" /> {{$lang.Status}}</label><label>{{$lang.Name}} <input type="text" name="aNewBlocks['+iNewBlock+'][sTitle]" value="" class="title" /></label> <label>{{$lang.Type}} <select class="blocktype" name="aNewBlocks['+iNewBlock+'][sType]">{{foreach from=['TEXT' => $lang.Page_Block_TEXT, 'FORM' => $lang.Page_Block_FORM, 'FORUM' => $lang.Page_Block_FORUM, 'COMMENTS' => $lang.Page_Block_COMMENTS, 'FILTER' => $lang.Page_Block_FILTER, 'ADVSEARCHER' => $lang.Page_Block_ADVSEARCHER, 'GALLERY' => $lang.Page_Block_GALLERY, 'SUBPAGES' => $lang.Page_Block_SUBPAGES, 'EXT_SUBPAGES' => $lang.Page_Block_EXT_SUBPAGES, 'SITEMAP' => $lang.Page_Block_SITEMAP, 'POLL' => $lang.Page_Block_POLL, 'PRODUCTS' => $lang.Page_Block_PRODUCTS, 'FILES' => $lang.Page_Block_FILES, 'VIDEO' => $lang.Page_Block_VIDEO, 'AUDIO' => $lang.Page_Block_AUDIO, 'HL' => $lang.Page_Block_HL, 'BOX' => $lang.Page_Block_BOX, 'BANNER' => $lang.Page_Block_BANNER] item=sType}}<option value="{{$sType@key}}">{{$sType}}</option>{{/foreach}}</select></label><label> {{$lang.Width}} <select class="widthtype" name="aNewBlocks['+iNewBlock+'][iWidthType]"> {{foreach from=['100' => '100%', '50' => '50%'] item=sType}} <option value="{{$sType@key}}">{{$sType}}</option> {{/foreach}} </select> </label> <hr/> <label class="hide TEXT"> {{$lang.Column_width}} <input type="text" name="aNewBlocks['+iNewBlock+'][iColumnWidth]" /> </label> <label class="hide FORM"> {{$lang.Form}} <select name="aNewBlocks['+iNewBlock+'][iForm]"> {{selectOptions aOptions=$aGeneralInfo.aForms}} </select> </label> <label class="hide GALLERY">{{$lang.Min_size}} <select name="aNewBlocks['+iNewBlock+'][iMinSize]">{{selectOptions aOptions=$config.pages_images_sizes}}</select></label> <label class="hide GALLERY SUBPAGES EXT_SUBPAGES PRODUCTS FILES VIDEO AUDIO BANNER"> {{$lang.Position_min}} <input type="text" name="aNewBlocks['+iNewBlock+'][iPositionMin]"/> </label> <label class="hide GALLERY SUBPAGES EXT_SUBPAGES PRODUCTS FILES VIDEO AUDIO BANNER"> {{$lang.Position_max}} <input type="text" name="aNewBlocks['+iNewBlock+'][iPositionMax]" /> </label> <label class="hide GALLERY FILES VIDEO AUDIO">{{$lang.Page_block_Files_sort_order}}<select name="aNewBlocks['+iNewBlock+'][sSortFiles]">{{selectOptions aOptions=['FILENAME_ASC'=>$lang.Page_block_Files_sort_order_filename_asc,'FILENAME_DESC'=>$lang.Page_block_Files_sort_order_filename_desc,'TITLE_ASC'=>$lang.Page_block_Files_sort_order_title_asc,'TITLE_DESC'=>$lang.Page_block_Files_sort_order_title_desc] mOption=$aBlock.sSortFiles}}</select></label> <label class="hide EXT_SUBPAGES HL"> {{$lang.Additional_page}} <select name="aNewBlocks['+iNewBlock+'][iAdditionalPage]"> {{selectPageOptions aOptions=$aGeneralInfo.aPages}} </select> </label> <label class="hide GALLERY SUBPAGES EXT_SUBPAGES PRODUCTS HL"> {{$lang.Quantity}} <input type="text" name="aNewBlocks['+iNewBlock+'][iCount]"/> </label> <label class="hide SUBPAGES EXT_SUBPAGES"><input type="hidden" name="aNewBlocks['+iNewBlock+'][iSubpagesShow][1]" value="0" /><input type="checkbox" name="aNewBlocks['+iNewBlock+'][iSubpagesShow][1]" value="1" /> {{$lang.Page_block_Subpages_show_date}}</label> <label class="hide SUBPAGES EXT_SUBPAGES"><input type="hidden" name="aNewBlocks['+iNewBlock+'][iSubpagesShow][2]" value="0" /><input type="checkbox" name="aNewBlocks['+iNewBlock+'][iSubpagesShow][2]" value="1" /> {{$lang.Page_block_Subpages_show_desc}}</label> <label class="hide SUBPAGES EXT_SUBPAGES"><input type="hidden" name="aNewBlocks['+iNewBlock+'][iSubpagesShow][4]" value="0" /><input type="checkbox" name="aNewBlocks['+iNewBlock+'][iSubpagesShow][4]" value="1" /> {{$lang.Page_block_Subpages_show_min}}</label> <label class="hide SUBPAGES EXT_SUBPAGES"><input type="radio" name="aNewBlocks['+iNewBlock+'][iSubpagesShow][8]" value="0" /> {{$lang.Page_block_Subpages_sort_alfa}}</label> <label class="hide SUBPAGES EXT_SUBPAGES"><input type="radio" name="aNewBlocks['+iNewBlock+'][iSubpagesShow][8]" value="1" /> {{$lang.Page_block_Subpages_sort_date}}</label> <label class="hide SUBPAGES EXT_SUBPAGES"><input type="radio" name="aNewBlocks['+iNewBlock+'][iSubpagesShow][16]" value="0" /> {{$lang.Page_block_Subpages_sort_asc}}</label> <label class="hide SUBPAGES EXT_SUBPAGES"><input type="radio" name="aNewBlocks['+iNewBlock+'][iSubpagesShow][16]" value="1" /> {{$lang.Page_block_Subpages_sort_desc}}</label> <label class="hide SUBPAGES EXT_SUBPAGES">{{$lang.Page_block_Subpages_columns}} <select name="aNewBlocks['+iNewBlock+'][iSubpagesShow][32]">{{selectOptions aOptions=[1=>1, 2=>2, 3=>3]}}</select></label> <label class="hide POLL"> {{$lang.Poll}} <select name="aNewBlocks['+iNewBlock+'][iPoll]"> {{selectOptions aOptions=$aGeneralInfo.aPolls}} </select> </label> <label class="hide PRODUCTS HL"> {{$lang.Products_display}} <select name="aNewBlocks['+iNewBlock+'][sProductsShow]"> {{selectOptions aOptions=['BOXES' => $lang.Products_show_boxes, 'LIST' => $lang.Products_show_list, 'LIGHTBOXES' => $lang.Products_show_lightboxes, 'TABLE' => $lang.Products_show_table, 'LIGHTLIST' => $lang.Products_show_lightlist, 'LIGHTLIST_PHOTO' => $lang.Products_show_lightlistphoto]}} </select> </label> <label class="hide HL"> {{$lang.Highlight_function}} <select name="aNewBlocks['+iNewBlock+'][sHlFunction]"> {{selectOptions aOptions=$aGeneralInfo.aHlFunctions}} </select> </label> <label class="hide BOX"> {{$lang.Box}} <select name="aNewBlocks['+iNewBlock+'][iBox]"> {{selectOptions aOptions=$aGeneralInfo.aBoxes}} </select> </label><label>{{$lang.Admin_comment}} <input type="text" name="aNewBlocks['+iNewBlock+'][sComment]" /></label></div>' );
		$('#short_description_container').before('<div class="block50" id="text_newblock_'+iNewBlock+'"><label class="hide TEXT">{{$lang.Text}} <span></span> <textarea name="aNewBlocks['+iNewBlock+'][sText]" id="anewblocks-'+iNewBlock+'-stext-" rows="20" cols="100" style="width:100%;height:280px;" tabindex="1"></textarea></label></div>');
		
		tinymce.init({
			language : 'pl',
			selector : 'textarea#anewblocks-'+iNewBlock+'-stext-',
			script_url : 'plugins/tinymce_jq/tinymce.min.js',
			plugins : "anchor,charmap,hr,image,link,emoticons,code,textcolor,table,visualchars,visualblocks,nonbreaking",
			image_advtab: true,
			tools : "inserttable",
			toolbar : [ "undo redo | styleselect fontselect fontsizeselect | bold italic forecolor backcolor", "alignleft aligncenter alignright alignjustify | bullist numlist outdent indent | link image | visualchars visualblocks nonbreaking" ],
			link_list : "admin.php?p=files-list_links&iPage={{$aPage.iPage}}",
			image_list : "admin.php?p=files-list_images&iPage={{$aPage.iPage}}",
			convert_urls: false
		});
		$('#newblock_'+iNewBlock+' select.blocktype').trigger('change');
		$('#page-layout').sortable('option','stop')();
		iNewBlock = iNewBlock + 1;
	});
	/***********************/
	
	$('#theme-selection select').change(function(){
		window.location = 'admin.php?p=p-form&iTemplate=' + $(this).val();
	});
	$('.tab input, .tab select, .tab textarea').change(function(){
		$('#theme-selection').remove();
	});
	
	{{if isset( $smarty.get.activeTabId )}}$('ul.tab-headers li a[href="#{{$smarty.get.activeTabId}}"]').trigger('click');{{/if}}
	
	var zbozicz_categories = '';
	$('#zbozicz-add').click(function(){
		if( zbozicz_categories == '' ){
			$.ajaxSetup({async: false});
			$.get( 'admin.php?p=p-zbozicz_categories', null, function(data){
				if( data.length > 0 ){
					zbozicz_categories = data;
				} else{
					alert( 'Error while fetching categories' );
				}
			});
			$.ajaxSetup({async: true});
		}
		
		var selecthtml = '<ul class="zbozicz-categories">';
		function parseObject( key, category ){
			selecthtml = selecthtml + '<li><a class="';
			if( category.id )
				selecthtml = selecthtml + 'final" data="'+category.categoryText;
			else
				selecthtml = selecthtml + 'extend';
			selecthtml = selecthtml + '">' + category.name + '</a>';
			if( category.children && category.children.length > 0 ){
				selecthtml = selecthtml + '<ul style="display: none">';
				$.each( category.children, parseObject );
				selecthtml = selecthtml + '</ul>';
			}
			selecthtml = selecthtml + '</li>';
		}
		
		$.each( zbozicz_categories, parseObject );
		selecthtml = selecthtml + '</ul>';
		
		$.colorbox({
			width: '100%',
			height: '100%',
			html: selecthtml,
			onComplete: function(){
				$('a.extend').click( function(e){
					e.preventDefault();
					$(this).next('ul').toggle();
				});
				$('a.final').click( function(e){
					e.preventDefault();
					$('#zbozicz-add').after( '<label><input type="checkbox" name="zboziczCategories[]" value="' + $(this).attr('data') + '" checked="checked" /> ' + $(this).attr('data') + '</label>' );
					$.colorbox.close();
				});
			}
		});
	});
});
</script>
<form action="?p={{$_GET.p}}&amp;iPage={{$aPage.iPage}}" name="form" enctype="multipart/form-data" method="post" id="pages-form" >
	<fieldset class="tabbed">
		<input type="hidden" name="iPage" value="{{$aPage.iPage}}" />
		<div class="clear"></div>

		<ul class="tab-headers">
			<li><a href="#page-basic">{{$lang.Name}}</a></li>
			<li><a href="#page-description">{{$lang.Description}}</a></li>
			<li><a href="#page-files">{{$lang.Files_and_images}}</a></li>
			<li><a href="#page-seo">{{$lang.SEO}}</a></li>
			<li><a href="#page-layout">{{$lang.Layout}}</a></li>
		</ul>

		{{if empty( $aPage.iPage )}}
			<label id="theme-selection" style="margin: 10px 0; display: block;">{{$lang.Template}}
				<select name="iTemplate">{{selectPageOptions aOptions=$aGeneralInfo.aTemplates mOption=$aPage.iTemplate}}</select>
			</label>
		{{/if}}
		
		<h1>{{if isset( $aPage.iPage )}}<a href="{{$aPage.sLinkName}}" target="_blank"><img src="{{$config.dir_templates}}admin/images/ico/view.png" alt="{{$lang.Preview}}" title="{{$lang.Preview}}"></a>{{/if}} {{$lang.Pages_form}} - <span class="autochange">{{$aPage.sName}}</span></h1>

		<div class="tab" id="page-basic">
			<div class="block50">
				<h2>{{$lang.Options}}</h2>
				<table class="details">
					<tr>
						<th class="name"><label>{{$lang.Name}}</label></th>
						<td class="value"><input type="text" name="sName" value="{{$aPage.sName}}" class="input" id="page-name" /></td>
						<td class="help"><img class="tTip info" src="templates/images/info.png"  title="{{$lang.help_page_name}}" /></td>
					</tr><tr>
						<th class="name"><label>{{$lang.Display_title}}</label></th>
						<td class="value"><input type="text" name="sDisplayTitle" value="{{$aPage.sDisplayTitle}}" class="input" /></td>
						<td class="help"><img class="tTip info" src="templates/images/info.png"  title="{{$lang.help_page_display_title}}" /></td>
					</tr><tr>
						<th class="name"><label>{{$lang.More_link}}</label></th>
						<td class="value"><input type="text" name="sMoreLink" value="{{$aPage.sMoreLink}}" class="input" /></td>
						<td class="help"><img class="tTip info" src="templates/images/info.png"  title="{{$lang.help_page_more_link}}" /></td>
					</tr><tr>
						<th class="name"><label>{{$lang.Page_id}}</label></th><td class="value">{{$aPage.iPage}}</td><td class="help"><img class="tTip info" src="templates/images/info.png"  title="{{$lang.help_page_id}}" /></td>
					</tr><tr>
						<th class="name"><label>{{$lang.Menu_subpages}}</label></th><td class="value"><input type="hidden" name="iMenuSubpages" value="0" /><input type="checkbox" name="iMenuSubpages" value="1" {{if $aPage.iMenuSubpages}}checked="checked"{{/if}} /></td><td class="help"></td>
					</tr><tr>
						<th class="name">{{$lang.Position}}</th><td class="value"><input type="text" name="iPosition" value="{{$aPage.iPosition}}"  size="3" maxlength="3" /></td><td class="help"><img class="tTip info" src="templates/images/info.png"  title="{{$lang.help_page_position}}" /></td>
					</tr><tr>
						<th class="name">{{$lang.Enabled}}</th><td class="value"><input type="checkbox" name="iStatus" {{if $aPage.iStatus}}checked="checked"{{/if}} value="1" /></td>
						<td class="help"><img class="tTip info" src="templates/images/info.png"  title="{{$lang.help_page_active}}" /></td>
					</tr><tr>
						<th class="name">{{$lang.Parent_page}}</th><td class="value">
							<select name="iPageParent" id="oPageParent"  class="select" style="width: 70%">
								<option value="">{{$lang.none}}</option>
								{{selectPageOptions aOptions=$aGeneralInfo.aPages mOption=$aPage.iPageParent iSkip=$aPage.iPage}}
							</select>
							[id: <input type="text" id="parentpage_overwrite" value="{{$aPage.iPageParent}}" style="width: 15%" />]
						</td>
						<td class="help"><img class="tTip info" src="templates/images/info.png"  title="{{$lang.help_page_parent}}" /></td>
					</tr><tr>
						<th class="name">{{$lang.Menu}}</th><td class="value"><select name="iType" class="select">{{selectOptions aOptions=$aGeneralInfo.aMenuTypes mOption=$aPage.iType}}</select></td>
						<td class="help"><img class="tTip info" src="templates/images/info.png"  title="{{$lang.help_page_menu}}" /></td>
					</tr><tr>
						<th class="name">{{$lang.Date}}</th><td class="value"><input class="datetime" type="text" name="sDate" value="{{$aPage.sDate}}" size="20" maxlength="20" class="input" /></td><td class="help"></td>
					</tr><tr>
						<th class="name">{{$lang.Author}}</th><td class="value"><select name="iAdmin" class="select"><option value="">{{$lang.none}}</option>{{selectOptions aOptions=$aGeneralInfo.aAdmins mOption=$aPage.iAdmin}}</select></td><td class="help"></td>
					</tr>
				</table>
			</div>
			<div class="block50">
				<h2>&nbsp;</h2>
				<table class="details">
					<tr>
						<th class="name">{{$lang.Margin}}</th><td class="value"><input type="text" name="sMargin" value="{{$aPage.sMargin}}" class="input" /></td>
						<td class="help"><img class="tTip info" src="templates/images/info.png"  title="{{$lang.help_page_margin}}" /></td>
					</tr><tr>
						<th class="name">{{$lang.Update_all_margins_page}}</th><td class="value"><input name="bUpdateMargins" value="1" type="checkbox" /></td><td class="help"><img class="tTip info" src="templates/images/info.png"  title="{{$lang.help_page_update_all_margins_page}}" /></td>
					</tr><tr>
						<th class="name">{{$lang.Page_authorized}}</th><td class="value"><input type="checkbox" name="iAuthorized" {{if $aPage.iAuthorized}}checked="checked"{{/if}} value="1" id="iAuthorized" /></td><td class="help"></td>
					</tr>
					<tr class="authorized">
						<th class="name">{{$lang.Client_groups_allowed}}</th>
						<td class="value">
							{{foreach from=$aGeneralInfo.aGroups item=sGroup}}
								<label><input type="checkbox" name="aGroups[]" value="{{$sGroup@key}}" {{if in_array( $sGroup@key, $aPage.aGroups )}}checked="checked"{{/if}} /> {{$sGroup}}</label><br/>
							{{/foreach}}
						</td>
						<td class="help"></td>
					</tr>
					<tr>
						<th class="name">{{$lang.Rss}}</th><td class="value"><input type="checkbox" name="iRss" {{if $aPage.iRss}}checked="checked"{{/if}} value="1" /></td>
						<td class="help"><img class="tTip info" src="templates/images/info.png"  title="{{$lang.help_page_rss}}" /></td>
					</tr>
					<tr><th class="name">{{$lang.Column_visible}}</th><td class="value"><input type="hidden" name="iColumn" value="0" /><input type="checkbox" name="iColumn" {{if $aPage.iColumn}}checked="checked"{{/if}} value="1" /></td><td class="help"></td></tr>
					<tr><th class="name">{{$lang.Banner_top_visible}}</th><td class="value"><input type="hidden" name="iBannerTop" value="0" /><input type="checkbox" name="iBannerTop" {{if $aPage.iBannerTop}}checked="checked"{{/if}} value="1" /></td><td class="help"></td></tr>
					<tr><th class="name">{{$lang.Banner_bottom_visible}}</th><td class="value"><input type="hidden" name="iBannerBottom" value="0" /><input type="checkbox" name="iBannerBottom" {{if $aPage.iBannerBottom}}checked="checked"{{/if}} value="1" /></td><td class="help"></td></tr>
					<tr>
						<th class="name">{{$lang.Address}} </th><td class="value"><input type="text" name="sUrl" value="{{$aPage.sUrl}}" maxlength="150" class="input" /></td><td class="help"><img class="tTip info" src="templates/images/info.png"  title="{{$lang.help_page_url}}" /></td>
					</tr>
					<tr>
						<th class="name">Zbozi.cz category</th>
						<td class="value zbozicz_category">
							<a id="zbozicz-add">{{$lang.Add}}</a>
							{{foreach from=$aPage.aZboziCategories item=sCategory}}
								<label><input type="checkbox" name="zboziczCategories[]" value="{{$sCategory}}" checked="checked" />{{$sCategory}}</label>
							{{/foreach}}
						</td>
						<td class="help"></td>
					</tr>
				</table>
			</div>
		</div>

		<div class="tab" id="page-layout">
			{{foreach from=$aPage.aBlocks item=aBlock}}
				{{if !isset( $aPage.iPage )}}
					{{$sBlockName = 'aNewBlocks['|cat:$aBlock@iteration|cat:']'}}
				{{else}}
					{{$sBlockName = 'aBlocks['|cat:$aBlock.iElement|cat:']'}}
				{{/if}}
				<div class="block" id="block_{{$aBlock.iElement}}">
					<a class="delete-block" href="#">X</a>
					<input type="hidden" class="currentposition" name="{{$sBlockName}}[iPosition]" value="{{$aBlock@iteration-1}}" />
					<label><input type="hidden" name="{{$sBlockName}}[iStatus]" value="0" /><input type="checkbox" name="{{$sBlockName}}[iStatus]" value="1" {{if $aBlock.iStatus}}checked="checked"{{/if}} /> {{$lang.Status}}</label>
					<label>
						{{$lang.Name}}
						<input type="text" name="{{$sBlockName}}[sTitle]" value="{{$aBlock.sTitle}}" class="title" />
					</label>
					<label>
						{{$lang.Type}}
						<select class="blocktype" name="{{$sBlockName}}[sType]">
							{{foreach from=['TEXT' => $lang.Page_Block_TEXT, 'FORM' => $lang.Page_Block_FORM, 'FORUM' => $lang.Page_Block_FORUM, 'COMMENTS' => $lang.Page_Block_COMMENTS, 'FILTER' => $lang.Page_Block_FILTER, 'ADVSEARCHER' => $lang.Page_Block_ADVSEARCHER, 'GALLERY' => $lang.Page_Block_GALLERY, 'SUBPAGES' => $lang.Page_Block_SUBPAGES, 'EXT_SUBPAGES' => $lang.Page_Block_EXT_SUBPAGES, 'SITEMAP' => $lang.Page_Block_SITEMAP, 'POLL' => $lang.Page_Block_POLL, 'PRODUCTS' => $lang.Page_Block_PRODUCTS, 'FILES' => $lang.Page_Block_FILES, 'VIDEO' => $lang.Page_Block_VIDEO, 'AUDIO' => $lang.Page_Block_AUDIO, 'HL' => $lang.Page_Block_HL, 'BOX' => $lang.Page_Block_BOX, 'BANNER' => $lang.Page_Block_BANNER] item=sType}}
								<option value="{{$sType@key}}" {{if $sType@key == $aBlock.sType}}selected="selected"{{/if}}>{{$sType}}</option>
							{{/foreach}}
						</select>
					</label>
					<label>
						{{$lang.Width}}
						<select class="widthtype" name="{{$sBlockName}}[iWidthType]">
							{{foreach from=['100' => '100%', '50' => '50%'] item=sType}}
								<option value="{{$sType@key}}" {{if $sType@key == $aBlock.iWidthType}}selected="selected"{{/if}}>{{$sType}}</option>
							{{/foreach}}
						</select>
					</label>
					<hr/>
					<label class="hide TEXT">
						{{$lang.Column_width}}
						<input type="text" name="{{$sBlockName}}[iColumnWidth]" value="{{$aBlock.iColumnWidth}}" />
					</label>
					<label class="hide FORM">
						{{$lang.Form}}
						<select name="{{$sBlockName}}[iForm]">
							{{selectOptions aOptions=$aGeneralInfo.aForms mOption=$aBlock.iForm}}
						</select>
					</label>
					<label class="hide GALLERY">
						{{$lang.Min_size}}
						<select name="{{$sBlockName}}[iMinSize]">{{selectOptions aOptions=$config.pages_images_sizes mOption=$aBlock.iMinSize}}</select>
					</label>
					<label class="hide GALLERY SUBPAGES EXT_SUBPAGES PRODUCTS FILES VIDEO AUDIO BANNER">
						{{$lang.Position_min}}
						<input type="text" name="{{$sBlockName}}[iPositionMin]" value="{{$aBlock.iPositionMin}}" />
					</label>
					<label class="hide GALLERY SUBPAGES EXT_SUBPAGES PRODUCTS FILES VIDEO AUDIO BANNER">
						{{$lang.Position_max}}
						<input type="text" name="{{$sBlockName}}[iPositionMax]" value="{{$aBlock.iPositionMax}}" />
					</label>
					<label class="hide GALLERY FILES VIDEO AUDIO">
						{{$lang.Page_block_Files_sort_order}}
						<select name="{{$sBlockName}}[sSortFiles]">
							{{selectOptions aOptions=['FILENAME_ASC'=>$lang.Page_block_Files_sort_order_filename_asc,'FILENAME_DESC'=>$lang.Page_block_Files_sort_order_filename_desc,'TITLE_ASC'=>$lang.Page_block_Files_sort_order_title_asc,'TITLE_DESC'=>$lang.Page_block_Files_sort_order_title_desc] mOption=$aBlock.sSortFiles}}
						</select>
					</label>
					<label class="hide EXT_SUBPAGES HL">
						{{$lang.Additional_page}}
						<select name="{{$sBlockName}}[iAdditionalPage]">
							{{selectPageOptions aOptions=$aGeneralInfo.aPages mOption=$aBlock.iAdditionalPage}}
						</select>
					</label>
					<label class="hide GALLERY SUBPAGES EXT_SUBPAGES PRODUCTS HL">
						{{$lang.Quantity}}
						<input type="text" name="{{$sBlockName}}[iCount]" value="{{$aBlock.iCount}}" />
					</label>
					
					{{* ****************  iSubpagesShow  **************** *}}
					<label class="hide SUBPAGES EXT_SUBPAGES">
						<input type="hidden" name="{{$sBlockName}}[iSubpagesShow][1]" value="0" />
						<input type="checkbox" name="{{$sBlockName}}[iSubpagesShow][1]" value="1" {{if $aBlock.iSubpagesShow & 1}}checked="checked"{{/if}} />
						{{$lang.Page_block_Subpages_show_date}}
					</label>
					
					<label class="hide SUBPAGES EXT_SUBPAGES">
						<input type="hidden" name="{{$sBlockName}}[iSubpagesShow][2]" value="0" />
						<input type="checkbox" name="{{$sBlockName}}[iSubpagesShow][2]" value="1" {{if $aBlock.iSubpagesShow & 2}}checked="checked"{{/if}} />
						{{$lang.Page_block_Subpages_show_desc}}
					</label>
					
					<label class="hide SUBPAGES EXT_SUBPAGES">
						<input type="hidden" name="{{$sBlockName}}[iSubpagesShow][4]" value="0" />
						<input type="checkbox" name="{{$sBlockName}}[iSubpagesShow][4]" value="1" {{if $aBlock.iSubpagesShow & 4}}checked="checked"{{/if}} />
						{{$lang.Page_block_Subpages_show_min}}
					</label>
					
					<label class="hide SUBPAGES EXT_SUBPAGES">
						<input type="radio" name="{{$sBlockName}}[iSubpagesShow][8]" value="0" {{if !( $aBlock.iSubpagesShow & 8 )}}checked="checked"{{/if}} />
						{{$lang.Page_block_Subpages_sort_alfa}}
					</label>
					<label class="hide SUBPAGES EXT_SUBPAGES">
						<input type="radio" name="{{$sBlockName}}[iSubpagesShow][8]" value="1" {{if $aBlock.iSubpagesShow & 8}}checked="checked"{{/if}} />
						{{$lang.Page_block_Subpages_sort_date}}
					</label>
					
					<label class="hide SUBPAGES EXT_SUBPAGES">
						<input type="radio" name="{{$sBlockName}}[iSubpagesShow][16]" value="0" {{if !( $aBlock.iSubpagesShow & 16 )}}checked="checked"{{/if}} />
						{{$lang.Page_block_Subpages_sort_asc}}
					</label>
					<label class="hide SUBPAGES EXT_SUBPAGES">
						<input type="radio" name="{{$sBlockName}}[iSubpagesShow][16]" value="1" {{if $aBlock.iSubpagesShow & 16}}checked="checked"{{/if}} />
						{{$lang.Page_block_Subpages_sort_desc}}
					</label>
					
					<label class="hide SUBPAGES EXT_SUBPAGES">
						{{$lang.Page_block_Subpages_columns}}
						<select name="{{$sBlockName}}[iSubpagesShow][32]">{{selectOptions aOptions=[1=>1, 2=>2, 3=>3] mOption=floor( $aBlock.iSubpagesShow / 32 ) % 4}}</select>
					</label>
					{{* **************** /iSubpagesShow  **************** *}}
					
					
					<label class="hide POLL">
						{{$lang.Poll}}
						<select name="{{$sBlockName}}[iPoll]">
							{{selectOptions aOptions=$aGeneralInfo.aPolls mOption=$aBlock.iPoll}}
						</select>
					</label>
					<label class="hide PRODUCTS HL">
						{{$lang.Products_display}}
						<select name="{{$sBlockName}}[sProductsShow]">
							{{selectOptions aOptions=['BOXES' => $lang.Products_show_boxes, 'LIST' => $lang.Products_show_list, 'LIGHTBOXES' => $lang.Products_show_lightboxes, 'TABLE' => $lang.Products_show_table, 'LIGHTLIST' => $lang.Products_show_lightlist, 'LIGHTLIST_PHOTO' => $lang.Products_show_lightlistphoto] mOption=$aBlock.sProductsShow}}
						</select>
					</label>
					<label class="hide HL">
						{{$lang.Highlight_function}}
						<select name="{{$sBlockName}}[sHlFunction]">
							{{selectOptions aOptions=$aGeneralInfo.aHlFunctions mOption=$aBlock.sHlFunction}}
						</select>
					</label>
					<label class="hide BOX">
						{{$lang.Box}}
						<select name="{{$sBlockName}}[iBox]">
							{{selectOptions aOptions=$aGeneralInfo.aBoxes mOption=$aBlock.iBox}}
						</select>
					</label>
					<label>{{$lang.Admin_comment}} <input type="text" name="{{$sBlockName}}[sComment]" value="{{$aBlock.sComment}}" /></label>
				</div>
			{{/foreach}}
			<a href="#" id="new_block">{{$lang.Add_block}}</a>
		</div>
		
		<div class="tab" id="page-description">
			{{foreach from=$aPage.aBlocks item=aBlock}}
				{{if !isset( $aPage.iPage )}}
					{{$sBlockName = 'aNewBlocks['|cat:$aBlock@iteration|cat:']'}}
				{{else}}
					{{$sBlockName = 'aBlocks['|cat:$aBlock.iElement|cat:']'}}
				{{/if}}
				<div class="block50" id="text_block_{{$aBlock.iElement}}">
					<label class="hide TEXT">
						{{$lang.Text}} <span></span>
						{{htmlEditor sName=$sBlockName|cat:'[sText]' iH='480px' iW='100%' sContent=$aBlock.sText}}
					</label>
				</div>
			{{/foreach}}
			<div class="block50" id="short_description_container">
				<h2>{{$lang.Short_description}} <img class="tTip info" src="templates/images/info.png" title="{{$lang.help_product_descriptionShort}}" /></h2>
				<div id="description-short" class="description">{{htmlEditor sName='sDescriptionShort' iH='280px' iW='100%' sContent=$aPage.sDescriptionShort}}</div>
			</div>
		</div>

		<div class="tab" id="page-files">
			{{include file='files_form_list.tpl' aFiles=$aPage.aFiles}}
		</div>

		<div class="tab" id="page-seo">
			<table class="details">
				<thead>
					<tr>
						<th colspan="3"><h2>{{$lang.SEO}}</h2></th>
					</tr>
				</thead>
				<tbody>
					<tr>
						<th class="name">{{$lang.Tags}}</th><td class="value"><input type="text" name="Tags" value="{{foreach from=$aPage.aTags item=sTag}}{{$sTag}}, {{/foreach}}" class="input" id="tagit-tags" /></td>
						<td class="help"><img class="tTip info" src="templates/images/info.png"  title="{{$lang.help_page_tags}}" /></td>
					</tr><tr>
						<th class="name">{{$lang.Page_title}}</th>
						<td class="value"><textarea name="sNameTitle">{{$aPage.sNameTitle}}</textarea><br/>{{$lang.AutoSEO}}: {{$aMetaPage.sTitle}}</td>
						<td class="help"><img class="tTip info" src="templates/images/info.png"  title="{{$lang.Page_title_description}}" /></td>
					</tr><tr>
						<th class="name">{{$lang.Meta_description}}</th>
						<td class="value"><textarea name="sMetaDescription">{{$aPage.sMetaDescription}}</textarea><br/>{{$lang.AutoSEO}}: {{$aMetaPage.sDescription}}</td>
						<td class="help"><img class="tTip info" src="templates/images/info.png"  title="{{$lang.Meta_description_description}}" /></td>
					</tr><tr>
						<th class="name">{{$lang.Key_words}}</th>
						<td class="value"><textarea name="sMetaKeywords">{{$aPage.sMetaKeywords}}</textarea><br/>{{$lang.AutoSEO}}: {{$aMetaPage.sKeywords}}</td>
						<td class="help"><img class="tTip info" src="templates/images/info.png"  title="{{$lang.Key_words_description}}" /></td>
					</tr><tr>
						<th class="name">{{$lang.Page_Topic}}</th>
						<td class="value"><textarea name="sMetaPageTopic">{{$aPage.sMetaPageTopic}}</textarea><br/>{{$lang.AutoSEO}}: {{$config.page_topic}}</td>
						<td class="help"><img class="tTip info" src="templates/images/info.png"  title="{{$lang.Page_Topic_description}}" /></td>
					</tr><tr>
						<th class="name">{{$lang.Abstract}}</th>
						<td class="value"><textarea name="sMetaAbstract">{{$aPage.sMetaAbstract}}</textarea><br/>{{$lang.AutoSEO}}: {{$config.abstract}}</td>
						<td class="help"><img class="tTip info" src="templates/images/info.png"  title="{{$lang.Abstract_description}}" /></td>
					</tr><tr>
						<th class="name">{{$lang.GoogleAdWords_conversion_label}}</th><td class="value"><input type="text" name="sConversionLabel" value="{{$aPage.sConversionLabel}}" /></td><td class="help"><img class="tTip info" src="templates/images/info.png"  title="{{$lang.help_product_ConversionLabel}}" /></td>
					</tr>
				</tbody>
			</table>
		</div>
		
		<div class="save float">
			<div class="save floatcontainer"><input type="submit" class="submit" value="{{$lang.Save}}" name="sOption" /></div>
		</div>

	</fieldset>
</form>