<h1 class="dashboard-title"><?php echo $this->translate("Categories"); ?></h1>
<div id="tree-controls">
	<a id="createNewNode"><?php echo $this->translate('Create category'); ?></a>
	<a id="renameNode"><?php echo $this->translate('Rename category'); ?></a>
	<a id="deleteNode"><?php echo $this->translate('Delete category'); ?></a>
	<a id="saveConfiguration"><?php echo $this->translate("Save"); ?></a>
	<div style="clear:both"></div>
</div>

<div id="categ-wrapper">
	<ul>
		<li id="node_root" class="open" rel="root">
			<a href="#"><?php echo $this->translate('Categories'); ?></a>
			<?php if(count($this->categories->filterRootNodes())): ?>
			<ul>
				<?php foreach($this->categories->filterRootNodes() as $category): ?>

							<li id="node_<?php echo $category['ID']; ?>" rel="primary-categ">
								<a href="#"><?php echo $category['Name']; ?></a>
				<?php 			$children = $category->getChildren();
								if(count($children)): 										?>
									<ul>
				<?php 				foreach($children as $child):							?>
										<li id="node_<?php echo $child['ID']; ?>" rel="secondary-categ">
											<a href="#"><?php echo $child['Name']; ?></a>
										</li>
				<?php				endforeach;												?>
									</ul>
				<?php 			endif; 														?>
							</li>
				<?php endforeach; 													?>
			</ul>
			<?php endif; ?>
		</li>
	</ul>
</div>

<div id="instructions">
	<h2><?php echo $this->translate('Instructions'); ?></h2>
	<p>
		<?php echo $this->translate(
			'To reorder categories, simply drag and drop them.<br/>
			To create a new category, select the parent category and then click "Create category".<br/>
			To rename a category, select it and click "Rename category".<br/>
			<br/>
			Many of these options are available using right-click/secondary-click on the items.
		'); ?>
	</p>
</div>

<div class="dialog" id="saveDialog" title="<?php echo $this->translate("Save successful"); ?>">
	<?php echo $this->translate("Your category configuration has been saved."); ?>
</div>

<?php
	$this->headLink()->appendStylesheet($this->path . 'js/jsTree/tree_component.css');
	$this->headLink()->appendStylesheet($this->baseUrl . '/public/js/lib/jquery-ui/css/cupertino/jquery-ui-1.7.1.custom.css');
	$this->headLink()->appendStylesheet($this->path . 'css/categories.css');
	$this->headScript()
		->appendFile($this->path . 'js/jsTree/_lib.js', 'text/javascript')
		->appendFile($this->path . 'js/jsTree/tree_component.min.js', 'text/javascript')
		->appendFile($this->path . 'js/jquery.json-1.3.min.js')
		->appendScript('var pluginUrl="' . $this->pluginUrl . '";')
		->appendFile($this->path . 'js/categories.js', 'text/javascript')
		->appendFile($this->baseUrl . '/public/js/lib/jquery-ui/js/jquery-ui-1.7.custom.min.js');
?>
