<?php
/**
 * aheadWorks Co.
 *
 * 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://ecommerce.aheadworks.com/LICENSE-M1.txt
 *
 * @category   AW
 * @package    AW_Mobile
 * @copyright  Copyright (c) 2010-2011 aheadWorks Co. (http://www.aheadworks.com)
 * @license    http://ecommerce.aheadworks.com/LICENSE-M1.txt
 */
?>
<?php
/**
 * Product list template
 *
 * @see Mage_Catalog_Block_Product_List
 */
?>
<?php $_productCollection=$this->getLoadedProductCollection() ?>
<?php if(!$_productCollection->count()): ?>
<div class="note-msg">
    <?php echo $this->__('There are no products matching the selection.') ?>
</div>
<?php else: ?>
<?php // List mode ?>
<?php $_iterator = 0; ?>
<div class="listing-type-list catalog-listing">
<ul class="c-list" id="c-list">
<?php foreach ($_productCollection as $_product): ?>
    <li>
        <div class="col2-alt-set" onclick="document.location = '<?php echo $_product->getProductUrl() ?>'; return false;">
            <div class="col-1">
                <?php // Product Image ?>
                <div class="product-image">
                        <img src="<?php echo $this->helper('catalog/image')->init($_product, 'small_image')->resize(65, 65); ?>" width="65" height="65" alt="<?php echo $this->helper('awmobile')->stripTags($this->getImageLabel($_product, 'small_image'), null, true) ?>" title="<?php echo $this->helper('awmobile')->stripTags($this->getImageLabel($_product, 'small_image'), null, true) ?>" />
                </div>
            </div>
            <div class="col-2 aranged">
                <?php // Product description ?>
                <div class="product-shop">
                    <?php $simplePricesTax = ($this->helper('tax')->displayPriceIncludingTax() || $this->helper('tax')->displayBothPrices()); ?>
                    <?php $_minimalPriceValue = $_product->getMinimalPrice() ?>
                    <?php $_minimalPrice = $this->helper('tax')->getPrice($_product, $_minimalPriceValue, $simplePricesTax) ?>
                    <a href="<?php echo $_product->getProductUrl() ?>" title="<?php echo $this->helper('awmobile')->stripTags($_product->getName(), null, true) ?>"><?php echo $this->helper('catalog/output')->productAttribute($_product, $_product->getName(), 'name') ?></a>
                    <?php
                    if ($_product->getTypeId() == 'bundle'){
                        list($_minimalPrice, $_maximalPrice) = $_product->getPriceModel()->getPrices($_product);
                        $_price = $_minimalPrice;
                    } elseif ($_product->getTypeId() == 'grouped') {     
                        $_exclTax = $this->helper('tax')->getPrice($_product, $_minimalPriceValue, $includingTax = null);
                        $_inclTax = $this->helper('tax')->getPrice($_product, $_minimalPriceValue, $includingTax = true);                        
                        $_price = $_inclTax;
                        if (!$this->helper('tax')->displayPriceIncludingTax()) {
                            $_price = $_exclTax;
                        }                        
                    } else {
                        $_price = $_product->getFinalPrice();
                    } ?>
                    <span class="product-price"><?php echo Mage::app()->getStore()->convertPrice( $_price, true ); ?></span>
                </div>
                <div class="description vert">
                    <?php $_descr = $this->helper('catalog/output')->productAttribute($_product, $_product->getShortDescription(), 'short_description');
                        if (strlen($_descr) > 77){
                            $_descr = substr($_descr, 0, 77)."...";
                        }
                        echo $this->helper('awmobile')->stripTags($_descr); ?>
                </div>
                <div class="description hor">
                    <?php $_descr = $this->helper('catalog/output')->productAttribute($_product, $_product->getShortDescription(), 'short_description');
                        if (strlen($_descr) > 122){
                            $_descr = substr($_descr, 0, 122)."...";
                        }
                        echo $this->helper('awmobile')->stripTags($_descr); ?>
                </div>
            </div>
            <div class="clear"></div>
    </div>
</li>
<?php endforeach; ?>
</ul>
<script type="text/javascript">
    decorateList('c-list', 'none-recursive');
    
    /* Redrawing of catalog list */
    var redrawList = function(){
        $j('ul.c-list div.description').each(function(index, element){
            var targetNode = $j(element.parentNode);
            var screenW = $j(element.parentNode.parentNode).width();
            targetNode.width(screenW - 122);
        });        
    };
    redrawList();
    $j(document).ready(function(){
        $j(document).bind('checkorientationchange', function(){
            redrawList();
        });
    });
    
</script>
</div>

<?php echo $this->getToolbarHtml() ?>
<?php endif; ?>
