<?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 echo $this->getMessagesBlock()->getGroupedHtml() ?>
<?php $product=$_product=$this->getProduct() ?>
<div class="product-info-box">
    <div class="product-essential">
        <div class="product-img-box">
            <?php if ($_product->getImage() != 'no_selection' && $_product->getImage()): ?>
            <p class="product-image-zoom">
                <img id="image" src="<?php echo $this->helper('catalog/image')->init($_product, 'image'); ?>" alt="<?php echo $this->htmlEscape($_product->getName()) ?>" />
            </p>
            <div class="image-zoom" id="track_outer">
                <img id="zoom_out" src="<?php echo $this->getSkinUrl('images/slider_btn_zoom_out.gif') ?>" alt="<?php echo $this->__('Zoom Out') ?>" class="btn-zoom-out" />
                <div id="track">
                    <div id="handle"></div>
                </div>
                <img id="zoom_in" src="<?php echo $this->getSkinUrl('images/slider_btn_zoom_in.gif') ?>" alt="<?php echo $this->__('Zoom In') ?>" class="btn-zoom-in" />
            </div>
            <script type="text/javascript">
                Event.observe(window, 'load', function() {
                    product_zoom = new Product.Zoom('image', 'track', 'handle', 'zoom_in', 'zoom_out');
                });
            </script>
            <?php else: ?>
            <img src="<?php echo $this->helper('catalog/image')->init($_product, 'image')->resize(265); ?>" alt="<?php echo $this->htmlEscape($_product->getName()) ?>" />
            <?php endif; ?>
        </div>

        <div class="product-shop">
            <h3 class="product-name"><?php echo $this->htmlEscape($product->getName()) ?></h3>
        <?php echo $this->getChildHtml('rating') ?>
        <?php if( $reviewCount ): ?>
            <a href="#customer-reviews" class="no-wrap"><small><?php echo $this->__('%s Review(s)', $reviewCount) ?></small></a>
        <?php endif; ?>

        <form action="<?php echo $this->getUrl('checkout/cart/add') ?>" method="post" id="product_addtocart_form">
        <fieldset>
        <input type="hidden" name="product" value="<?php echo $product->getId() ?>" />
        </fieldset>

        <?php if($product->isSuperConfig()): ?>
        <?php echo $this->getChildHtml('super_config') ?>
        <?php endif; ?>
        <?php $_tierPrices = $this->getTierPrices($product) ?>
        <?php if(count($_tierPrices)>0): ?>
            <div class="product-pricing">
                <ul class="bare">
                <?php foreach($_tierPrices as $_price): ?>
                    <li><?php echo $this->__('Buy %s for %s', $_price['price_qty'], $_price['formated_price']) ?></li>
                <?php endforeach ?>
                </ul>
            </div>
        <?php endif; ?>

        <?php if($product->isGrouped()): ?>
            <?php echo $this->getChildHtml('super_group') ?>
        <?php endif; ?>

        <?php if(!$product->isGrouped()): ?>
            <?php if($product->isSaleable()): ?>
            <p><small><?php echo $this->__('Availability: In stock.') ?></small></p>
            <?php else: ?>
            <p><small><?php echo $this->__('Availability: Out of stock.') ?></small><br /></p>
            <?php endif; ?>

            <?php if($product->isSaleable()): ?>
            <?php echo $this->helper('catalog/product')->getPriceHtml($product) ?>
            <fieldset class="add-to-cart-box">
                <legend><?php echo $this->__('Add Items to Cart') ?></legend>
                <span class="qty-box"><label for="qty"><?php echo $this->__('Qty') ?>:</label> <input name="qty" type="text" class="input-text qty" id="qty" /></span>
                <button class="form-button" onclick="productAddToCartForm.submit()"><span><?php echo $this->__('Add to Cart') ?></span></button> <strong><?php echo $this->__('OR') ?></strong>
            </fieldset>

            <div class="add-to-box">
                <?php if ($this->helper('wishlist')->isAllow()) : ?>
                <a href="<?php echo $wishlistLink ?>"><?php echo $this->__('Add to Wishlist') ?></a><br />
                <?php endif; ?>

                <?php if($_compareUrl=$this->helper('catalog/product_compare')->getAddUrl($product)): ?>
                <a href="<?php echo $_compareUrl ?>"><?php echo $this->__('Add to Compare') ?></a>
                <?php endif; ?>
            </div>

            <?php else: ?>
                <?php if ($this->helper('wishlist')->isAllow()) : ?>
                <p><a href="<?php echo $wishlistLink ?>"><?php echo $this->__('Add to Wishlist') ?></a><br />
                <?php endif; ?>

                <?php if($_compareUrl=$this->helper('catalog/product_compare')->getAddUrl($product)): ?>
                <a href="<?php echo $_compareUrl ?>"><?php echo $this->__('Add to Compare') ?></a>
                <?php endif; ?></p>

            <?php endif; ?>
        <?php else: ?>
            <button class="form-button" onclick="productAddToCartForm.submit()"><span><?php echo $this->__('Add to Cart') ?></span></button> <strong><?php echo $this->__('OR') ?></strong>

        <?php if ($this->helper('wishlist')->isAllow()) : ?>
            &nbsp;&nbsp;<a href="<?php echo $wishlistLink ?>"><?php echo $this->__('Add to Wishlist') ?></a>
        <?php endif; ?>

        <?php if($_compareUrl=$this->helper('catalog/product_compare')->getAddUrl($product)): ?>
            <span class="pipe">|</span><a href="<?php echo $_compareUrl ?>"><?php echo $this->__('Add to Compare') ?></a>
        <?php endif; ?>

        <?php endif; ?>
        </form>
        <script type="text/javascript">
            var productAddToCartForm = new VarienForm('product_addtocart_form');
            productAddToCartForm.submit = function() {
                if(this.validator.validate()) {
                    this.form.submit();
                }
            }.bind(productAddToCartForm);
        </script>
        <div class="clear"></div>
        <div class="divider"></div>

        <p><a href="<?php echo $product->getProductUrl() ?>">&laquo; <?php echo $this->__('Back to Main Product Info') ?></a></p>

        </div>
        </div>

        <div class="product-collateral">
    <?php if( $this->getCollection() && $this->count()): ?>
        <div class="collateral-box dedicated-review-box" id="customer-reviews">
            <div class="head">
                <h4><?php echo $this->__('Customer Reviews') ?></h4>
            </div>
        <?php echo $this->getToolbarHtml() ?>
            <ol style="margin-top:15px;">
        <?php foreach( $this->getCollection()->getItems() as $_review ): ?>
                <li>
                    <a href="<?php echo $this->getReviewUrl($_review->getId()) ?>"><strong><?php echo $this->htmlEscape($_review->getTitle()) ?></strong></a> <?php echo $this->__('Review by %s', $this->htmlEscape($_review->getNickname())) ?>
                    <table class="ratings-list" cellspacing="0">
                        <tbody>
                        <?php foreach( $_review->getRatingVotes() as $_vote ): ?>
                        <tr>
                            <td class="label"><strong><?php echo $this->escapeHtml($_vote->getRatingCode()) ?></strong></td>
                            <td>
                                <div class="rating-box">
                                    <div class="rating" style="width: <?php echo $_vote->getPercent() ?>%;"></div>
                                </div>
                            </td>
                        </tr>
                        <?php endforeach; ?>
                        </tbody>
                    </table>
                    <p><?php echo nl2br($this->htmlEscape($_review->getDetail())) ?> <?php echo $this->__('(Posted on %s)', $this->formatDate($_review->getCreatedAt()), 'long') ?></p>
                </li>
        <?php endforeach; ?>
            </ol>
        </div>
        <?php echo $this->getToolbarHtml() ?>
    <?php else: ?>
    <?php endif; ?>
    <br/>
    <?php echo $this->getChildHtml('reviewForm') ?>
    </div>
</div>
