<script language="javascript">
	var idCurrentCategory={$idCurrentCategory|default:0};
</script>

{if $categoriesList}
	{foreach from=$categoriesList item=category key=key name=categoriesLoop}
		<div id="categoryDiv_{$category.id}"

			{if $category.id==$idCurrentCategory}class="tabSel"
			{else}class="tabBlur"{/if}

			onmouseover="$(this).addClassName('tabFocus');"
			onmouseout="$(this).removeClassName('tabFocus');"
			onclick="

				// switch clases
				if ( idCurrentCategory && $('categoryDiv_'+idCurrentCategory) )
					$('categoryDiv_'+idCurrentCategory).className='tabBlur';
				$(this).className='tabSel';
				idCurrentCategory={$category.id};

				// reload reports
				ajaxIframe('reportsListDiv', 'reportsList.php', 'idCategory={$category.id}&currentPage=0');

			"

		>

			{* -- edit category -- *}
			<a href="#;" class="icon-edit" tooltip="{$_LANG.reports.mng.categories.editCatTooltip}"
				onclick="editCategory('{$category.id}');"
			></a>

			{* -- delete category -- *}
			{if !$category.reportsCount}
				<a href="#;" class="icon-delete" tooltip="{$_LANG.reports.mng.categories.delCatTooltip}"
					onclick="
						messageBox.showQuestion(
							'{$_LANG.confirm}',
							'{$_LANG.reports.mng.categories.delCatConfirm}',
							[
								['{$_LANG.yes}', 'window.location=\'./?deleteIdCategory={$category.id}\''],
								['{$_LANG.no}','',true]
							]
						)
					"
				></a>
			{/if}

			{$category.name}

			{if $category.description}
				<div class="categoryDescription">{$category.description}</div>
			{/if}

		</div>

		{if !$smarty.foreach.categoriesLoop.last}
			<div class="categoriesEmptyDiv categoriesSpacer">&nbsp;</div>
		{/if}

	{/foreach}
{/if}

<div class="right categoriesEmptyDiv addCatDiv">
	<button type="button" onclick="addCategory();">{$_LANG.reports.mng.categories.addCatButton}</button>
</div>

<div id="categoriesSpaceFiller" class="categoriesEmptyDiv"></div>