/// <summary>
/// 充值金额
/// </summary>
var amount = [
    { "k": ["any"], "c": "RMB", "v": [1, 10, 20, 50, 100, 200, 500, 1000, 2000, 3000, 5000, 8000, 10000] },
    { "k": ["unicom"], "c": "RMB", "v": [20, 30, 50, 100] },
    { "k": ["tele"], "c": "RMB", "v": [50, 100] },
    { "k": ["szx"], "c": "RMB", "v": [10, 20, 30, 50, 100, 300, 500] },
    { "k": ["shenda"], "c": "RMB", "v": [5, 10, 15, 25, 30, 35, 45, 50, 100, 350, 1000] },
    { "k": ["wanmei"], "c": "RMB", "v": [10, 15, 20, 30, 50] },
    { "k": ["wangyi"], "c": "RMB", "v": [10, 20, 30, 50] },
    { "k": ["jiuyou"], "c": "RMB", "v": [5, 10, 30, 50] },
    { "k": ["sohu"], "c": "RMB", "v": [5, 10, 15, 30, 40, 100] },
    { "k": ["tianxia"], "c": "RMB", "v": [5, 6, 10, 15, 30, 50, 100] },
    { "k": ["tianh"], "c": "RMB", "v": [5, 10, 15, 20, 30, 50, 100] },
    { "k": ["zong"], "c": "RMB", "v": [5, 10, 30, 50, 100] },
    { "k": ["dianka"], "c": "RMB", "v": [5] },
    { "k": ["qq"], "c": "RMB", "v": [5, 10, 15, 20, 30, 50, 60, 100, 200] }
]
/**** 修改中  ***********/

/// 没设置，默认值
var def_money = [1, 10, 20, 50, 100, 200, 500, 1000, 2000, 3000, 5000, 8000, 10000];


function getMoney(k) {
    var amountspr = "";
    var money_list_key = k + "_moneys";
    if (k == "none") {
        $(".money-item").hide()//没选择充值方式,不显示充值金额
    } else {

    $.ajax({
        url: "/api/webconfig.ashx?m=" + Math.random(),
        data: { 'key': money_list_key },
        success: function (mlist) {


            if (typeof mlist == "string" && mlist != "") {
                $(mlist.split(',')).each(function (l, dm) {
                    amountspr += '<span value="' + dm + '" class="money-item">' + dm + '</span>';
                })
            } else {

                /** 默认值  **/
                $(def_money).each(function (n, ky) {
                    amountspr += '<span value="' + ky + '" class="money-item">' + ky + '</span>';
                })
            }
            /****************************************/
            $.get("/api/webconfig.ashx?m=" + Math.random(), { 'key': "custom_" + money_list_key + "_mini" }, function (htmlValue) {
                try {
                    if (htmlValue.indexOf("|") == -1) {/** 有|号 **/
                        amountspr += '<strong class="money-item" id="userinputzdy" style="width:110px; font-size:12px;">其他 <input onkeyup="userinputzdy(this)" class="i" type="text" style="width:60px;height:14px" /></strong>';
                        amountspr += '<span style="display: none;" value="0" id="userinputhide" class="money-item">0</span>';
                    }                   
                } catch (e) {
                    amountspr += '<strong class="money-item" id="userinputzdy" style="width:110px; font-size:12px;">其他 <input onkeyup="userinputzdy(this)" class="i" type="text" style="width:60px;height:14px" /></strong>';
                    amountspr += '<span style="display: none;" value="0" id="userinputhide" class="money-item">0</span>';
                }
                if (money_list_key == "dianka_moneys") {
                    amountspr = '<strong class="money-item" id="userinputzdy" style="width:260px; font-size:12px;">输入卡号 <input  type="text" style="width:150px;height:18px" id="diankahao" onblur="likai()"/></strong>'
                        + '<strong class="money-item" id="userinputzdy" style="width:260px; font-size:12px;">输入密码 <input  type="text" style="width:150px;height:18px" id="mima" onblur="mima()"/></strong>'
                        ;
                }
                $(".amountselp").html(amountspr);
                $(".amountselp span").click(function () {
                    $("#money").val($(this).attr("value"));
                    checkmoney("#money");
                    $(".amountselp span").removeClass("on");
                    $(this).addClass("on");
                    if ($(this).attr("id") != "userinputhide") {
                        $('#userinputzdy').css({ border: "1px solid #DDD", padding: "6px 10px" })
                        $('#userinputzdy input').val("");
                    }
                });
                if (money_list_key == "dianka_moneys") {
                    amountspr = '<strong class="money-item" id="userinputzdy" style="width:260px; font-size:12px;">输入卡号 <input  type="text" style="width:150px;height:18px" id="diankahao" onblur="likai()"/></strong>'
                        + '<strong class="money-item" id="userinputzdy" style="width:260px; font-size:12px;">输入密码 <input  type="text" style="width:150px;height:18px" id="mima" onblur="mima()"/></strong>'
                        ;
                    $(".amountselp").html(amountspr);
                }
            })
            /****************************************/
        }
    })
    }

}


function userinputzdy(self) {
    var thmoney = 0;

    $(self).parent().css({ border: "3px solid #FD9C00", padding: "4px 8px" })
    $(".amountselp span").removeClass("on");
    if (isNaN($(self).val())) {
        $(self).val("")
        thmoney = 0

        $("#userinputhide").attr("value", thmoney);
        $("#userinputhide").click();
    } else
        if ($(self).val().length > 6) {
            $(self).val("")
            thmoney = 0;
            $("#userinputhide").attr("value", thmoney);
            $("#userinputhide").click();
        } else
            if ($(self).val().indexOf("-") != -1 || $(self).val().indexOf(".") != -1) {
                $(self).val("")
                thmoney = 0;
                $("#userinputhide").attr("value", thmoney);
                $("#userinputhide").click();
            } else
                if ($(self).val().length > 0 && parseInt($(self).val()) < 1) {
                    $(self).val("")
                    thmoney = 0;
                    $("#userinputhide").attr("value", thmoney);
                    $("#userinputhide").click();
                } else {
                    thmoney = parseInt($(self).val());
                    $("#userinputhide").attr("value", thmoney);
                    $("#userinputhide").click();
                }



}
$(document).ready(function () {
    getMoney("none");

    $("#pay_setup_1 li a").click(function () {
        $(".paypalpaynone").hide();
        $(".wenstationpay").hide();



        if (typeof chetype != "undefined") {
            chetype = "none";
        }
        $(".wangshangyinhang").html("");
        clspopbank();
        $(".stupcreditcard").hide();
        $(".stupucread").hide();
        $(".stupbank").hide();
        $(".stup-bank-logo ul li").remove();
        var self = $(this);

        if (self.attr("data") == "stationpay") {
            $(".wenstationpay").show();
        }

        $("input[name='pay_away']").val(self.attr("data"));
        if ("paypalpay" == self.attr("data")) {
            $(".paypalpaynone").show();
        }
        var data = self.attr("premiun"); //amt 旧版本使用值
        if (data == "sys_station_btog") {
            $(".pingtaibixianshi").show();
        } else {
            $(".pingtaibixianshi").hide();
        }
        $.ajax(
        {
            url: "/api/pay20/checkparams.ashx?type=bit",
            data: "gid=" + $("input[name='gname_id']").val() + "&user=" + $("#username").val() + "&data=" + self.attr("premiun") + "&rm=" + Math.random(),
            success: function (jon) {
                $("#get_game_money").attr("data", jon);
                $("#p_g_bit").html(Math.floor(jon)); //get_game_money
                checkmoney("#money");
            }
        });
        $(".chongzhimingcheng").html(self.html());
        var bankload = self.attr("bank");
        if (typeof bankload != "undefined") {
            loadbank(bankload);
            $(".popbank").show();
        } else {
            $(".stupbank").hide();
            clspopbank();
        }
        if (chetype == "credit" || chetype == "dianka") {
            clspopbank()
        }
        getMoney(data);
        $("#pay_setup_1 li a").removeClass("current");
        self.addClass("current");
        $('#userinputzdy').show();
    });
})

function clspopbank() { $(".hidepopbank .sss").css("position", "static"); $(".popbank").hide() }