<?php
/**
 * Avalanche for Magento 1.8+
 * Designed by Fast Division (http://fastdivision.com)
 *
 * NOTICE OF LICENSE
 *
 * This source file is subject to the EULA
 * that is bundled with this package in the file license.txt.
 * It is also available through the world-wide-web at this URL:
 * http://fastdivision.com/legal/license.txt
 *
 * @author     Fast Division
 * @version    1.5.0
 * @copyright  Copyright 2013 Fast Division
 * @license    http://fastdivision.com/legal/license.txt
 */
?>
<?php
    $_helper = $this->helper('catalog/output');
    $_category = $this->getCurrentCategory();
	$_filters = Mage::getSingleton('Mage_Catalog_Block_Layer_State')->getActiveFilters();
    $_imgHtml   = '';
    if($_imgUrl = $_category->getImageUrl()) {
        $_imgHtml = '<img src="'.$_imgUrl.'" alt="'.$this->escapeHtml($_category->getName()).'" title="'.$this->escapeHtml($_category->getName()).'" />';
        $_imgHtml = $_helper->categoryAttribute($_category, $_imgHtml, 'image');
    }
?>
<div class="page-title category-title">
    <h1>
		<?php 
			$title = $_helper->categoryAttribute($_category, $_category->getName(), 'name');
			
			foreach($_filters as $_filter) {
				if($_filter->getName() == "Category") {
					$title = $_filter->getLabel();
				} else {
					$title = $_filter->getLabel() . " " . $title;
				}
			}
			
			echo $title;
		?>
	</h1>
</div>

<div class="page-messages">
	<?php echo $this->getMessagesBlock()->getGroupedHtml() ?>
</div>

<?php if($_imgUrl): ?>
	<div class="category-banner">
    	<?php echo $_imgHtml ?>
    </div>
<?php endif; ?>

<?php if($_description=$this->getCurrentCategory()->getDescription()): ?>
    <div class="category-description std">
        <?php echo $_helper->categoryAttribute($_category, $_description, 'description') ?>
    </div>
<?php endif; ?>

<?php if($this->isContentMode()): ?>
    <?php echo $this->getCmsBlockHtml() ?>

<?php elseif($this->isMixedMode()): ?>
    <?php echo $this->getCmsBlockHtml() ?>
    <?php echo $this->getProductListHtml() ?>

<?php else: ?>
    <?php echo $this->getProductListHtml() ?>
<?php endif; ?>
