<?php
/**
 * Avalanche for Magento 1.8+
 * Designed by Fast Division (http://fastdivision.com)
 *
 * 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://fastdivision.com/legal/license.txt
 *
 * @author     Fast Division
 * @version    1.5.0
 * @copyright  Copyright 2013 Fast Division
 * @license    http://fastdivision.com/legal/license.txt
 */
?>
<div class="grid_12 white-box">
    <h1 style="margin: 0">Select Payment Method</h1>
    <div class="multiple-checkout">
        <?php echo $this->getMessagesBlock()->getGroupedHtml() ?>
        <script src="<?php echo Mage::getBaseUrl('js') ?>varien/payment.js" type="text/javascript"></script>
        <form action="<?php echo $this->getPostActionUrl() ?>" method="post" id="multishipping-billing-form">
            <div class="clearfix">
                <h3><?php echo $this->__('Billing Address') ?> <span class="separator">|</span> <a href="<?php echo $this->getSelectAddressUrl() ?>"><?php echo $this->__('Change') ?></a></h3>
                <div class="box">
                    <div class="box-content">
                        <?php $_address=$this->getAddress() ?>
                        <address><?php echo $_address->format('html') ?></address>
                    </div>
                </div>

                <h3><?php echo $this->__('Payment Method') ?></h3>
                <div class="box">
                    <div class="box-content">
                        <div class="tool-tip" id="payment-tool-tip" style="display:none;">
                            <div class="btn-close"><a href="#" id="payment-tool-tip-close" title="<?php echo $this->__('Close') ?>"><?php echo $this->__('Close') ?></a></div>
                            <div class="tool-tip-content"><img src="<?php echo $this->getSkinUrl('images/cvv.gif') ?>" alt="<?php echo $this->__('Card Verification Number Visual Reference') ?>" title="<?php echo $this->__('Card Verification Number Visual Reference') ?>" /></div>
                        </div>
                        <!-- Payment methods forms list -->
                        <dl class="sp-methods">
                        <?php
                            $_methods       = $this->getMethods();
                            $_methodsCount  = count($_methods);
                        ?>
                        <?php foreach ($_methods as $_method): $_code = $_method->getCode() ?>
                            <dt>
                                <?php if ($_methodsCount > 1): ?>
                                <input type="radio" id="p_method_<?php echo $_code ?>" value="<?php echo $_code ?>" name="payment[method]" title="<?php echo $this->escapeHtml($_method->getTitle()) ?>" onclick="payment.switchMethod('<?php echo $_code ?>')"<?php if($this->getSelectedMethodCode()==$_code): ?> checked="checked"<?php endif; ?> class="radio" />
                                <?php else :?>
                                <span class="no-display"><input type="radio" id="p_method_<?php echo $_code ?>" value="<?php echo $_code ?>" name="payment[method]" checked="checked" class="radio" /></span>
                                <?php endif;?>
                                <label for="p_method_<?php echo $_code ?>"><?php echo $_method->getTitle() ?></label>
                            </dt>
                            <?php if($html = $this->getChildHtml('payment.method.'.$_code)) : ?>
                            <dd>
                                <?php echo $html; ?>
                            </dd>
                            <?php endif; ?>
                        <?php endforeach; ?>
                        </dl>
                        <?php echo $this->getChildHtml('checkout_billing_items') ?>
                    </div>
                </div>
            </div>
            <div class="box-action box-multishipping clearfix">
                <p class="back-link"><a href="<?php echo $this->getBackUrl() ?>"><small>&laquo; </small><?php echo $this->__('Back to Shipping Information') ?></a></p>
                <button type="submit" title="<?php echo $this->__('Continue to Review Your Order') ?>" class="action-button"><span><?php echo $this->__('Continue to Review Your Order') ?></span></button>
            </div>
        </form>
        <script type="text/javascript">
        //<![CDATA[
            var payment = new paymentForm('multishipping-billing-form');
            function toggleToolTip(event){
                if($('payment-tool-tip')){
                    /*$('payment-tool-tip').setStyle({
                        top: (Event.pointerY(event)-510)+'px',
                        left: (Event.pointerX(event)-800)+'px'
                    })*/
                    $('payment-tool-tip').toggle();
                }
                Event.stop(event);
            }
            if($('payment-tool-tip-close')){
                Event.observe($('payment-tool-tip-close'), 'click', toggleToolTip);
            }
            $$('.cvv-what-is-this').each(function(element){
                Event.observe(element, 'click', toggleToolTip);
            });
        //]]>
        </script>
    </div>
</div>
