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

<inp2:m_RenderElement name="combined_header" section="in-portal:reviews" prefix="c" module="in-portal" title_preset="reviews" tabs="catalog/catalog_tabs" special="-rev" skip_prefixes="m,c"/>

<!-- 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="incs/nlsmenu.css" type="text/css" />
			<script type="text/javascript" src="js/nlsmenu.js"></script>
			<script type="text/javascript" src="js/nlsmenueffect_1_2_1.js"></script>
	  		<script type="text/javascript" src="js/ajax.js"></script>
	  		<script type="text/javascript" src="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();
	  			}

	  			Catalog.prototype.refreshTab = function($prefix, $div_id, $force) {
					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) {
						// query tab content only in case if not queried or category don't match
						var $url = this.URLMask.replace('#ITEM_PREFIX#', $prefix).replace('#TAB_NAME#', this.queryTabRegistry('prefix', $prefix, 'tab_id'));
						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="reviews/reviews_tab" item_prefix="#ITEM_PREFIX#" tab_name="#TAB_NAME#" pass_through="td,item_prefix,tab_name" td="no" m_cat_id="-1" no_amp="1"/>', 'reviews_', 'Reviews');
				var a_toolbar = new ToolBar();

					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() {
							$form_name = $Catalog.queryTabRegistry('prefix', $Catalog.ActivePrefix, 'tab_id') + '_form';
							std_delete_items($Catalog.ActivePrefix, null, 1);
						} ) );


					<inp2:m_ModuleInclude template="catalog_buttons" main_template="reviews" skip_prefixes="m,c" replace_m="yes"/>

					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';
							$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';
							$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" pass_through="item_prefix" item_prefix="#PREFIX#" no_amp="1"/>' . replace('#PREFIX#', $Catalog.ActivePrefix);

						std_edit_temp_item(
							$Catalog.ActivePrefix, 'reviews/review_direct_edit',
							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 prefix_append="-rev" td="no"/>
<inp2:m_ModuleInclude template="catalog_tab" tab_init="2" skip_prefixes="m,c" replace_m="yes"/>

<inp2:m_if check="m_get" var="SetTab">
<script type="text/javascript">
	$Catalog.switchTab('<inp2:m_get var="SetTab"/>-rev');
</script>
</inp2:m_if>

<script type="text/javascript">
	addLoadEvent(
		function() {
			$Catalog.Init();
		}
	);
</script>

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