
<?php
/**
 * Product list template
 *
 * @see Mage_Catalog_Block_Product_List
 */
?>
<?php
    $_productCollection=$this->getLoadedProductCollection();
    $_helper = $this->helper('catalog/output');
    $this->setData('column_count',3);
?>
<?php if(!$_productCollection->count()): ?>
<?php
$empty_category_block = Mage::getModel('cms/block')->load('amaze_empty_category');
 if($empty_category_block->getIsActive()){
     echo $this->getLayout()->createBlock('cms/block')->setBlockId('amaze_empty_category')->toHtml();
 } else { ?>
<p class="note-msg"><?php echo $this->__('There are no products matching the selection.') ?></p>
<?php } ?>
<?php else: ?>

<?php echo $this->getToolbarHtml() ?>
<!-- BEGIN CATEGORY PRODUCTS -->
<div class="category-products">
    <?php // List mode ?>
    <?php if($this->getMode()!='grid'): ?>
    <?php $_iterator = 0; ?>

    <ol class="products-list" id="products-list">
    <?php foreach ($_productCollection as $_product): ?>
        <li class="item<?php if(($i-1)%$_columnCount==0): ?> first<?php elseif($i%$_columnCount==0): ?> last<?php endif; ?>">
        <!-- BEGIN PRODUCT IMAGE -->
          <div class="product-image">
            <a href="<?php echo $_product->getProductUrl() ?>" title="<?php echo $this->stripTags($this->getImageLabel($_product, 'small_image'), null, true) ?>" class="">
              <img src="<?php echo $this->helper('catalog/image')->init($_product, 'small_image')->resize(230,279); ?>" class="small-image" alt="<?php echo $this->stripTags($this->getImageLabel($_product, 'small_image'), null, true) ?>" />             
            </a>
          </div> <!--product-image-->
          <!-- BEGIN PRODUCT SHOP -->
          <div class="product-shop">
            <h2 class="product-name">
                <?php $_productNameStripped = $this->stripTags($_product->getName(), null, true); ?>
                <a href="<?php echo $_product->getProductUrl() ?>" title="<?php echo $_productNameStripped; ?>"><?php echo $_helper->productAttribute($_product, $_product->getName() , 'name'); ?></a>
            </h2>
            
            <?php echo $this->getPriceHtml($_product, true) ?>
                 <?php  if($_product->getRatingSummary()): ?>
                        <?php echo $this->getReviewsSummaryHtml($_product, 'short') ?>
                 <?php else: ?>
                        <div class="ratings"><div class="rating-box"><div style="width:0%" class="rating"></div></div></div>
                 <?php  endif;  ?>
             
            <div class="desc std">
              <p><?php echo $_helper->productAttribute($_product, $_product->getShortDescription(), 'short_description') ?></p>
              <p><a href="<?php echo $_product->getProductUrl() ?>" title="<?php echo $_productNameStripped ?>" class="link-learn"><?php echo $this->__('Learn More') ?></a></p>
            </div> <!--desc std-->
            
            <!-- BEGIN ACTIONS -->
            <div class="actions"> 
            <?php if($_product->isSaleable()): ?>
                   <button type="button" title="<?php echo $this->__('Add to Cart') ?>" class="button btn-cart ajx-cart" onclick="setLocation('<?php echo $this->getAddToCartUrl($_product) ?>')"><span><?php echo $this->__('Add to Cart') ?></span></button>
              <?php else: ?>
                   <p class="availability out-of-stock"><span><?php echo $this->__('Out of stock') ?></span></p>
              <?php endif; ?>            
              <span class="add-to-links">
                <?php if ($this->helper('wishlist')->isAllow()) : ?>
                    <a href="<?php echo $this->helper('wishlist')->getAddUrl($_product) ?>" class="button link-wishlist" title="<?php echo $this->__('Add to wishlist');?>"><span><?php echo $this->__('Add to wishlist');?></span></a>
                <?php endif; ?>
                <?php if($_compareUrl=$this->getAddToCompareUrl($_product)): ?>
                    <span class="separator">|</span><a href="<?php echo $_compareUrl ?>" class="button link-compare" title="<?php echo $this->__('Add to compare');?>"><span><?php echo $this->__('Add to compare');?></span></a>
                <?php endif; ?>
              </span> <!--add-to-links-->
            </div> <!--actions-->
          </div> <!--product-shop-->
        </li>
    <?php endforeach; ?>
    </ol>

    <script type="text/javascript">decorateList('products-list', 'none-recursive')</script>

    <?php else: ?>

    <?php // Grid Mode ?>

    <?php $_collectionSize = $_productCollection->count() ?>
    <?php $_columnCount = $this->getColumnCount(); ?>
   

  <ul class="products-grid">       
    <?php $i=0; foreach ($_productCollection as $_product): ?>
        <?php if ($i++%$_columnCount==0): ?>

        <?php endif ?>
            <li class="item<?php if(($i-1)%$_columnCount==0): ?> first<?php elseif($i%$_columnCount==0): ?> last<?php endif; ?>">

   <div class="item-inner">
     <div class="product-block">
        <div class="product-image">
          <a href="<?php echo $_product->getProductUrl() ?>">
            <figure class="product-display">
          <?php echo $this->helper('amazesettings')->getLabel($_product);  ?>
          <img class="lazyOwl product-mainpic" src="<?php echo $this->helper('catalog/image')->init($_product, 'small_image')->resize(268,325) ?>" alt="<?php echo $this->htmlEscape($_product->getName()) ?>" />
          <img class="product-secondpic" src="<?php echo $this->helper('catalog/image')->init($_product, 'thumbnail')->resize(268,325) ?>" alt="<?php echo $this->htmlEscape($_product->getName()) ?>" />
            </figure>
          </a>
        </div> <!--product-image-->
        <div class="product-meta">
           <div class="product-action">
              <?php if($_product->isSaleable()): ?>
                <a href="<?php echo $this->getAddToCartUrl($_product) ?>" class="addcart"> <i class="icon-shopping-cart">&nbsp;</i> <?php echo $this->__('Add to Cart') ?></a>
              <?php else: ?>
                <p class="availability out-of-stock"><span><?php echo $this->__('Out of stock') ?></span></p>
              <?php endif; ?>
              <a href="<?php echo $this->helper('wishlist')->getAddUrl($_product) ?>" class="wishlist" title="<?php echo $this->__('Add to Wishlist');?>"><i class="icon-heart">&nbsp;</i></a>
              <?php if(Mage::app()->getStore()->getConfig('amazesettings/amazesettings_quickview/enable')==1){?>
                  <a data-fancybox-type="ajax" onclick="callQuickView('<?php echo Mage::getUrl('amazesettings/index/view/id/'.$_product->getId());?>');" title="<?php echo $this->__('Quick View') ?>" class="quickview"><i class="icon-zoom">&nbsp;</i></a>                    
              <?php }  ?>   
           </div> <!--product-action-->
        </div> <!--product-meta-->
     </div> <!--product-block-->

     <div class="item-info">
       <div class="info-inner">
          <div class="item-title">
            <a href="<?php echo $_product->getProductUrl() ?>" title="<?php echo $this->htmlEscape($_product->getName()) ?>">
                  <?php $prod_name = $this->htmlEscape($_product->getName()) ; 
                  if(strlen($prod_name) > 30) {echo substr($prod_name,0,30)."...";}else {echo $prod_name;}?>
            </a>
          </div> <!--item-title-->
          <div class="item-content">
            <div class="item-price">
              <?php echo $this->getPriceHtml($_product, true) ?>
            </div> <!--item-price-->
                 <?php  if($_product->getRatingSummary()): ?>
                        <?php echo $this->getReviewsSummaryHtml($_product, 'short') ?>
                 <?php else: ?>
                        <div class="rating"><div class="ratings"><div class="rating-box"><div style="width:0%" class="rating"></div></div></div></div>
                 <?php  endif; ?> 
          </div> <!--item-content-->
       </div> <!--info-inner-->
     </div> <!--item-info-->
   </div> <!--item-inner-->

            </li>

        <?php if ($i%$_columnCount==0 || $i==$_collectionSize): ?>

        <?php endif ?>
         
        <?php endforeach ?>
  </ul>        
        <script type="text/javascript">decorateGeneric($$('ul.products-grid'), ['odd','even','first','last'])</script>
    <?php endif; ?>
</div> <!--category-products-->

<!--div class="toolbar-bottom">
    <?php //echo $this->getToolbarHtml() ?>
</div-->

<?php endif; ?>

<div id="mgkquickview">
<div id="magikloading" style="display:none;text-align:center;margin-top:400px;"><img src="<?php echo $this->getSkinUrl('images/mgkloading.gif');?>" alt="loading">
</div></div>
<script type="text/javascript">
function callQuickView(qurl) { 
    jQuery('#mgkquickview').show();
    jQuery('#magikloading').show();
    jQuery.get(qurl, function(data) {
      jQuery.fancybox(data);
      jQuery('#magikloading').hide();
jQuery('#mgkquickview').hide();
    });
 }
 
</script>