<?php
/**
 * Maho
 *
 * @category    design
 * @package     rwd_default
 * @copyright   Copyright (c) 2006-2020 Magento, Inc. (https://magento.com)
 * @copyright   Copyright (c) 2022-2024 The OpenMage Contributors (https://openmage.org)
 * @copyright   Copyright (c) 2024 Maho (https://mahocommerce.com)
 * @license     https://opensource.org/licenses/afl-3.0.php  Academic Free License (AFL 3.0)
 */

/** @var Mage_Checkout_Block_Onepage_Payment $this */
?>
<script type="text/javascript">
    var quoteBaseGrandTotal = <?= (float)$this->getQuoteBaseGrandTotal() ?>;
    var checkQuoteBaseGrandTotal = quoteBaseGrandTotal;
    var quoteGrandTotalClean = quoteBaseGrandTotal;
    var payment = new Payment('co-payment-form', '<?= $this->getUrl('checkout/onepage/savePayment') ?>');
    var lastPrice;
</script>
<form action="" id="co-payment-form">
    <div class="fieldset">
        <?= $this->getChildChildHtml('methods_additional', '', true, true) ?>
        <?= $this->getChildHtml('methods') ?>
    </div>
    <?= $this->getBlockHtml('formkey') ?>
</form>
<div class="tool-tip" id="payment-tool-tip" style="display:none;">
    <div class="btn-close"><a href="#" id="payment-tool-tip-close" title="<?= Mage::helper('core')->quoteEscape($this->__('Close')) ?>"><?= $this->__('Close') ?></a></div>
    <div class="tool-tip-content"><img src="<?= $this->getSkinUrl('images/cvv.gif') ?>" alt="<?= Mage::helper('core')->quoteEscape($this->__('Card Verification Number Visual Reference')) ?>" title="<?= Mage::helper('core')->quoteEscape($this->__('Card Verification Number Visual Reference')) ?>" /></div>
</div>
<?= $this->getChildChildHtml('additional') ?>
<div class="buttons-set" id="payment-buttons-container">
    <?php // Moved to CC form ?>
    <button type="button" class="button" onclick="payment.save()"><?= $this->__('Continue') ?></button>
    <span class="please-wait" id="payment-please-wait" style="display:none;">
        <img src="<?= $this->getSkinUrl('images/loading.svg') ?>" alt="<?= Mage::helper('core')->quoteEscape($this->__('Loading next step...')) ?>" title="<?= Mage::helper('core')->quoteEscape($this->__('Loading next step...')) ?>" class="v-middle" /> <?= $this->__('Loading next step...') ?>
    </span>
</div>
<script type="text/javascript">
    payment.currentMethod = "<?= $this->getChild('methods')->getSelectedMethodCode() ?>";
    function toggleToolTip(event) {
        let paymentToolTip = document.getElementById('payment-tool-tip');
        if (paymentToolTip) {
            paymentToolTip.style = {
                top: (event.clientY-560) + 'px'
            }
            paymentToolTip.classList.toggle('hidden');
        }
        event.preventDefault();
    }
    let paymentToolTipClose = document.getElementById('payment-tool-tip-close');
    if (paymentToolTipClose){
        paymentToolTipClose.addEventListener('click', toggleToolTip);
    }
</script>
