<?php

/**
************************************************************************
Copyright [2015] [PagSeguro Internet Ltda.]

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
************************************************************************
*/

?>
<?php
    $helper = Mage::helper('pagseguro');
    $baseUrl = Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_WEB);
    $adminSkinUrl = $baseUrl . 'skin/adminhtml/default/default/';
?>

<link rel="stylesheet" type="text/css" href="<?php echo $adminSkinUrl . 'uol/pagseguro/css/pagseguro-modal.css'; ?>" media="all" />
<link rel="stylesheet" type="text/css" href="<?php echo $adminSkinUrl . 'uol/pagseguro/css/pagseguro-module.css'; ?>" media="all" />

<script type="text/javascript" src="<?php echo $adminSkinUrl . 'uol/pagseguro/js/jquery-1.11.1.js'; ?>"></script>
<script type="text/javascript" src="<?php echo $adminSkinUrl . 'uol/pagseguro/js/jquery.colorbox-min.js'; ?>"></script>
<script type="text/javascript" src="<?php echo $adminSkinUrl . 'uol/pagseguro/js/pagseguro-module.js';?>"></script>

<script type="text/javascript">
    var jQuery = jQuery.noConflict();
    jQuery(document).ready(function(){
        jQuery(".button").click(function(e){
            if (jQuery(this).attr('onclick') == 'payment.save()') {
                if (jQuery.type(jQuery('.btn-checkout')[0]) == 'object') {
                    jQuery('.btn-checkout').remove();
                }
                if (jQuery('input:radio[name="payment[method]"]:checked').val() == 'pagseguro') {
                    var interval = setInterval(function() {
                        if (jQuery.type(jQuery('.btn-checkout')[0]) == 'object') {
                            jQuery('.btn-checkout').attr('onclick','activeLoading(), review.save();');
                            clearInterval(interval);
                        }
                    }, 0);
                }
            }
        });
    });

    function activeLoading() {
        jQuery('#review-please-wait.please-wait').addClass('ps_msg_hidden');
        jQuery('.btn-checkout').remove();
        Modal.showLoading('<?php echo $helper->__('Processando o pedido...') ?>');
        jQuery('#pagseguro-loading-message h3').attr('style','min-width:210px; font-size: 16px !important;');
        jQuery('#cboxContent').css('height','104px');
    }
</script>
