<?php

/*
 * Created by tpay.com
 */
?>

<style>
    <?php include_once dirname(__FILE__) . '/../_css/style.css'; ?>
</style>
<div class="insidebg" id="main-payment">
    <div id="kanaly_v">
        <select name="bank_list" id="tpay-bank-list" onchange="changeBank()"></select>
        <?php if ($data['show_regulations_checkbox'] === true) { ?>
            <p>
                <input id="tpay-accept-regulations-checkbox" type="checkbox" name="regulations" value="0">

                <?php tpay\Lang::l('accept') ?> <a href="<?php echo $data['regulation_url'] ?>"
                                                   target="_blank"><?php tpay\Lang::l('regulations_url') ?></a>
                <?php tpay\Lang::l('regulations'); ?>
            </p>
        <?php } ?>
    </div>
</div>
<?php echo $data['form'] ?>
<script>
    var s = document.createElement('script');
    function renderTpayChannels(installmentsActive) {
        var submit_form_input = document.getElementById('tpay-payment-submit'),
            regulations_form_input = document.getElementById('tpay-regulations-input'),
            regulation_checkbox = document.getElementById('tpay-accept-regulations-checkbox');
        changeBank = function () {
            document.getElementById('tpay-channel-input').value = document.getElementById('tpay-bank-list').value;
        };
        s.src = 'https://secure.tpay.com/groups-<?php echo $data['merchant_id'] . $data['online'] ?>.js';
        s.onload = function () {
            var str = '', i;
            for (i in tr_groups) {
                var channel = tr_groups[i],
                    id = channel[0],
                    name = channel[1];
                if (id === '109' && installmentsActive === false) {
                    continue;
                }
                str += '<option value="' + id + '" >' + name + '</option>';
            }
            document.getElementById('tpay-bank-list').innerHTML = str;
            changeBank();
        };
        document.getElementsByTagName('head')[0].appendChild(s);

        <?php if ($data['show_regulations_checkbox'] === true){ ?>

        submit_form_input.onclick = function () {
            if (regulations_form_input.value == 0) {
                alert('<?php tpay\Lang::l('acceptance_is_required') ?>');
                return false;
            }
            return true;
        };

        regulation_checkbox.onchange = function () {
            regulations_form_input.value = (this.checked) ? 1 : 0;
        };

        <?php } ?>
    }
</script>
