<inp2:m_include t="incs/header" noform="yes"/>
<inp2:m_include template="catalog/catalog_elements"/>

<inp2:m_RenderElement name="combined_header" section="in-portal:browse" prefix="c" title_preset="advanced_view" tabs="catalog/catalog_tabs" special=".showall" additional_blue_bar_render_as="theme_selector"/>

<!-- main kernel_form: begin -->
<inp2:m_RenderElement name="kernel_form"/>
<!-- ToolBar -->
<table class="toolbar" height="30" cellspacing="0" cellpadding="0" width="100%" border="0">
<tbody>
	<tr>
	  	<td>
	  		<input type="hidden" name="m_cat_id" value="<inp2:m_get name="m_cat_id"/>"/>
			<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">
	  			<inp2:m_if check="adm_CheckPermCache">
	  				$(document).ready(
	  					function() {
	  						Application.SetVar('continue', 1);
	  						openSelector('c', '<inp2:m_t t="categories/cache_updater" pass="m"/>');
	  					}
	  				);
	  			</inp2:m_if>

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

	  			var $Catalog = new Catalog('<inp2:m_Link template="#TEMPLATE_NAME#" pass_through="ts,td" ts="showall" td="no" m_cat_id="#CATEGORY_ID#" no_amp="1"/>', 'advanced_view_', 'AdvancedView');
				var a_toolbar = new ToolBar();

					<inp2:m_set ts="showall" td="no"/>
					<inp2:m_ModuleInclude template="catalog_tab" tab_init="1" replace_m="yes"/>

					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 + ']', 1);
							std_delete_items($Catalog.ActivePrefix, $template, 1);
						} ) );


					<inp2:m_ModuleInclude template="catalog_buttons" main_template="advanced_view"/>

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

					a_toolbar.AddButton( new ToolBarButton('approve', '<inp2:m_phrase label="la_ToolTip_Approve" escape="1"/>', function() {
							$form_name = $Catalog.queryTabRegistry('prefix', $Catalog.ActivePrefix, 'tab_id') + '_form';
							set_hidden_field('remove_specials[' + $Catalog.ActivePrefix + ']', 1);
							$Catalog.submit_event($Catalog.ActivePrefix, 'OnMassApprove');
						}
				 	) );

					a_toolbar.AddButton( new ToolBarButton('decline', '<inp2:m_phrase label="la_ToolTip_Decline" escape="1"/>', function() {
							$form_name = $Catalog.queryTabRegistry('prefix', $Catalog.ActivePrefix, 'tab_id') + '_form';
							set_hidden_field('remove_specials[' + $Catalog.ActivePrefix + ']', 1);
							$Catalog.submit_event($Catalog.ActivePrefix, 'OnMassDecline');
						}
				 	) );

					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();

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

					function add_item() {
						$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_precreate_item(
							$Catalog.ActivePrefix, $Catalog.queryTabRegistry('prefix', $Catalog.ActivePrefix, 'edit_template'),
							function() {
								$kf.action = $prev_action;
							}
						);
					}
			</script>
		</td>

		<inp2:m_RenderElement name="catalog_search_box"/>
	</tr>
</tbody>
</table>
<inp2:m_RenderElement name="kernel_form_end"/>
<!-- main kernel_form: end -->

<inp2:m_set ts="showall" td="no"/>
<inp2:m_ModuleInclude template="catalog_tab" tab_init="2"/>

<script type="text/javascript">
	var $menu_frame = getFrame('menu');
	if (typeof $menu_frame.ShowStructure != 'undefined') {
		<inp2:m_DefineElement name="structure_node"><inp2:m_param name="section_url"/></inp2:m_DefineElement>
		$menu_frame.ShowStructure('<inp2:adm_PrintSection escape="1" render_as="structure_node" section_name="in-portal:browse"/>', false);
	}

	Application.setHook(
		'm:OnAfterWindowLoad',
		function() {
			$Catalog.Init();
			<inp2:m_if check="m_get" var="SetTab">
				$Catalog.switchTab('<inp2:m_get var="SetTab"/>.showall');
			</inp2:m_if>

			getFrame('head').$('#extra_toolbar').html('<inp2:m_RenderElement name="extra_toolbar" js_escape="1"/>');
		}
	);
</script>

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