<!-- register fields tpl -->

<!-- navigation bar -->
<div id="nav_bar">
	{rlHook name='apTplAccountFieldsNavBar'}

	{if !isset($smarty.get.action)}
		<a href="javascript:void(0)" onclick="show('search', '#action_blocks div');" class="button_bar"><span class="left"></span><span class="center_search">{$lang.search}</span><span class="right"></span></a>
	{/if}
	
	{if $aRights.$cKey.add && !$smarty.get.action}
		<a href="{$rlBaseC}action=add" class="button_bar"><span class="left"></span><span class="center_add">{$lang.add_field}</span><span class="right"></span></a>
	{/if}
	<a href="{$rlBase}index.php?controller={$smarty.get.controller}" class="button_bar"><span class="left"></span><span class="center_list">{$lang.fields_list}</span><span class="right"></span></a>
</div>
<!-- navigation bar end -->

<div id="action_blocks">

	{if !isset($smarty.get.action)}
		<!-- search -->
		<div id="search" class="hide">
			{include file='blocks'|cat:$smarty.const.RL_DS|cat:'m_block_start.tpl' block_caption=$lang.search}
			
			<form method="post" onsubmit="return false;" id="search_form" action="">
			<table class="form">
			<tr>
				<td class="name">{$lang.name}</td>
				<td class="field">
					<input type="text" id="search_name" />
				</td>
			</tr>
			
			<tr>
				<td class="name">{$lang.field_type}</td>
				<td class="field">
					<select id="search_type" style="width: 200px">
					<option value="">- {$lang.all} -</option>
					{foreach from=$l_types item='item' key='key'}
						<option value="{$key}">{$item}</option>
					{/foreach}
					</select>
				</td>
			</tr>
			
			<tr>
				<td class="name">{$lang.required_field}</td>
				<td class="field" id="search_require_td">
					<label title="{$lang.unmark}"><input id="required_uncheck" title="{$lang.unmark}" type="radio" name="search_required" value="" /> ...</label>
					<label><input type="radio" name="search_required" value="1" /> {$lang.yes}</label>
					<label><input type="radio" name="search_required" value="0" /> {$lang.no}</label>
					
					<script type="text/javascript">
					{literal}
					$('#required_uncheck').click(function(){
						$('#search_require_td input').attr('checked', false);
					});
					{/literal}
					</script>
				</td>
			</tr>
			
			<tr>
				<td class="name">{$lang.google_map}</td>
				<td class="field" id="search_gmap_td">
					<label title="{$lang.unmark}"><input id="gmap_uncheck" title="{$lang.unmark}" type="radio" value="" name="search_gmap" /> ...</label>
					<label><input type="radio" name="search_gmap" value="1" /> {$lang.yes}</label>
					<label><input type="radio" name="search_gmap" value="0" /> {$lang.no}</label>
					
					<script type="text/javascript">
					{literal}
					$('#gmap_uncheck').click(function(){
						$('#search_gmap_td input').attr('checked', false);
					});
					{/literal}
					</script>
				</td>
			</tr>
			
			{rlHook name='apTplAccountFieldsSearchFields'}
			
			<tr>
				<td class="name">{$lang.status}</td>
				<td class="field">
					<select id="search_status" style="width: 200px;">
						<option value="">- {$lang.all} -</option>
						<option value="active">{$lang.active}</option>
						<option value="approval">{$lang.approval}</option>
					</select>
				</td>
			</tr>
			
			<tr>
				<td></td>
				<td class="field">
					<input type="submit" value="{$lang.search}" id="search_button" />
					<input type="button" value="{$lang.reset}" id="reset_search_button" />
					<a class="cancel" href="javascript:void(0)" onclick="show('search')">{$lang.cancel}</a>
				</td>
			</tr>
			
			</table>
			</form>
			
			{include file='blocks'|cat:$smarty.const.RL_DS|cat:'m_block_end.tpl'}
		</div>
		
		<script type="text/javascript">
		{literal}
		
		var search = new Array();
		var cookie_filters = '';

		$(document).ready(function(){
			
			if ( readCookie('account_fields_sc') )
			{
				$('#search').show();
				cookie_filters = readCookie('account_fields_sc').split(',');

				for (var i in cookie_filters)
				{
					if ( typeof(cookie_filters[i]) == 'string' )
					{
						var item = cookie_filters[i].split('||');
						if ( item[0] != 'undefined' && item[0] != '' )
						{
							if ( item[0] == 'Required' )
							{
								$('#search input').each(function(){
									var val = item[1] == 1 ? 'yes' : 'no';
									if ( $(this).attr('name') == 'search_required' && $(this).val() == val )
									{
										$(this).attr('checked', true);
									}
								});
							}
							else if ( item[0] == 'Map' )
							{
								$('#search input').each(function(){
									var val = item[1] == 1 ? 'yes' : 'no';
									if ( $(this).attr('name') == 'search_gmap' && $(this).val() == val )
									{
										$(this).attr('checked', true);
									}
								});
							}
							else
							{
								$('#search_'+item[0].toLowerCase()).selectOptions(item[1]);
							}
						}
					}
				}
			}
			
			$('#search_form').submit(function(){
				createCookie('account_fields_pn', 0, 1);
				
				search = new Array();
				search.push( new Array('action', 'search') );
				search.push( new Array('Name', $('#search_name').val()) );
				search.push( new Array('Type', $('#search_type').val()) );
				if ( $('input[name=search_required]:checked').val() )
				{
					search.push( new Array('Required', $('input[name=search_required]:checked').val()) );
				}
				if ( $('input[name=search_gmap]:checked').val() )
				{
					search.push( new Array('Map', $('input[name=search_gmap]:checked').val()) );
				}
				
				{/literal}{rlHook name='apTplAccountFieldsSearch'}{literal}
				
				search.push( new Array('Status', $('#search_status').val()) );

				// save search criteria
				var save_search = new Array();
				for(var i in search)
				{
					if ( search[i][1] != '' )
					{
						save_search.push(search[i][0]+'||'+search[i][1]);
					}
				}
				createCookie('account_fields_sc', save_search, 1);
				
				accountFieldsGrid.filters = search;
				accountFieldsGrid.reload();
			});
			
			$('#reset_search_button').click(function(){
				eraseCookie('account_fields_sc');
				accountFieldsGrid.reset();
				
				$("#search select option[value='']").attr('selected', true);
				$("#search input.text").val('');
				$("#search input").each(function(){
					if ( $(this).attr('type') == 'radio' )
					{
						$(this).attr('checked', false);
					}
				});
			});
			
		});
		
		{/literal}
		</script>
		<!-- search end -->
	{/if}
	
</div>

{if $smarty.get.action}

	{assign var='sPost' value=$smarty.post}

	<!-- add new field -->
	{include file='blocks'|cat:$smarty.const.RL_DS|cat:'m_block_start.tpl'}
	<form action="{$rlBaseC}action={if $smarty.get.action == 'add'}add{elseif $smarty.get.action == 'edit'}edit&amp;field={$smarty.get.field}{/if}" method="post">
	<input type="hidden" name="submit" value="1" />
	{if $smarty.get.action == 'edit'}
		<input type="hidden" name="fromPost" value="1" />
	{/if}
	<table class="form">
	<tr>
		<td class="name"><span class="red">*</span>{$lang.key}</td>
		<td class="field">
			<input {if $smarty.get.action == 'edit'}readonly="readonly"{/if} class="{if $smarty.get.action == 'edit'}disabled{/if}" name="key" type="text" style="width: 150px;" value="{$sPost.key}" maxlength="30" />
		</td>
	</tr>

	<tr>
		<td class="name">
			<span class="red">*</span>{$lang.name}
		</td>
		<td class="field">
			{if $allLangs|@count > 1}
				<ul class="tabs">
					{foreach from=$allLangs item='language' name='langF'}
					<li lang="{$language.Code}" {if $smarty.foreach.langF.first}class="active"{/if}>{$language.name}</li>
					{/foreach}
				</ul>
			{/if}
			
			{foreach from=$allLangs item='language' name='langF'}
				{if $allLangs|@count > 1}<div class="tab_area{if !$smarty.foreach.langF.first} hide{/if} {$language.Code}">{/if}
				<input type="text" name="name[{$language.Code}]" value="{$sPost.name[$language.Code]}" maxlength="350" />
				{if $allLangs|@count > 1}
						<span class="field_description_noicon">{$lang.name} (<b>{$language.name}</b>)</span>
					</div>
				{/if}
			{/foreach}
		</td>
	</tr>
	
	<tr>
		<td class="name">
			{$lang.description}
		</td>
		<td class="field">
			{if $allLangs|@count > 1}
				<ul class="tabs">
					{foreach from=$allLangs item='language' name='langF'}
					<li lang="{$language.Code}" {if $smarty.foreach.langF.first}class="active"{/if}>{$language.name}</li>
					{/foreach}
				</ul>
			{/if}
			
			{foreach from=$allLangs item='language' name='langF'}
				{if $allLangs|@count > 1}<div class="tab_area{if !$smarty.foreach.langF.first} hide{/if} {$language.Code}">{/if}
				<textarea cols="" rows="" name="description[{$language.Code}]">{$sPost.description[$language.Code]}</textarea>
				{if $allLangs|@count > 1}</div>{/if}
			{/foreach}
		</td>
	</tr>
	
	<tr>
		<td class="name"><span class="red">*</span>{$lang.required_field}</td>
		<td class="field">
			{if $sPost.required == '1'}
				{assign var='required_yes' value='checked="checked"'}
			{elseif $sPost.required == '0'}
				{assign var='required_no' value='checked="checked"'}
			{else}
				{assign var='required_no' value='checked="checked"'}
			{/if}
			
			<label><input {$required_yes} type="radio" name="required" value="1" /> {$lang.yes}</label>
			<label><input {$required_no} type="radio" name="required" value="0" /> {$lang.no}</label>
		</td>
	</tr>
	
	<tr>
		<td class="name">{$lang.google_map}</td>
		<td class="field">
			{if $sPost.map == '1'}
				{assign var='map_yes' value='checked="checked"'}
			{elseif $sPost.map == '0'}
				{assign var='map_no' value='checked="checked"'}
			{else}
				{assign var='map_no' value='checked="checked"'}
			{/if}
			
			<table>
			<tr>
				<td>
					<label><input {$map_yes} type="radio" name="map" value="1" /> {$lang.yes}</label>
					<label><input {$map_no} type="radio" name="map" value="0" /> {$lang.no}</label>
				</td>
				<td>
					<span class="field_description">({$lang.use_for_displaing_map})</span>
				</td>
			</tr>
			</table>
		</td>
	</tr>

	{rlHook name='apTplAccountFieldsForm'}
	
	<tr>
		<td class="name"><span class="red">*</span>{$lang.status}</td>
		<td class="field">
			<select name="status" class="margin">
				<option value="active" {if $sPost.status == 'active'}selected="selected"{/if}>{$lang.active}</option>
				<option value="approval" {if $sPost.status == 'approval'}selected="selected"{/if}>{$lang.approval}</option>
			</select>
		</td>
	</tr>
	
	<tr>
		<td class="name"><span class="red">*</span>{$lang.field_type}</td>
		<td class="field">
			<select {if $smarty.get.action == 'edit'}disabled="disabled"{/if} onchange="field_types(this.value);" name="type" class="margin{if $smarty.get.action == 'edit'} disabled{/if}">
				<option value="">{$lang.select_field_type}</option>
				{foreach from=$l_types item='lType' key='key'}
				{if $key != 'price'}
					<option {if $sPost.type == $key}selected="selected"{/if} value="{$key}">{$lType}</option>
				{/if}
				{/foreach}
			</select>
			{if $smarty.get.action == 'edit'}
				<input type="hidden" name="type" value="{$sPost.type}" />
			{/if}
		</td>
	</tr>
	</table>
	
	<!-- additional options -->
	<div id="additional_options">

	<script type="text/javascript">
	var langs_list = Array(
	{foreach from=$allLangs item='languages' name='lF'}
	'{$languages.Code}|{$languages.name}'{if !$smarty.foreach.lF.last},{/if}
	{/foreach}
	);
	</script>
	
	<!-- text field -->
	{assign var='textDefault' value=$sPost.text.default}
	<div id="field_text" class="hide">
		<table class="form">
		{foreach from=$allLangs item='languages' name='lang_foreach'}
		{assign var='lCode' value=$languages.Code}
		<tr>
			<td class="name">
				<div style="margin-left: 10px;">{$lang.default_value} <span class="green_10">(<b>{$languages.name}</b>)</span></div>
			</td>
			<td class="field">
				<input class="margin" name="text[default][{$languages.Code}]" type="text" style="width: 250px;" value="{$textDefault.$lCode}" maxlength="100" />
			</td>
		</tr>
		{/foreach}
		
		{assign var='text_cond' value=$sPost.text}
		<tr>
			<td class="name">{$lang.check_condition}</td>
			<td class="field">
				<select name="text[condition]">
					<option value="">- {$lang.condition} -</option>
					{foreach from=$l_cond item='condition' key='cKey'}
						<option {if $text_cond.condition == $cKey}selected="selected"{/if} value="{$cKey}">{$condition}</option>
					{/foreach}
				</select>
			</td>
		</tr>
		
		<tr>
			<td class="name">{$lang.maxlength}</td>
			<td class="field">
				<table>
				<tr>
					<td><input class="margin" name="text[maxlength]" type="text" style="width: 50px; text-align: center;" value="{$sPost.text.maxlength}" maxlength="3" /></td>
					<td><span class="field_description">{$lang.default_text_value_des}</span></td>
				</tr>
				</table>
			</td>
		</tr>
		
		{rlHook name='apTplAccountFieldsFormText'}
		
		</table>
	</div>
	<!-- text field end -->
	
	<!-- textarea field -->
	{assign var='textarea' value=$sPost.textarea}
	<div id="field_textarea" class="hide">
		<table class="form">
		<tr>
			<td class="name">{$lang.maxlength}</td>
			<td class="field">
				<table>
				<tr>
					<td><input name="textarea[maxlength]" type="text" style="width: 50px; text-align: center;" value="{$textarea.maxlength}" maxlength="4" /></td>
					<td><span class="field_description">{$lang.default_textarea_value_des}</span></td>
				</tr>
				</table>
			</td>
		</tr>
		
		{rlHook name='apTplAccountFieldsFormTextarea'}
		
		</table>
	</div>
	<!-- textarea field end -->
	
	<!-- number field -->
	{assign var='number' value=$sPost.number}
	<div id="field_number" class="hide">
		<table class="form">
		<tr>
			<td class="name">{$lang.minumber}</td>
			<td class="field">
				<input name="number[min_number]" type="text" style="width: 60px; text-align: center;" value="{$number.min_number}" maxlength="8" />
			</td>
		</tr>
		<tr>
			<td class="name">{$lang.maxnumber}</td>
			<td class="field">
				<input class="margin numeric" name="number[max_number]" type="text" style="width: 60px; text-align: center;" value="{$number.max_number}" maxlength="8" />
			</td>
		</tr>
		
		{rlHook name='apTplAccountFieldsFormNumber'}
		
		</table>
	</div>
	<!-- number field end -->
	
	<!-- date field -->
	{assign var='date' value=$sPost.date}
	<div id="field_date" class="hide">
		<table class="form">
		<tr>
			<td class="name"><span class="red">*</span>{$lang.mode}</td>
			<td class="field">
				<label><input {if $date.mode == 'single'}checked="checked"{/if} type="radio" name="date[mode]" value="single" /> {$lang.single_date}</label>
				<label><input {if $date.mode == 'multi'}checked="checked"{/if} type="radio" name="date[mode]" value="multi" /> {$lang.time_period}</label>
			</td>
		</tr>
		
		{rlHook name='apTplAccountFieldsFormDate'}
		
		</table>
	</div>
	<!-- date field end -->
	
	<!-- boolean field -->
	{if $sPost.bool.default == '1'}
		{assign var='bool_default_yes' value='checked="checked"'}
	{elseif $sPost.required == '0'}
		{assign var='bool_default_no' value='checked="checked"'}
	{else}
		{assign var='bool_default_no' value='checked="checked"'}
	{/if}
	<div id="field_bool" class="hide">
		<table class="form">
		<tr>
			<td class="name">{$lang.default_value}</td>
			<td class="field">
				<label><input {$bool_default_yes} type="radio" name="bool[default]" value="1" /> {$lang.yes}</label>
				<label><input {$bool_default_no} type="radio" name="bool[default]" value="0" /> {$lang.no}</label>
			</td>
		</tr>
		
		{rlHook name='apTplAccountFieldsFormBool'}
		
		</table>
	</div>
	<!-- boolean field end -->
	
	<!-- mixed field -->
	<div id="field_mixed" class="hide">
		<script type="text/javascript">
		var mixed_step = 1;
		</script>
		<table class="form">
		
		{rlHook name='apTplAccountFieldsFormMixed'}
		
		<tr>
			<td class="name">{$lang.bind_data_format}</td>
			<td class="field">
				<select id="dd_mixed_block" name="mixed_data_format" class="data_format">
					<option value="0">{$lang.select}</option>
					{foreach from=$data_formats item='format'}
					<option value="{$format.Key}"{if $format.Key == $sPost.mixed_data_format} selected="selected"{/if}>{$format.name|strip_tags}</option>
					{/foreach}
				</select>
			</td>
		</tr>
		</table>
		
		<div id="mixed_block" {if $sPost.mixed_data_format}class="hide"{/if}>
		<table class="form">
		<tr>
			<td class="name">{$lang.field_items}</td>
			<td class="field">
				<table id="mixed">
				{if $sPost.mixed}
					{foreach from=$sPost.mixed item='selectItem' key='selectKey'}
					{if $selectKey != 'default'}
					<tr id="mixed_{$selectKey}">
						<td>
							{foreach from=$allLangs item='languages' name='lang_foreach'}
								{assign var='lCode' value=$languages.Code}
								<div><input type="text" class="margin float" value="{$selectItem.$lCode}" name="mixed[{$selectKey}][{$languages.Code}]" /><span class="field_description">{$lang.item_value} <span class="green_10">(<b>{$languages.name}</b>)</span></span></div>
							{/foreach}
						</td>
						<td style="padding: 3px 10px 0 10px;">
							<label><input {if $sPost.mixed.default == $selectKey}checked="checked"{/if} type="radio" name="mixed[default]" value="{$selectKey}" /> {$lang.default}</label>
						</td>
						<td>
							<a class="delete_item" href="javascript:void(0)" onclick="$('#mixed_{$selectKey}').remove('');">{$lang.remove}</a>
							<script type="text/javascript">
							if (mixed_step <= {$selectKey})
								mixed_step = {$selectKey} + 1;
							</script>
						</td>
					</tr>
					{/if}
					{/foreach}
				{/if}
				</table>
				
				<div class="add_item"><a href="javascript:void(0)" onclick="field_build('mixed', langs_list );">{$lang.add_field_item}</a></div>
			</td>
		</tr>
		</table>
		</div>
	</div>
	<!-- mixed field end -->
	
	<!-- dropdown list field -->
	<div id="field_select" class="hide">
		<script type="text/javascript">
		var select_step = 1;
		</script>
		<table class="form">
		
		{rlHook name='apTplAccountFieldsFormDropdown'}
		
		<tr>
			<td class="name">{$lang.bind_data_format}</td>
			<td class="field">
				<select id="dd_select_block" name="data_format" class="data_format">
					<option value="0">{$lang.select}</option>
					{foreach from=$data_formats item='format'}
					<option value="{$format.Key}"{if $format.Key == $sPost.data_format} selected="selected"{/if}>{$format.name|strip_tags}</option>
					{/foreach}
				</select>
			</td>
		</tr>
		</table>
		
		<div id="select_block" {if $sPost.data_format}class="hide"{/if}>
		<table class="form">
		<tr>
			<td class="name">{$lang.field_items}</td>
			<td class="field">
				<table id="select">
				{if $sPost.select}
					{foreach from=$sPost.select item='selectItem' key='selectKey'}
					{if $selectKey != 'default'}
					<tr id="select_{$selectKey}">
						<td>
							{foreach from=$allLangs item='languages' name='lang_foreach'}
								{assign var='lCode' value=$languages.Code}
								<div><input type="text" class="float margin" value="{$selectItem.$lCode}" name="select[{$selectKey}][{$languages.Code}]" /><span class="field_description">{$lang.item_value} <span class="green_10">(<b>{$languages.name}</b>)</span></span></div>
							{/foreach}
						</td>
						<td style="padding: 3px 10px 0 10px;">
							<label><input {if $sPost.select.default == $selectKey}checked="checked"{/if} type="radio" name="select[default]" value="{$selectKey}" /> {$lang.default}</label>
						</td>
						<td>
							<a class="delete_item" href="javascript:void(0)" onclick="$('#select_{$selectKey}').remove('');">{$lang.remove}</a>
							<script type="text/javascript">
							if (select_step <= {$selectKey})
								select_step = {$selectKey} + 1;
							</script>
						</td>
					</tr>
					{/if}
					{/foreach}
				{/if}
				</table>
				
				<div class="add_item"><a href="javascript:void(0)" onclick="field_build('select', langs_list );">{$lang.add_field_item}</a></div>
			</td>
		</tr>
		</table>
		</div>
	</div>
	<!-- dropdown list field end -->
	
	<!-- radio set field -->
	<div id="field_radio" class="hide">
		<script type="text/javascript">
		var radio_step = 1;
		</script>
		<table class="form">
		
		{rlHook name='apTplAccountFieldsFormRadio'}
		
		<tr>
			<td class="name">{$lang.bind_data_format}</td>
			<td class="field">
				<select id="dd_radio_block" name="data_format" class="data_format">
					<option value="0">{$lang.select}</option>
					{foreach from=$data_formats item='format'}
					<option value="{$format.Key}"{if $format.Key == $sPost.data_format} selected="selected"{/if}>{$format.name|strip_tags}</option>
					{/foreach}
				</select>
			</td>
		</tr>
		</table>
		
		<div id="radio_block" {if $sPost.data_format}class="hide"{/if}>
		<table class="form">
		<tr>
			<td class="name">{$lang.field_items}</td>
			<td class="field">
				<table id="radio">
				{if $sPost.radio}
					{foreach from=$sPost.radio item='radioItem' key='radioKey'}
					{if $radioKey != 'default'}
					<tr id="radio_{$radioKey}">
						<td>
							{foreach from=$allLangs item='languages' name='lang_foreach'}
								{assign var='lCode' value=$languages.Code}
								<div><input type="text" class="float margin" value="{$radioItem.$lCode}" name="radio[{$radioKey}][{$languages.Code}]" /><span class="field_description">{$lang.item_value} <span class="green_10">(<b>{$languages.name}</b>)</span></span></div>
							{/foreach}
						</td>
						<td style="padding: 3px 10px 0 10px;">
							<label><input {if $sPost.radio.default == $radioKey}checked="checked"{/if} type="radio" name="radio[default]" value="{$radioKey}" /> {$lang.default}</label>
						</td>
						<td>
							<a class="delete_item" href="javascript:void(0)" onclick="$('#radio_{$radioKey}').remove('');">{$lang.remove}</a>
							<script type="text/javascript">
							if (radio_step <= {$radioKey})
								radio_step = {$radioKey} + 1;
							</script>
						</td>
					</tr>
					{/if}
					{/foreach}
				{/if}
				</table>
				
				<div class="add_item"><a href="javascript:void(0)" onclick="field_build('radio', langs_list );">{$lang.add_field_item}</a></div>
			</td>
		</tr>
		</table>
		</div>
	</div>
	<!-- radio set field end -->
	
	<!-- checkbox set field -->	
	<div id="field_checkbox" class="hide">
		<script type="text/javascript">
		var checkbox_step = 1;
		</script>
		<table class="form">
		
		{rlHook name='apTplAccountFieldsFormCheckbox'}
		
		<tr>
			<td class="name">{$lang.bind_data_format}</td>
			<td class="field">
				<select id="dd_checkbox_block" name="data_format" class="data_format">
					<option value="0">{$lang.select}</option>
					{foreach from=$data_formats item='format'}
					<option value="{$format.Key}"{if $format.Key == $sPost.data_format} selected="selected"{/if}>{$format.name|strip_tags}</option>
					{/foreach}
				</select>
			</td>
		</tr>
		</table>
		
		<div id="checkbox_block" {if $sPost.data_format}class="hide"{/if}>
		<table class="form">
		<tr>
			<td class="name">{$lang.field_items}</td>
			<td class="field">
				<table id="checkbox">
				{if $sPost.checkbox}
					{foreach from=$sPost.checkbox item='checkboxItem' key='checkboxKey'}
					{assign var='checkbox' value=$sPost.checkbox}
					{assign var='checkboxIter' value=$checkbox.$checkboxKey}
					{if $checkboxKey != 'default'}
					<tr id="checkbox_{$checkboxKey}">
						<td>
							{foreach from=$allLangs item='languages' name='lang_foreach'}
								{assign var='lCode' value=$languages.Code}
								<div><input type="text" class="margin float" value="{$checkboxItem.$lCode}" name="checkbox[{$checkboxKey}][{$languages.Code}]" /><span class="field_description">{$lang.item_value} <span class="green_10">(<b>{$languages.name}</b>)</span></span></div>
							{/foreach}
						</td>
						<td style="padding: 3px 10px 0 10px;">
							<input {if $checkboxIter.default == $checkboxKey}checked="checked"{/if} id="checkbox_def_{$checkboxKey}" type="checkbox" name="checkbox[{$checkboxKey}][default]" value="{$checkboxKey}" /> <label for="checkbox_def_{$checkboxKey}">{$lang.default}</label>
						</td>
						<td>
							<a class="delete_item" href="javascript:void(0)" onclick="$('#checkbox_{$checkboxKey}').remove('');">{$lang.remove}</a>
							<script type="text/javascript">
							if (checkbox_step <= {$checkboxKey})
								checkbox_step = {$checkboxKey} + 1;
							</script>
						</td>
					</tr>
					{/if}
					{/foreach}
				{/if}
				</table>
				
				<div class="add_item"><a href="javascript:void(0)" onclick="field_build('checkbox', langs_list );">{$lang.add_field_item}</a></div>
			</td>
		</tr>
		</table>
		</div>
	</div>
	<!-- checkbox set field end -->
	
	<!-- image field -->
	{assign var='image' value=$sPost.image}
	<div id="field_image" class="hide">
		<table class="form">
		<tr>
			<td class="name">{$lang.resize_type}</td>
			<td class="field">
				<select onchange="resize_action($(this).val());" name="image[resize_type]">
					<option value="">- {$lang.resize_type} -</option>
					{foreach from=$l_resize item='resize' key='resKey'}
						<option value="{$resKey}" {if $resKey == $sPost.image.resize_type}selected="selected"{/if}>{$resize}</option>
					{/foreach}
				</select>
			</td>
		</tr>
		
		<tr>
			<td class="name">{$lang.resolution}</td>
			<td class="field">
				<table>
				<tr>
					<td>
						<small>{$lang.width}: </small>
					</td>
					<td>
						<input readonly="readonly" id="resW" class="numeric" name="image[width]" type="text" style="width: 40px; text-align: center;" value="{$sPost.image.width}" maxlength="4" />
					</td>
				</tr>
				<tr>
					<td>
						<small>{$lang.height}: </small>
					</td>
					<td>
						<input readonly="readonly" id="resH" class="numeric" name="image[height]" type="text" style="width: 40px; text-align: center;" value="{$sPost.image.height}" maxlength="4" />
					</td>
				</tr>
				</table>
			</td>
		</tr>
		
		{rlHook name='apTplAccountFieldsFormImage'}
		
		</table>
	</div>
	<!-- image field end -->
	
	<!-- file storage field -->
	{assign var='image' value=$sPost.image}
	<div id="field_file" class="hide">
		<table class="form">
		<tr>
			<td class="name"><span class="red">*</span>{$lang.file_type}</td>
			<td class="field">
				<select name="file[type]">
					<option value="">- {$lang.file_type} -</option>
					{foreach from=$l_file_types item='fTypes' key='ftKey'}
						<option value="{$ftKey}" {if $ftKey == $sPost.file.type}selected="selected"{/if}>{$fTypes.name} ({$fTypes.ext})</option>
					{/foreach}
				</select>
			</td>
		</tr>
		
		{rlHook name='apTplAccountFieldsFormFile'}
		
		</table>
	</div>
	<!-- file storage field end -->
	
	<!-- agreement field -->
	<div id="field_accept" class="hide">
		<table class="form">
		{foreach from=$allLangs item='languages' name='lang_foreach'}
		{assign var='accept' value=$sPost.accept}
		{assign var='lCode' value=$languages.Code}
		<tr>
			<td class="name">
				<div style="margin-left: 10px;"><span class="red">*</span>{$lang.agreement_text} <span class="green_10">(<b>{$languages.name}</b>)</span></div>
			</td>
			<td class="field">
				<textarea rows="5" cols="" name="accept[{$languages.Code}]">{$accept.$lCode}</textarea>
			</td>
		</tr>
		{/foreach}
		
		{rlHook name='apTplAccountFieldsFormAgreement'}
		
		</table>
	</div>
	<!-- agreement field -->
	
	{rlHook name='apTplAccountFieldsFormBottom'}
	
	</div>
	<!-- additional options end -->
	
	<!-- additional JS -->
	{if $sPost.type != false}
	<script type="text/javascript">
		field_types('{$sPost.type}');
	</script>	
	{/if}
	
	{if $sPost.image.resize_type}
	<script type="text/javascript">
		resize_action('{$sPost.image.resize_type}');
	</script>	
	{/if}
	<!-- additional JS end -->
	
	<table class="form">
	<tr>
		<td class="no_divider"></td>
		<td class="field">
			<input type="submit" value="{if $smarty.get.action == 'edit'}{$lang.edit}{else}{$lang.add}{/if}" />
		</td>
	</tr>
	</table>
	</form>
	{include file='blocks'|cat:$smarty.const.RL_DS|cat:'m_block_end.tpl'}
	<!-- add new field end -->

{else}

	<!-- account fields grid -->
	<div id="grid"></div>
	<script type="text/javascript">//<![CDATA[
	var accountFieldsGrid;
	
	{literal}
	$(document).ready(function(){
		
		accountFieldsGrid = new gridObj({
			key: 'accountFields',
			id: 'grid',
			ajaxUrl: rlUrlHome + 'controllers/account_fields.inc.php?q=ext',
			defaultSortField: 'name',
			title: lang['ext_account_fields_manager'],
			remoteSortable: true,
			filters: cookie_filters,
			fields: [
				{name: 'name', mapping: 'name', type: 'string'},
				{name: 'Type', mapping: 'Type'},
				{name: 'Required', mapping: 'Required'},
				{name: 'Map', mapping: 'Map'},
				{name: 'Short_form', mapping: 'Short_form'},
				{name: 'Status', mapping: 'Status'},
				{name: 'Position', mapping: 'Position', type: 'int'},
				{name: 'Key', mapping: 'Key'}
			],
			columns: [
				{
					header: lang['ext_name'],
					dataIndex: 'name',
					width: 50,
					id: 'rlExt_item_bold'
				},{
					id: 'rlExt_item',
					header: lang['ext_type'],
					dataIndex: 'Type',
					width: 20
				},{
					header: lang['ext_required_field'],
					dataIndex: 'Required',
					width: 13,
					editor: new Ext.form.ComboBox({
						store: [
							['1', lang['ext_yes']],
							['0', lang['ext_no']]
						],
						displayField: 'value',
						valueField: 'key',
						emptyText: lang['ext_not_available'],
						typeAhead: true,
						mode: 'local',
						triggerAction: 'all',
						selectOnFocus:true
					}),
					renderer: function(val){
						return '<span ext:qtip="'+lang['ext_click_to_edit']+'">'+val+'</span>';
					}
				},{
					header: lang['ext_google_map'],
					dataIndex: 'Map',
					width: 13,
					editor: new Ext.form.ComboBox({
						store: [
							['1', lang['ext_yes']],
							['0', lang['ext_no']]
						],
						displayField: 'value',
						valueField: 'key',
						emptyText: lang['ext_not_available'],
						typeAhead: true,
						mode: 'local',
						triggerAction: 'all',
						selectOnFocus: true
					}),
					renderer: function(val){
						return '<span ext:qtip="'+lang['ext_click_to_edit']+'">'+val+'</span>';
					}
				},{
					header: lang['ext_status'],
					dataIndex: 'Status',
					width: 13,
					editor: new Ext.form.ComboBox({
						store: [
							['active', lang['ext_active']],
							['approval', lang['ext_approval']]
						],
						displayField: 'value',
						valueField: 'key',
						typeAhead: true,
						mode: 'local',
						triggerAction: 'all',
						selectOnFocus:true
					}),
					renderer: function(val){
						return '<span ext:qtip="'+lang['ext_click_to_edit']+'">'+val+'</span>';
					}
				},{
					header: lang['ext_actions'],
					width: 70,
					fixed: true,
					dataIndex: 'Key',
					sortable: false,
					renderer: function(data) {
						var out = "<center>";
						var splitter = false;
						
						if ( rights[cKey].indexOf('edit') >= 0 )
						{
							out += "<a href='"+rlUrlHome+"index.php?controller="+controller+"&action=edit&field="+data+"'><img class='edit' ext:qtip='"+lang['ext_edit']+"' src='"+rlUrlHome+"img/blank.gif' /></a>";
						}
						if ( rights[cKey].indexOf('delete') >= 0 )
						{
							out += "<img class='remove' ext:qtip='"+lang['ext_delete']+"' src='"+rlUrlHome+"img/blank.gif' onclick='rlConfirm( \""+lang['ext_notice_delete_field']+"\", \"xajax_deleteAField\", \""+Array(data)+"\", \"field_load\" )' />";
						}
						out += "</center>";
						
						return out;
					}
				}
			]
		});
		
		{/literal}{rlHook name='apTplAccountFieldsGrid'}{literal}
		
		accountFieldsGrid.init();
		grid.push(accountFieldsGrid.grid);
		
	});
	{/literal}
	//]]>
	</script>
	<!-- account fields grid end -->
	
	{rlHook name='apTplAccountFieldsBottom'}

{/if}

<!-- register fields tpl end -->