<?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
/**
 * Bachup of bundle display on product view
 */
?>
<?php
/**
 * Product view template
 *
 * @see Mage_Catalog_Block_Product_View
 */
?>
<?php echo $this->getMessagesBlock()->getGroupedHtml() ?>
<?php $_product=$this->getProduct() ?>
<div class="product-info-box">
    <div class="product-essential">
        <div class="product-img-box">
            <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 Out') ?>" 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 if ($this->getGalleryImages() && $this->getGalleryImages()->getSize()): ?>
            <div class="more-views">
                <h4><?php echo $this->__('More Views') ?></h4>
                <ul>
                <?php foreach ($this->getGalleryImages() as $_image): ?>
                    <li>
                        <a href="#" onclick="popWin('<?php echo $this->getGalleryUrl($_image) ?>', 'gallery', 'scrollbars=no,width=300,height=300');return false;">
                            <img src="<?php echo $_image->setType(2)->getSourceUrl(); ?>" width="68" alt="" />
                        </a>
                    </li>
                <?php endforeach; ?>
                </ul>
            </div>
       <?php endif; ?>
       </div>
       <div class="product-shop">
       <h3 class="product-name"><?php echo $this->htmlEscape($_product->getName()) ?></h3>
            <?php echo $this->getHelper('review/helper')->getSummaryHtml($_product, null, 1) ?>
            <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() ?>" />
            <input type="hidden" name="related_product" id="related-products-field" value="" />
            </fieldset>

            <?php if($_product->isBundle()): ?>
                <div class="product-attributes">
                <?php if($_product->isAvailableBundle()): ?>
                    <table cellspacing="0" id="bundle-price-table">
                    <?php foreach($_product->getBundleOptionCollection() as $_bundleOption): ?>
                        <tr>
                            <td class="label"><?php echo $_bundleOption->getLabel() ?>:</td>
                            <td>
                            <?php if(sizeof($_bundleOption->getLinkCollection()->getItems())>1): ?>
                                <select name="bundle_option[<?php echo $_bundleOption->getId() ?>]">
                                    <?php foreach ($_bundleOption->getLinkCollection() as $_option): ?>
                                    <option value="<?php echo $_option->getProductId() ?>"><?php echo $_option->getName() ?></option>
                                    <?php endforeach; ?>
                                </select>
                            <?php elseif(sizeof($_bundleOption->getLinkCollection()->getItems())==1): ?>
                                <?php $_option=$_bundleOption->getLinkCollection()->getFirstItem() ?>
                                <input type="hidden" name="bundle_option[<?php echo $_bundleOption->getId() ?>]" value="<?php echo $_option->getProductId() ?>" /><?php echo $_option->getName() ?>
                            <?php else: ?>
                                <?php echo $this->__('Out of Stock') ?>
                            <?php endif; ?>
                            </td>
                        </tr>
                    <?php endforeach; ?>
                    </table>
                    <script type="text/javascript">decorateTable('bundle-price-table')</script>
                <?php else: ?>
                    <p><?php echo $this->__('This bundle is out of stock.') ?></p>
                <?php endif; ?>
                </div>

            <?php elseif($_product->isSuperConfig()): ?>
                <?php echo $this->getChildHtml('super_config') ?>
            <?php endif; ?>

            <?php if($_product->getTierPriceCount()>1): ?>
                <div class="product-pricing">
                    <ul class="bare">
                    <?php foreach($_prices=$_product->getFormatedTierPrice() as $_price): ?>
                        <li><?php echo $this->__('Buy %s for %s each', $_price['price_qty'], $_price['price']) ?></li>
                    <?php endforeach ?>
                    </ul>
                </div>
            <?php endif; ?>

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

            <?php if(!$_product->isSuperGroup()): ?>
                <?php if(!$_product->isBundle() || $_product->isAvailableBundle()): ?>
                    <p><small><?php echo $this->__('Availability: In stock. Ships within 24 hours.') ?></small></p>
                    <?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 $this->getAddToWishlistUrl($_product) ?>"><?php echo $this->__('Add to Wishlist') ?></a><br/>
                        <?php endif; ?>
                        <a href="<?php echo $this->getAddToCompareUrl($_product) ?>"><?php echo $this->__('Add to Compare') ?></a>
                    </div>
                <?php else: ?>
                    <p><small><?php echo $this->__('Availability: Out of stock.') ?></small></p>
                    <p>
                        <?php if ($this->helper('wishlist')->isAllow()) : ?>
                        <a href="<?php echo $this->getAddToWishlistUrl($_product) ?>"><?php echo $this->__('Add to Wishlist') ?></a> <br/>
                        <?php endif; ?>
                        <a href="<?php echo $this->getAddToCompareUrl($_product) ?>"><?php echo $this->__('Add to Compare') ?></a>
                    </p>
                <?php endif; ?>
            <?php else: ?>
                <p><small><?php echo $this->__('Availability: In stock. Ships within 24 hours.') ?></small></p>
                <button type="button" class="form-button" onclick="productAddToCartForm.submit()"><span><?php echo $this->__('Add to Cart') ?></span></button> <strong><?php echo $this->__('OR') ?></strong>
                &nbsp;&nbsp;
                <?php if ($this->helper('wishlist')->isAllow()) : ?>
                <a href="<?php echo $this->getAddToWishlistUrl($_product) ?>"><?php echo $this->__('Add to Wishlist') ?></a>
                <span class="pipe">|</span>
                <?php endif; ?>
                <a href="<?php echo $this->getAddToCompareUrl($_product) ?>"><?php echo $this->__('Add to Compare') ?></a>
            <?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>
            <h4><?php echo $this->__('Product Description') ?></h4>
            <div class="product-specs"><?php echo $this->htmlEscape($_product->getDescription()) ?></div>
        </div>
    </div>

    <div class="product-collateral">
        <?php echo $this->getChildHtml('upsell_products') ?>
        <?php if($_additional = $this->getAdditionalData()): ?>
        <div class="collateral-box attribute-specs">
            <div class="head">
                <h4><?php echo $this->__('Product Attribute Specs') ?></h4>
            </div>
            <table cellspacing="0" class="data-table" id="product-attribute-specs-table">
            <?php foreach ($_additional as $_data): ?>
            <tr>
                <td class="label"><?php echo $_data['label'] ?></td>
                <td class="data"><?php echo $_data['value'] ?></td>
            </tr>
            <?php endforeach; ?>
            </table>
            <script type="text/javascript">decorateTable('product-attribute-specs-table')</script>
        </div>
        <?php endif; ?>
        <div class="collateral-box" id="customer-reviews">
          <?php echo $this->getChildHtml('product_additional_data') ?>
        </div>
    </div>
</div>
