$(function () {
    $("input[type=radio]").click(function () {
        $(".payinput ul").css("display", "none");
        $($(".payinput ul").get($(this).parent().index())).css("display", "block");
    });
    $("#radioonline").click(function () {
        $(this).parents("form").attr("action", "pay.online.html");
    });
    $("#radiocard").click(function () {
        $(this).parents("form").attr("action", "pay.card.html");
    });

    var paymoney = $("#paymoney"),
    allFields1 = $([])
            .add(paymoney)
    ;
    function ValidTemp1() {
        var bValid = true;
        allFields1.removeClass("ui-state-error");
        bValid = bValid && checkRegexp(paymoney, Regex_InputMoney, "充值金额必须大于0，精确度0.01");
        return bValid;
    };
    $("#PayBTN").click(function () {
        if (ValidTemp1()) {
            $(this).parent().append("<img src=\"/Common/Images/loading.gif\" />提交中，请稍候...");
            $(this).attr("disabled", "disabled");
            $("form").submit();
        } else {
            return false;
        }
    });

    var CardNO = $("#CardNO"),
    allFields = $([])
            .add(CardNO)
    ;
    function ValidTemp() {
        var bValid = true;
        allFields.removeClass("ui-state-error");
        bValid = bValid && checkRegexp(CardNO, Regex_MoneyCard, "充值卡格式不正确");
        return bValid;
    };
    $("#checkCard").click(function () {
        var LoadString = "<img src=\"/Common/Images/loading.gif\" /> 查询中，请稍候...";
        if (ValidTemp()) {
            $(".CardNO").html(LoadString);
            CommonGetAjax(5000, "/common/ashx/global.ashx", { "Action": "CheckMoneyCard", "CardNO": $("#CardNO").val() }, $(".CardNO"), "系统错误");
        } else {
            return false;
        }
        
    });
    $("#AddBTN").click(function () {
        if (ValidTemp()) {
            $(this).parent().append("<img src=\"/Common/Images/loading.gif\" />提交中，请稍候...");
            $(this).attr("disabled", "disabled");
            $("form").submit();
        } else {
            return false;
        }
    });
});