<inp2:adm_SetPopupSize width="720" height="500"/>

<inp2:m_include t="incs/header"/>
<inp2:m_RenderElement name="combined_header" section="in-portal:user_list" prefix="u" title_preset="user_edit_items" tab_preset="Default"/>

<inp2:m_include template="catalog/catalog_elements"/>

<!-- ToolBar -->
<table class="toolbar" height="30" cellspacing="0" cellpadding="0" width="100%" border="0">
<tbody>
	<tr>
  		<td>
  			<link rel="stylesheet" rev="stylesheet" href="<inp2:m_Compress files='incs/nlsmenu.css'/>" type="text/css" />
			<script type="text/javascript" src="<inp2:m_Compress files='
				js/nlsmenu.js|
				js/nlsmenueffect_1_2_1.js|
				js/catalog.js
			'/>"></script>

	  		<script type="text/javascript">
  				var menuMgr = new NlsMenuManager("mgr");
					menuMgr.timeout = 500;
					menuMgr.flowOverFormElement = true;

  				Request.progressText = '<inp2:m_phrase name="la_title_Loading" no_editing="1" escape="1"/>';

  				Catalog.prototype.AfterInit = function () {
					this.switchTab(); // refresh current item tab
				}

  				/*Catalog.prototype.refreshTab = function($prefix, $div_id, $force) {
					// query tab content only in case if not queried or category don't match

					var $cat_id = get_hidden_field('m_cat_id');
					var $tab_cat_id = document.getElementById($div_id).getAttribute('category_id');
					if ($cat_id != $tab_cat_id || $force) {
						var $url = this.URLMask.replace('#TEMPLATE_NAME#', this.queryTabRegistry('prefix', $prefix, 'module_path') + '/user_item_tab');

						this.BusyRequest[$prefix] = false;

						Request.makeRequest($url, this.BusyRequest[$prefix], $div_id, this.successCallback, this.errorCallback, $div_id, this);
					}
				}*/

	  			var $Catalog = new Catalog('<inp2:m_Link template="#TEMPLATE_NAME#" pass_through="ts" ts="user" pass="m,u" no_amp="1"/>', 'useritems_', 'UserItemEditor');

				a_toolbar = new ToolBar();
				a_toolbar.AddButton( new ToolBarButton('select', '<inp2:m_phrase label="la_ToolTip_Save" escape="1"/>', function() {
							submit_event('u','<inp2:u_SaveEvent/>');
						}
					) );
				a_toolbar.AddButton( new ToolBarButton('cancel', '<inp2:m_phrase label="la_ToolTip_Cancel" escape="1"/>', function() {
							submit_event('u','OnCancelEdit');
						}
				 ) );

				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('u', '<inp2:u_PrevId/>');
						}
				 ) );
				a_toolbar.AddButton( new ToolBarButton('next', '<inp2:m_phrase label="la_ToolTip_Next" escape="1"/>', function() {
							go_to_id('u', '<inp2:u_NextId/>');
						}
				 ) );

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

				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() {
						var $template = $Catalog.queryTabRegistry('prefix', $Catalog.ActivePrefix, 'view_template');
						$form_name = $Catalog.queryTabRegistry('prefix', $Catalog.ActivePrefix, 'tab_id') + '_form';
						set_hidden_field('remove_specials[' + $Catalog.ActivePrefix + '.user]', 1);
						std_delete_items($Catalog.ActivePrefix, $template, 1);
					} ) );


				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');
						}
				) );

				function edit() {
					$form_name = $Catalog.queryTabRegistry('prefix', $Catalog.ActivePrefix, 'tab_id') + '_form';
					var $kf = document.getElementById($form_name);

					var $prev_action = $kf.action;
					$kf.action = '<inp2:m_t pass="all" no_pass_through="1"/>';

					set_hidden_field('remove_specials[' + $Catalog.ActivePrefix + ']', 1);
					std_edit_item(
						$Catalog.ActivePrefix, $Catalog.queryTabRegistry('prefix', $Catalog.ActivePrefix, 'edit_template'),
						function() {
							$kf.action = $prev_action;
						}
					);
				}

				a_toolbar.Render();

				<inp2:m_if check="u_IsSingle">
					a_toolbar.HideButton('prev');
					a_toolbar.HideButton('next');
					a_toolbar.HideButton('sep1');
				<inp2:m_else/>
					<inp2:m_if check="u_IsLast">
						a_toolbar.DisableButton('next');
					</inp2:m_if>
					<inp2:m_if check="u_IsFirst">
						a_toolbar.DisableButton('prev');
					</inp2:m_if>
				</inp2:m_if>
			</script>
		</td>

		<inp2:m_RenderElement name="catalog_search_box"/>
	</tr>
</tbody>
</table>
<inp2:m_RenderElement name="kernel_form_end"/>

<inp2:u_SaveWarning name="grid_save_warning"/>
<inp2:u_ErrorWarning name="form_error_warning"/>

<div id="scroll_container" mode="minimal">
	<table class="edit-form">
		<inp2:m_RenderElement name="subsection" prefix="u" fields="PortalUserId,Login" title="la_section_General"/>
			<inp2:m_RenderElement name="inp_id_label" prefix="u" field="PortalUserId" title="la_fld_Id"/>
			<inp2:m_RenderElement name="inp_label" prefix="u" field="Login" title="la_fld_Username"/>
			<inp2:m_RenderElement name="inp_edit_filler"/>
		<inp2:m_RenderElement name="subsection" title="la_section_Items"/>
	</table>
</div>
<br />

<!-- item tabs: begin -->
<inp2:m_DefineElement name="item_tab" title="" special=".user">
	<td class="tab-spacer"><img src="img/spacer.gif" width="3" height="1"/></td>
	<td id="<inp2:m_param name="prefix"/><inp2:m_param name="special"/>_tab" class="tab">
		<img src="<inp2:m_TemplatesBase module='$icon_module'/>/img/itemicons/<inp2:m_Param name='icon'/>" width="16" height="16" align="absmiddle" alt=""/>
		<a href="#" onclick="$Catalog.switchTab('<inp2:m_param name="prefix"/><inp2:m_Param name="special"/>'); return false;" class="tab-link">
			<inp2:m_Phrase name="$title"/> <span class="small-statistics" style="color: inherit;">(<span id="<inp2:m_param name="prefix"/><inp2:m_Param name="special"/>_item_count">?</span>)</span>
		</a>
	</td>
</inp2:m_DefineElement>

<inp2:m_DefineElement name="user_items_tabs">
	<inp2:m_ModuleInclude template="user_item_tab" tab_init="2" title_property="ViewMenuPhrase" skip_prefixes="m,adm,cms"/>
</inp2:m_DefineElement>

<inp2:m_RenderElement name="tabs_container" tabs_render_as="user_items_tabs"/>
<!-- item tabs: end -->

<inp2:m_set ts="user"/>
<inp2:m_ModuleInclude template="user_item_tab" tab_init="1" skip_prefixes="m,adm,cms"/>
<script type="text/javascript">

addLoadEvent(
	function() {
		$Catalog.Init(false);
	}
);

</script>
<inp2:m_include t="incs/footer" noform="yes"/>