<?php if (Mage::getStoreConfig('roltasettings/roltasettings_products/related_product')): ?>

<?php if($this->getItems()->getSize()): ?>
<!-- BEGIN CATEGORY PRODUCTS -->
<div class="category-products">    
  
 <div id="block-related" class="related-product">
       <ul class="products-grid first odd">
        <?php foreach($this->getItems() as $_item): ?>
             <li class="item<?php if(($i-1)%$_columnCount==0): ?> first<?php elseif($i%$_columnCount==0): ?> last<?php endif; ?>">
            <a href="<?php echo $_item->getProductUrl() ?>" class="fancybox quick-view" id="fancybox358"><?php echo $this->__('Details');?></a>
              <a href="<?php echo $_item->getProductUrl() ?>" title="<?php echo $this->stripTags($this->getImageLabel($_item, 'small_image'), null, true) ?>" class="product-image">
                
                  <img src="<?php echo $this->helper('catalog/image')->init($_item, 'small_image'); ?>" class="small-image" alt="<?php echo $this->stripTags($this->getImageLabel($_item, 'small_image'), null, true) ?>" />                 
              </a>
              <!-- BEGIN PROD IMAGE DETAIL -->
              <div class="prod_image_detail">
                
                 <a class="product-name" href="<?php echo $_item->getProductUrl() ?>" title="<?php echo $this->stripTags($_item->getName(), null, true) ?>">
                    <?php $prod_name = $this->htmlEscape($_item->getName()) ; 
                      if(strlen($prod_name) > 20) {echo substr($prod_name,0,20)."...";}else {echo $prod_name;}?>
                 </a>                  
                 
                  
                  <?php echo $this->getReviewsSummaryHtml($_item) ?>
                 <?php echo $this->getPriceHtml($_item, true, '-related') ?>

                 <!-- BEGIN ACTIONS -->           
                 <div class="actions">
                   <?php if($_item->isSaleable()): ?>
                      <button type="button" title="<?php echo $this->__('Add to Cart') ?>" class="button btn-cart ajx-cart" onclick="setLocation('<?php echo $this->getAddToCartUrl($_item) ?>')"><span><span><?php echo $this->__('Add to Cart') ?></span></span></button>
                   <?php else: ?>
                      <p class="availability out-of-stock"><span><?php echo $this->__('Out of stock') ?></span></p>
                   <?php endif; ?>
                 </div> <!--actions-->
              </div> <!--prod_image_detail-->          
            </li>
        <?php endforeach; ?>        
        </ul>
        <script type="text/javascript">decorateList('block-related', 'none-recursive')</script>
  </div> <!--#block-related-->
</div> <!--category-products-->
   
    <script type="text/javascript">
    //<![CDATA[
    $$('.related-checkbox').each(function(elem){
        Event.observe(elem, 'click', addRelatedToProduct)
    });

    var relatedProductsCheckFlag = false;
    function selectAllRelated(txt){
        if (relatedProductsCheckFlag == false) {
            $$('.related-checkbox').each(function(elem){
                elem.checked = true;
            });
            relatedProductsCheckFlag = true;
            txt.innerHTML="<?php echo $this->__('unselect all') ?>";
        } else {
            $$('.related-checkbox').each(function(elem){
                elem.checked = false;
            });
            relatedProductsCheckFlag = false;
            txt.innerHTML="<?php echo $this->__('select all') ?>";
        }
        addRelatedToProduct();
    }

    function addRelatedToProduct(){
        var checkboxes = $$('.related-checkbox');
        var values = [];
        for(var i=0;i<checkboxes.length;i++){
            if(checkboxes[i].checked) values.push(checkboxes[i].value);
        }
        if($('related-products-field')){
            $('related-products-field').value = values.join(',');
        }
    }
    //]]>
    </script>
<?php endif; ?>  <!-- end related product -->

<?php endif; ?>