<inp2:adm_SetPopupSize width="650" height="790"/>

<inp2:m_include t="incs/header"/>
<inp2:m_Get name="section" result_to_var="section"/>
<inp2:m_RenderElement name="combined_header" prefix="conf" section="$section" title_preset="config_edit"/>

<!-- ToolBar -->
<table class="toolbar" height="30" cellspacing="0" cellpadding="0" width="100%" border="0">
<tbody>
	<tr>
  	<td>
  		<script type="text/javascript">
				a_toolbar = new ToolBar();
				a_toolbar.AddButton( new ToolBarButton('select', '<inp2:m_phrase label="la_ToolTip_Save" escape="1"/>', function() {
							submit_event('conf', '<inp2:conf_SaveEvent/>');
						}
					) );
				a_toolbar.AddButton( new ToolBarButton('cancel', '<inp2:m_phrase label="la_ToolTip_Cancel" escape="1"/>', function() {
							cancel_edit('conf', 'OnCancelEdit','<inp2:conf_SaveEvent/>','<inp2:m_Phrase label="la_FormCancelConfirmation" escape="1"/>');
						}
				 ) );

			 a_toolbar.AddButton( new ToolBarButton('reset_edit', '<inp2:m_phrase label="la_ToolTip_Reset" escape="1"/>', function() {
						reset_form('conf', 'OnReset', '<inp2:m_Phrase label="la_FormResetConfirmation" escape="1"/>');
					}
			 	) );

				a_toolbar.AddButton( new ToolBarSeparator('sep1') );

				a_toolbar.AddButton( new ToolBarButton('prev', '<inp2:m_phrase label="la_ToolTip_Prev" escape="1"/>', function() {
							go_to_id('conf', '<inp2:conf_PrevId/>');
						}
				 ) );
				a_toolbar.AddButton( new ToolBarButton('next', '<inp2:m_phrase label="la_ToolTip_Next" escape="1"/>', function() {
							go_to_id('conf', '<inp2:conf_NextId/>');
						}
				 ) );

				a_toolbar.Render();

				<inp2:m_if check="conf_IsSingle" >
					a_toolbar.HideButton('prev');
					a_toolbar.HideButton('next');
					a_toolbar.HideButton('sep1');
				<inp2:m_else/>
					<inp2:m_if check="conf_IsLast" >
						a_toolbar.DisableButton('next');
					</inp2:m_if>
					<inp2:m_if check="conf_IsFirst" >
						a_toolbar.DisableButton('prev');
					</inp2:m_if>
				</inp2:m_if>
			</script>
		</td>
	</tr>
</tbody>
</table>

<inp2:conf_SaveWarning name="grid_save_warning"/>
<inp2:conf_ErrorWarning name="form_error_warning"/>

<div id="scroll_container">
	<table class="edit-form">
		<inp2:m_RenderElement name="inp_id_label" prefix="conf" field="VariableId" title="la_fld_Id"/>
		<inp2:m_RenderElement name="inp_edit_box" prefix="conf" field="VariableName" title="la_fld_SystemSettingName"/>
		<inp2:m_RenderElement name="inp_label" prefix="conf" field="VariableValue" title="la_fld_SystemSettingValue"/>
		<inp2:m_RenderElement name="inp_edit_options" prefix="conf" field="ModuleOwner" title="la_fld_Module" has_empty="1"/>
		<inp2:m_RenderElement name="inp_edit_box" prefix="conf" field="Section" title="la_fld_SystemSettingSection"/>
		<inp2:m_RenderElement name="inp_edit_box" prefix="conf" field="Heading" title="la_prompt_heading"/>
		<inp2:m_RenderElement name="inp_edit_box" prefix="conf" field="Prompt" title="la_prompt_FieldPrompt"/>
		<inp2:m_RenderElement name="inp_edit_box" prefix="conf" field="HintLabel" title="la_fld_SystemSettingHint"/>
		<inp2:m_RenderElement name="inp_edit_options" prefix="conf" field="ElementType" title="la_prompt_InputType" has_empty="1"/>
		<inp2:m_RenderElement name="inp_edit_textarea" prefix="conf" field="Validation" title="la_fld_SystemSettingValidation"/>
		<inp2:m_RenderElement name="inp_edit_textarea" prefix="conf" field="ValueList" title="la_prompt_valuelist"/>
		<inp2:m_RenderElement name="inp_edit_box" prefix="conf" field="DisplayOrder" title="la_field_displayorder"/>
		<inp2:m_RenderElement name="inp_edit_box" prefix="conf" field="GroupDisplayOrder"/>
		<inp2:m_RenderElement name="inp_edit_filler"/>
	</table>
</div>

<script type="text/javascript">
	$(document).ready(function () {
		var $suggest_url = '<inp2:m_Link template="dummy" pass="m,conf" conf_event="OnSuggestValuesJSON" field="#FIELD_NAME#" no_amp="1" js_escape="1"/>';

		$.each(['Section', 'Heading'], function ($i, $field) {
			var $selector = '<inp2:conf_InputName name="#FIELD_NAME#" js_escape="1"/>'.replace('#FIELD_NAME#', $field);

			$('#' + jq($selector))
			.autocomplete({
				source: $suggest_url.replace('#FIELD_NAME#', $field)
			})
			.data('ui-autocomplete')._renderItem = function (ul, item) {
				// allow HTML in items
				return $('<li>').append($('<a>').html(item.label)).appendTo(ul);
			};
		});
	});
</script>

<inp2:m_include t="incs/footer"/>
