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

<inp2:m_Get name="section" result_to_var="section"/>
<inp2:m_RenderElement name="combined_header" prefix="cf" section="$section" perm_event="cf:OnLoad" title_preset="custom_fields_list" pagination="1"/>

<!-- ToolBar -->
<table class="toolbar" height="30" cellspacing="0" cellpadding="0" width="100%" border="0">
<tbody>
	<tr>
  	<td>
  		<script type="text/javascript">
  			//do not rename - this function is used in default grid for double click!
  			function edit()
  			{
  				std_edit_item('cf', 'custom_fields/custom_fields_edit');
  			}

  			var a_toolbar = new ToolBar();
				a_toolbar.AddButton( new ToolBarButton('new_item', '<inp2:m_phrase label="la_ToolTip_New_CustomField" escape="1"/>::<inp2:m_phrase label="la_Add" escape="1"/>',
						function() {
							std_precreate_item('cf', 'custom_fields/custom_fields_edit')
						} ) );

				a_toolbar.AddButton( new ToolBarButton('edit', '<inp2:m_phrase label="la_ToolTip_Edit" escape="1"/>', edit) );
				a_toolbar.AddButton( new ToolBarButton('delete', '<inp2:m_phrase label="la_ToolTip_Delete" escape="1"/>',
						function() {
							std_delete_items('cf')
						} ) );

				a_toolbar.AddButton( new ToolBarSeparator('sep1') );
				<inp2:m_if check="m_isDebugMode">

					a_toolbar.AddButton( new ToolBarButton('clone', '<inp2:m_phrase label="la_ToolTip_Clone" escape="1"/>',
						function() {
							submit_event('cf', 'OnMassClone')
						} ) );

					a_toolbar.AddButton( new ToolBarSeparator('sep2') );
				</inp2:m_if>

				a_toolbar.AddButton( new ToolBarButton('move_up', '<inp2:m_phrase label="la_ToolTip_MoveUp" escape="1"/>', function() {
							submit_event('cf','OnMassMoveUp');
						}
				 ) );

				a_toolbar.AddButton( new ToolBarButton('move_down', '<inp2:m_phrase label="la_ToolTip_MoveDown" escape="1"/>', function() {
							submit_event('cf','OnMassMoveDown');
						}
				 ) );

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

				a_toolbar.AddButton( new ToolBarButton('view', '<inp2:m_phrase label="la_ToolTip_View" escape="1"/>', function() {
							show_viewmenu(a_toolbar,'view');
						}
				) );

				a_toolbar.Render();
			</script>
		</td>

		<inp2:m_RenderElement name="search_main_toolbar" prefix="cf" grid="Default"/>
	</tr>
</tbody>
</table>

<inp2:m_DefineElement name="cf_grid_data_td">
	<inp2:Field field="$field" grid="$grid" no_special="no_special" as_label="1" />
</inp2:m_DefineElement>

<style type="text/css">
	tr.row-disabled td {
		background-color: #FFDFE0;
	}

	tr.grid-data-row-even.row-disabled td {
		background-color: #F4D4D5;
	}
</style>

<inp2:m_DefineElement name="row_class">
	<inp2:m_if check="Field" field="IsSystem" db="db">
		row-disabled
	</inp2:m_if>
</inp2:m_DefineElement>

<inp2:m_RenderElement name="grid" PrefixSpecial="cf" IdField="CustomFieldId" grid="Default" row_class_render_as="row_class"/>
<script type="text/javascript">
	Grids['cf'].SetDependantToolbarButtons( new Array('edit','delete', 'clone', 'move_down', 'move_up') );
</script>

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