<?php
/**
 * Hello Magento
 *
 * @package    HM
 * @license    http://opensource.org/licenses/afl-3.0.php  Academic Free License (AFL 3.0)
 * @see HM_Bestseller_Model_Bestseller
 */
?>

<?php 
 
$total_products = ($this->show_total) ? $this->show_total : 6;
$_productCollection = $this->getBestsellers($total_products); 
$_collectionSize = count($_productCollection);
?>


<?php if(count($_productCollection) > 0): ?>

<?php /* BELOW IS DEFAULT MAGENTO TEMPLATE CODE FROM catalog/product/list.phtml file */ ?>
<div class="listing-type-grid catalog-listing">
<div class="new-product-title">
    <strong>Top Sellers</strong>
</div>
<div class="block-home-content products-grid" >
<?php $_collectionSize = count($_productCollection) ?>
		<?php $_columnCount = 3; ?>
		<?php $i=0; foreach ($_productCollection as $_product): ?>
		<?php if($i++%$_columnCount==0): ?>
			<ul class="products-grid">
		<?php endif; ?>
			<li class="item <?php if($i%3==1):?> first <?php elseif($i%3==0):?>last<?php endif;?>">
				<div class="boxgrid_caption">
                    <a href="<?php echo $_product->getProductUrl() ?>" title="<?php echo $this->htmlEscape($this->getImageLabel($_product, 'small_image')) ?>">
                        <img src="<?php echo $this->helper('catalog/image')->init($_product, 'small_image')->resize(135, 135); ?>" alt="<?php echo $this->htmlEscape($this->getImageLabel($_product, 'small_image')) ?>" title="<?php echo $this->htmlEscape($this->getImageLabel($_product, 'small_image')) ?>" />
                    </a>					
					<div class="cover_boxcaption">
						<div class="group_box">
							<div class="box_price">								
								<span><?php echo $this->helper('checkout')->formatPrice($_product->getPrice()) ?></span>
							</div>
						</div>						
						<h3><a href="<?php echo $_product->getProductUrl() ?>"><?php echo $this->htmlEscape($_product->getName()) ?></a></h3>
					</div>
                </div>
			</li>
			<?php if($i%$_columnCount==0 || $i==$_collectionSize): ?>
			</ul>
			<div class="clear_both"><span></span></div>
			<?php endif; ?>
			<?php //if($i>=3):break; endif;?>
		<?php endforeach ?>
		<script type="text/javascript">decorateGeneric($$('.products-grid'), ['last', 'odd', 'even']);</script>
	</div>
</div>
<?php endif; ?>
