<?php
/* @var $this Mage_Catalog_Block_Product_Compare_List */
?>
<?php $_total=$this->getItems()->getSize() ?>
<?php if($_total): ?>
    <table class="data-table compare-table for-desktop" id="product_comparison">
    <?php $_i=0 ?>
    <?php foreach($this->getItems() as $_item): ?>
        <?php if($_i++%10==0): ?>
            <col width="23%" />
        <?php endif; ?>
            <col width="<?php echo floor(77/$_total); ?>%" />
    <?php endforeach; ?>
        <tbody>
            <tr class="product-img-row">
            <?php $_i=0 ?>
            <?php foreach($this->getItems() as $_item): ?>
                <?php if($_i++%10==0): ?>
                <th><?php echo $this->__('Product') ?></th>
                <?php endif; ?>
                <td>
                    <a href="<?php echo $this->helper('catalog/product_compare')->getRemoveUrl($_item) ?>" class="btn-remove2" title="<?php echo $this->__('Remove This Item') ?>"><i class="icon-cancel"></i></a>
                    <a class="product-image" href="#" onclick="setLocation('<?php echo $this->getProductUrl($_item) ?>')" title="<?php echo $this->stripTags($_item->getName(), null, true) ?>"><img src="<?php echo $this->helper('catalog/image')->init($_item, 'small_image')->constrainOnly(FALSE)->keepAspectRatio(TRUE)->keepFrame(FALSE)->resize(350); ?>" alt="<?php echo $this->stripTags($_item->getName(), null, true) ?>" /></a>
                    <h2 class="product-name"><a href="#" onclick="setLocation('<?php echo $this->getProductUrl($_item) ?>')" title="<?php echo $this->stripTags($_item->getName(), null, true) ?>"><?php echo $this->helper('catalog/output')->productAttribute($_item, $_item->getName(), 'name') ?></a></h2>
                </td>
            <?php endforeach; ?>
            </tr>
            <tr class="product-price-row">
            <?php $_i=0 ?>
            <?php foreach($this->getItems() as $_item): ?>
                <?php if($_i++%10==0): ?>
                <th><?php echo $this->__('Price') ?></th>
                <?php endif; ?>
                <td>
                    <?php echo $this->getPriceHtml($_item, true, '-compare-list-top') ?>
                </td>
            <?php endforeach; ?>
            </tr>
            <tr class="product-availability-row">
            <?php $_i=0 ?>
            <?php foreach($this->getItems() as $_item): ?>
                <?php if($_i++%10==0): ?>
                <th><?php echo $this->__('Availability') ?></th>
                <?php endif; ?>
                <td>
                <?php if ($_item->isAvailable()): ?>
                    <p class="availability in-stock"><span><?php echo $this->__('In Stock') ?></span></p>
                <?php else: ?>
                    <p class="availability out-of-stock"><span><?php echo $this->__('Out of Stock') ?></span></p>
                <?php endif; ?>
                </td>
            <?php endforeach; ?>
            </tr>
            <tr class="product-review-row">
            <?php $_i=0 ?>
            <?php foreach($this->getItems() as $_item): ?>
                <?php if($_i++%10==0): ?>
                <th><?php echo $this->__('Rating') ?></th>
                <?php endif; ?>
                <td>
                    <?php echo $this->getReviewsSummaryHtml($_item, 'short') ?>
                </td>
            <?php endforeach; ?>
            </tr>
        </tbody>
        <tbody>
        <?php foreach ($this->getAttributes() as $_attribute): ?>
            <tr>
                <?php $_i=0 ?>
                <?php foreach($this->getItems() as $_item): ?>
                <?php if($_i++%10==0): ?>
                <th><span class="nobr"><?php echo $_attribute->getStoreLabel() ?></span></th>
                <?php endif; ?>
                <td>
                    <?php switch ($_attribute->getAttributeCode()) {
                        case "price": ?>
                            <?php echo $this->getPriceHtml($_item, true, '-compare-list-' . $_attribute->getCode()) ?>
                            <?php break;
                        case "small_image": ?>
                            <img src="<?php echo $this->helper('catalog/image')->init($_item, 'small_image')->resize(125, 125); ?>" width="125" height="125" alt="<?php echo $this->htmlEscape($_item->getName()) ?>" title="<?php echo $this->htmlEscape($_item->getName()) ?>" />
                            <?php break;
                        case "date":
                              echo substr($this->getProductAttributeValue($_item, $_attribute),0,10);
                              break;
                        default: ?>
                            <div class="std">
                                <?php echo $this->helper('catalog/output')->productAttribute($_item, $this->getProductAttributeValue($_item, $_attribute), $_attribute->getAttributeCode()) ?>
                            </div>
                            <?php break;
                    } ?>
                </td>
                <?php endforeach; ?>
            </tr>
        <?php endforeach; ?>
        </tbody>
        <tbody>
                <tr class="add-to-row">
                <?php $_i=0 ?>
                <?php foreach($this->getItems() as $_item): ?>
                <?php if($_i++%10==0): ?>
                <th>&nbsp;</th>
                <?php endif; ?>
                <td>
                    <?php if($_item->isSaleable()): ?>
                        <p><button type="button" title="<?php echo $this->__('Add to Cart') ?>" class="button btn-cart" onclick="setLocation('<?php echo $this->helper('catalog/product_compare')->getAddToCartUrl($_item) ?>')"><span><span><?php echo $this->__('Add to Cart') ?></span></span></button></p>
                    <?php else: ?>
                        <p class="availability out-of-stock"><span><?php echo $this->__('Out of stock') ?></span></p>
                    <?php endif; ?>
                </td>
                <?php endforeach; ?>
            </tr>
        </tbody>
    </table>
    <script type="text/javascript">
        decorateTable('product_comparison');
    </script>
    <table class="data-table compare-table for-mobile" id="product_comparison_mobile">
    <?php if($_total < 2): ?>
            <col width="100%" />
    <?php else: ?>
            <col width="50%" />
            <col width="50%" />
    <?php endif; ?>
        <tbody>
            <tr>
                <th <?php echo ($_total>1)?'colspan="2"':''?>><?php echo $this->__('Product') ?></th>
            </tr>
            <?php $_i=0; ?>
            <?php foreach($this->getItems() as $_item): ?>
            <?php $_i++; if($_i%2==1): ?>
            <tr class="product-img-row">
            <?php endif; ?>
                <td>
                    <a href="<?php echo $this->helper('catalog/product_compare')->getRemoveUrl($_item) ?>" class="btn-remove2" title="<?php echo $this->__('Remove This Item') ?>"><i class="icon-cancel"></i></a>
                    <a class="product-image" href="#" onclick="setLocation('<?php echo $this->getProductUrl($_item) ?>')" title="<?php echo $this->stripTags($_item->getName(), null, true) ?>"><img src="<?php echo $this->helper('catalog/image')->init($_item, 'small_image')->constrainOnly(FALSE)->keepAspectRatio(TRUE)->keepFrame(FALSE)->resize(350); ?>" alt="<?php echo $this->stripTags($_item->getName(), null, true) ?>" /></a>
                    <h2 class="product-name"><a href="#" onclick="setLocation('<?php echo $this->getProductUrl($_item) ?>')" title="<?php echo $this->stripTags($_item->getName(), null, true) ?>"><?php echo $this->helper('catalog/output')->productAttribute($_item, $_item->getName(), 'name') ?></a></h2>
                </td>
            <?php if($_i%2==0 || $_i==$_total): ?>
            </tr>
            <?php endif; ?>
            <?php endforeach; ?>
            <tr>
                <th <?php echo ($_total>1)?'colspan="2"':''?>><?php echo $this->__('Price') ?></th>
            </tr>
            <?php $_i=0; ?>
            <?php foreach($this->getItems() as $_item): ?>
            <?php $_i++; if($_i%2==1): ?>
            <tr class="product-price-row">
            <?php endif; ?>
                <td>
                    <?php echo $this->getPriceHtml($_item, true, '-compare-list-top') ?>
                </td>
            <?php if($_i%2==0 || $_i==$_total): ?>
            </tr>
            <?php endif; ?>
            <?php endforeach; ?>
            <tr>
                <th <?php echo ($_total>1)?'colspan="2"':''?>><?php echo $this->__('Availability') ?></th>
            </tr>
            <?php $_i=0; ?>
            <?php foreach($this->getItems() as $_item): ?>
            <?php $_i++; if($_i%2==1): ?>
            <tr class="product-availability-row">
            <?php endif; ?>
                <td>
                <?php if ($_item->isAvailable()): ?>
                    <p class="availability in-stock"><span><?php echo $this->__('In Stock') ?></span></p>
                <?php else: ?>
                    <p class="availability out-of-stock"><span><?php echo $this->__('Out of Stock') ?></span></p>
                <?php endif; ?>
                </td>
            <?php if($_i%2==0 || $_i==$_total): ?>
            </tr>
            <?php endif; ?>
            <?php endforeach; ?>
            <tr>
                <th <?php echo ($_total>1)?'colspan="2"':''?>><?php echo $this->__('Rating') ?></th>
            </tr>
            <?php $_i=0; ?>
            <?php foreach($this->getItems() as $_item): ?>
            <?php $_i++; if($_i%2==1): ?>
            <tr class="product-review-row">
            <?php endif; ?>
                <td>
                    <?php echo $this->getReviewsSummaryHtml($_item, 'short') ?>
                </td>
            <?php if($_i%2==0 || $_i==$_total): ?>
            </tr>
            <?php endif; ?>
            <?php endforeach; ?>
        </tbody>
        <tbody>
        <?php foreach ($this->getAttributes() as $_attribute): ?>
            <tr>
                <th <?php echo ($_total>1)?'colspan="2"':''?>><?php echo $_attribute->getStoreLabel() ?></th>
            </tr>
                <?php $_i=0; ?>
                <?php foreach($this->getItems() as $_item): ?>
            <?php $_i++; if($_i%2==1): ?>
            <tr>
            <?php endif; ?>
                <td>
                    <?php switch ($_attribute->getAttributeCode()) {
                        case "price": ?>
                            <?php echo $this->getPriceHtml($_item, true, '-compare-list-' . $_attribute->getCode()) ?>
                            <?php break;
                        case "small_image": ?>
                            <img src="<?php echo $this->helper('catalog/image')->init($_item, 'small_image')->resize(125, 125); ?>" width="125" height="125" alt="<?php echo $this->htmlEscape($_item->getName()) ?>" title="<?php echo $this->htmlEscape($_item->getName()) ?>" />
                            <?php break;
                        case "date":
                              echo substr($this->getProductAttributeValue($_item, $_attribute),0,10);
                              break;
                        default: ?>
                            <div class="std">
                                <?php echo $this->helper('catalog/output')->productAttribute($_item, $this->getProductAttributeValue($_item, $_attribute), $_attribute->getAttributeCode()) ?>
                            </div>
                            <?php break;
                    } ?>
                </td>
            <?php if($_i%2==0 || $_i==$_total): ?>
            </tr>
            <?php endif; ?>
                <?php endforeach; ?>
        <?php endforeach; ?>
        </tbody>
        <tbody>
            <tr>
                <th <?php echo ($_total>1)?'colspan="2"':''?>>&nbsp;</th>
            </tr>
                <?php $_i=0; ?>
                <?php foreach($this->getItems() as $_item): ?>
            <?php $_i++; if($_i%2==1): ?>
                <tr class="add-to-row">
            <?php endif; ?>
                <td>
                    <?php if($_item->isSaleable()): ?>
                        <p><button type="button" title="<?php echo $this->__('Add to Cart') ?>" class="button btn-cart" onclick="setLocation('<?php echo $this->helper('catalog/product_compare')->getAddToCartUrl($_item) ?>')"><span><span><?php echo $this->__('Add to Cart') ?></span></span></button></p>
                    <?php else: ?>
                        <p class="availability out-of-stock"><span><?php echo $this->__('Out of stock') ?></span></p>
                    <?php endif; ?>
                </td>
            <?php if($_i%2==0 || $_i==$_total): ?>
            </tr>
            <?php endif; ?>
                <?php endforeach; ?>
        </tbody>
    </table>
    <script type="text/javascript">
        decorateTable('product_comparison_mobile');
    </script>
<?php else: ?>
    <p class="note-msg"><?php echo $this->__('There are no products in my compare list.') ?></p>
<?php endif; ?>
