<?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 if (($_products = $this->getProductCollection()) && $_products->getSize()): ?>
<?php $_collectionSize = count($_products->getItems()) ?>

<?php 
	$gridClasses = '';
	if(Mage::getStoreConfig('avalanche_config/avalanche_product_listings/avalanche_quick_view') == 1)
		$gridClasses .= 'quick-view-enabled ';
	if(Mage::getStoreConfig('avalanche_config/avalanche_product_listings/avalanche_grid_hover') == 1)
		$gridClasses .= 'grid-hover-enabled ';
?>
	
<h2 style="margin: 0"><?php echo $this->__('Best Sellers') ?></h2>

<!--<a class="carousel-backward-nav"><?php echo $this->__('Previous') ?></a>-->

<div class="<?php echo $gridClasses ?>">
	<ul class="product-grid product-grid-homepage carousel clearfix">
		<?php foreach ($_products->getItems() as $_product): ?>
		<li>
			<div class="grid-image"><a href="<?php echo $_product->getProductUrl() ?>"><img src="<?php echo $this->helper('catalog/image')->init($_product, 'small_image')->resize(118) ?>" alt="<?php echo $this->htmlEscape($_product->getName()) ?>"></a>
				<div class="grid-quick-view">
					<a href="#" data-url="<?php echo Mage::getBaseUrl(), 'catalog/ajax_product/view/?id=', $_product->getId() ?>/"><?php echo $this->__('Quick View') ?></a>
				</div>	
			</div>
			<div class="grid-rating"><?php echo $this->getReviewsSummaryHtml($_product) ?></div>
			<div class="grid-title"><a href="<?php echo $_product->getProductUrl() ?>"><?php echo $this->htmlEscape($_product->getName()) ?></a></div>
			<div class="grid-price"><?php echo $this->getPriceHtml($_product, false, '-new') ?></div>
			<div class="grid-actions">
	            <?php if(Mage::getStoreConfigFlag('avalanche_config/avalanche_product_listings/avalanche_grid_show_button')): ?>
				<a href="<?php echo $_product->getProductUrl() ?>" class="action-button"><?php echo Mage::getStoreConfig('avalanche_config/avalanche_product_listings/avalanche_grid_show_button_text'); ?></a>
	            <?php endif; ?>
			</div>
		</li>	
		<?php endforeach; ?>
	</ul>
</div>

<!--<a class="carousel-forward-nav"><?php echo $this->__('Next') ?></a>-->

<?php else: ?>
	<h2><?php echo $this->__('Best Sellers') ?></h2>
	
	<div class="white-box-inner">
		<p><?php echo $this->__('No best sellers were found. Clear your cache, reindex and make sure you\'ve sold some products!') ?></p>
	</div>
<?php endif; ?>