
function show_top_inner() {
    document.write('<div id="indextop">');
    document.write('<table width="1000" border="0" cellpadding="0" cellspacing="0" align="center">');
    document.write('<tr>');
    document.write('<td width="955" height="45" bgcolor="#e0e8f6"><div id="top_ad"></div></td>');
    document.write('<td width="45" align="right" bgcolor="#e0e8f6">');
    document.write('<a style="cursor: hand" onclick="closeme()">');
    document.write('<img src="/images/ec21.png" alt="关闭" width="18" height="45" border="0"/></a>');
    document.write('<td>');
    document.write('</tr>');
    document.write('</table>');
    document.write('</div>');

}
//关闭广告
function closeme() {
    $("#indextop").hide();
document.frames('keysIFrameIFrame').location.reload();
document.frames('proIFrame').location.reload();
}
function sprintf() {
    var repl_count = 0;
    var args = arguments;
    return arguments[0].replace(/%s/g, function() {
        return args[++repl_count];
    });
}

$(function() {
    if(!isIE7plus())
        alert('为了您拥有更好的充值体验，建议使用IE7或以上版本浏览器。');
    if ($("#lb_tiptitle").html() != "" || $("#lb_tipcontent").html() != "") {
        $("#box-tip").slideDown("slow");
    }
    $("#tips-close").click(function() {
        $("#box-tip").slideToggle("slow");
    });


    var newtype = 1;

    $("#new_title h1").mouseover(function() {
        newtype == 1 ? newtype = 2 : newtype = 1;
        $("#new_title h1").removeClass("type_selected");
        $(this).addClass("type_selected");
        $("#news1").hide();
        $("#news2").hide();
        $("#news" + newtype).show();
        $("#more_btn").attr("href", "news/list_news.aspx?id=" + newtype);
    });

    function AutoSwitch() {
        newtype == 1 ? newtype = 2 : newtype = 1;
        $("#new_title h1").removeClass("type_selected");
        $("#new_title h1[title='" + newtype + "']").addClass("type_selected");
        $("#news1").hide();
        $("#news2").hide();
        $("#news" + newtype).show();
        $("#more_btn").attr("href", "news/list_news.aspx?id=" + newtype);
    }

    setInterval(AutoSwitch, 10000);

});



//展示验证码
function showCodes(imgid, codeurl, flag) {
    if ($("#" + imgid + "").css("display") == "none" || $("#" + imgid + "").attr("src") == "/images/getcode.gif" || $("#" + imgid + "").attr("src") == "/images/getcode.png") {
        $("#" + imgid + "").attr("src", "" + codeurl + "?rnd=" + Math.random() + "");
        $("#" + imgid + "").show();
    }
    else {

        if (flag == true) {
            $("#" + imgid + "").attr("src", "");
            $("#" + imgid + "").attr("src", "" + codeurl + "?rnd=" + Math.random() + "");
        }
    }


}

document.write('<script src="/js/box.js"> <\/script>');

$(function() {

    $("#loading1").hide();
    $("#loading2").hide();
    $("#spancnt").html('<iframe id="statIFrame" name="statIFrame"  allowTransparency="true" src="html/index.htm" style="width:28px; height:28px" width="28" height="28" frameborder="0"  scrolling="no"></iframe>');
    //文本框输入按钮
    function txtEnter(e) {
        var key = window.event ? event.keyCode : event.which;
        if (key == 13) {
            $("#" + e.data.id + "").click();
            return false;
        }
    }
    $("#txt_username").bind("keydown", { id: "btn_login" }, txtEnter);
    $("#txt_userpwd").bind("keydown", { id: "btn_login" }, txtEnter);
    $("#txt_usercode").bind("keydown", { id: "btn_login" }, txtEnter);

    $("#tb_cardnumber").bind("keydown", { id: "btn_card" }, txtEnter);
    $("#tb_cardpassword").bind("keydown", { id: "btn_card" }, txtEnter);
    $("#tb_getcode").bind("keydown", { id: "btn_card" }, txtEnter);

    $("#tb_kahao1").bind("keydown", { id: "btnzc1" }, txtEnter);
    $("#tb_mima1").bind("keydown", { id: "btnzc1" }, txtEnter);
    $("#ddl_buynum1").bind("keydown", { id: "btnzc1" }, txtEnter);
    $("#tb_Account1").bind("keydown", { id: "btnzc1" }, txtEnter);
    $("#code1").bind("keydown", { id: "btnzc1" }, txtEnter);

    $("#tb_kahao2").bind("keydown", { id: "btnzc2" }, txtEnter);
    $("#tb_mima2").bind("keydown", { id: "btnzc2" }, txtEnter);
    $("#tb_Account2").bind("keydown", { id: "btnzc2" }, txtEnter);
    $("#sell_type").bind("keydown", { id: "btnzc2" }, txtEnter);
    $("#ddl_buynum2").bind("keydown", { id: "btnzc2" }, txtEnter);
    $("#code2").bind("keydown", { id: "btnzc2" }, txtEnter);

    //首页查询一卡通验证
    $("#btn_card").click(function() {
        if ($("#tb_cardnumber").val().length != 10 && $("#tb_cardnumber").val().length != 12) {
            $("#tb_cardnumber").focus();
            alert("请正确输入卡号，卡号位数应该为10或12位!");
            return false;
        }
        if ($("#tb_getcode").val().length != 4) {
            $("#tb_getcode").focus();
            alert("请正确输入验证码!");
            return false;
        }
    });

    //首页登录验证
    $("#btn_login").click(function() {
        if ($("#txt_username").val().length < 5) {
            $("#txt_username").focus();
            alert("请输入正确的会员名");
            return false;
        }
        if ($("#txt_userpwd").val().length < 6) {
            $("#txt_userpwd").focus();
            alert("请输入正确的密码");
            return false;
        }
        if ($("#txt_usercode").val().length != 5) {
            $("#txt_usercode").focus();
            alert("请输入正确的验证码");
            return false;
        }
    });
    //快速充值一
    $("#btnzc1").click(function() {

        //格式判断
        if ($("#tb_kahao1").val().length != 10 && $("#tb_kahao1").val().length != 12) {
            $("#tb_kahao1").focus();
            alert("请输入正确的一卡通卡号");
            return false;
        }
        if ($("#tb_mima1").val().length != 10 && $("#tb_mima1").val().length != 15) {
            $("#tb_mima1").focus();
            alert("请输入正确的一卡通密码");
            return false;
        }
        if ($("#tb_Account1").val().length < 4) {
            $("#tb_Account1").focus();
            alert("请输入正确的QQ号码");
            return false;
        }
        if ($("#code1").val().length != 4) {
            $("#code1").focus();
            alert("请输入正确的验证码");
            return false;
        }
        //显示Loading图
        //$("#loading1").show();
        //禁用提交按钮 防止二次误操作
        //$("#btnzc1").attr("disabled", true);
        var q_msg = [sprintf("<span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;　点卡类型：%s</span>", "Q币快充")];

        q_msg.push(sprintf("<span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;　充值数量：%s</span>", $("#ddl_buynum1 option:selected").text()));
        q_msg.push(sprintf("<span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;    QQ号码：%s</span>", $("#tb_Account1").val()));

        Popup.confirmMsg("本次充值信息如下", q_msg, "", function(s, _class) {
            if (s) {
                var zcurl = "num=" + $("#ddl_buynum1").val();
                zcurl += "&cknum=1";
                zcurl += "&tb_kahao1=" + $("#tb_kahao1").val();
                zcurl += "&tb_mima1=" + $("#tb_mima1").val();
                zcurl += "&tb_Account=" + $("#tb_Account1").val();
                zcurl += "&code=" + $("#code1").val();
                zcurl += "&price=" + $("#ddl_buynum1").val();
                zcurl += "&flnid=5";
                //异步调用ajax
                $.ajax({
                    type: "get",
                    url: $("#zc1url").val(),
                    data: zcurl,
                    dataType: "json",
                    cache: false,
                    success: function(e) {
                        Popup.close();
                        //$("#loading1").hide(); //隐藏loading图
                        //$("#btnzc1").attr("disabled", false); //启用提交按钮
                        if (e.State == 0) {
                            ShowText("快速充值", "<dl>充值成功！</dl>" + e.Msg, "", [["关闭", function() { Box.close(); } ]]); //弹出提示消息
                        }
                        else {
                            ShowText("快速充值", e.Msg, "", [["关闭", function() { Box.close(); } ]]); //弹出提示消息
                        }

                        showCodes('verify_img', '/Validator/getcode.aspx', true);

                    },
                    //error: function(XMLResponse) { alert(XMLResponse.responseText); }// --显示错误详细信息
                    error: function() { Popup.close(); alert("服务器没有返回数据，可能服务器忙，请重试"); $("#btnzc1").attr("disabled", false); showCodes('verify_img', '/Validator/getcode.aspx', true); }
                });
            }
        });
        return false;





    });
    //快速充值二
    $("#btnzc2").click(function() {

        if ($("#tb_kahao2").val().length != 10 && $("#tb_kahao2").val().length != 12) {
            $("#tb_kahao2").focus();
            alert("请输入正确的一卡通卡号");
            return false;
        }
        if ($("#tb_mima2").val().length != 10 && $("#tb_mima2").val().length != 15) {
            $("#tb_mima2").focus();
            alert("请输入正确的一卡通密码");
            return false;
        }
        if ($("#sell_type option:selected").val() == "0") {
            $("#sell_type").focus();
            alert("请选择充值方式");
            return false;
        }
        if ($("#tb_Account2").val().length < 4) {
            $("#tb_Account2").focus();
            alert("请输入正确的QQ号码");
            return false;
        }
        if ($("#code2").val().length != 4) {
            $("#code2").focus();
            alert("请输入正确的验证码");
            return false;
        }
        //显示Loading图
        //$("#loading2").show();
        //禁用提交按钮 防止二次误操作
        //$("#btnzc2").attr("disabled", true);
        var q_msg = [sprintf("<span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;　点卡类型：%s</span>", "QQ会员/钻")];
        q_msg.push(sprintf("<span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;　充值数量：%s</span>", $("#ddl_buynum2 option:selected").text()));
        q_msg.push(sprintf("<span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;　充值方式：%s</span>", $("#sell_type option:selected").text()));
        q_msg.push(sprintf("<span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;    QQ号码：%s</span>", $("#tb_Account2").val()));

        Popup.confirmMsg("本次充值信息如下", q_msg, "", function(s, _class) {
            if (s) {
                var zcurl = $("#zc2url").val();
                zcurl = "num=" + (parseInt($("#ddl_buynum2").val()) / 10);
                zcurl += "&cknum=1";
                zcurl += "&tb_kahao1=" + $("#tb_kahao2").val();
                zcurl += "&tb_mima1=" + $("#tb_mima2").val();
                zcurl += "&tb_Account=" + $("#tb_Account2").val();
                zcurl += "&code=" + $("#code2").val();
                zcurl += "&sell_type=" + $("#sell_type option:selected").val();
                zcurl += "&price=" + $("#ddl_buynum2").val();
                zcurl += "&flnid=711";
                //异步调用ajax
                $.ajax({
                    type: "get",
                    url: $("#zc2url").val(),
                    data: zcurl,
                    dataType: "json",
                    cache: false,
                    success: function(e) {
                        //$("#loading2").hide();
                        //$("#btnzc2").attr("disabled", false);
                        Popup.close();
                        if (e.State == 0) {
                            ShowText("快速充值", "<dl>充值成功！</dl>" + e.Msg, "", [["关闭", function() { Box.close(); } ]]); //弹出提示消息
                        }
                        else {
                            ShowText("快速充值", e.Msg, "", [["关闭", function() { Box.close(); } ]]);
                        }
                        showCodes('verify_img2', '/Validator/getcode2.aspx', true);
                    },
                    error: function() { Popup.close(); alert("服务器没有返回数据，可能服务器忙，请重试"); $("#btnzc2").attr("disabled", false); showCodes('verify_img2', '/Validator/getcode2.aspx', true); }
                });
            }
        });
        return false;



    });
    //使用多张一卡通充值弹出充值页
    $("#ektnum1").change(function() {
        if ($("#ektnum1").val() == "2") {
            var zcurl = $("#zc1url").val();
            zcurl += "&num=" + $("#ddl_buynum1").val();
            zcurl += "&cknum=" + $("#ektnum1").val();
            zcurl += "&price=" + $("#ddl_buynum1").val() + "&flnid=5";
            window.open(zcurl);
            $("#ektnum1").val("1");
        }
    });
    //使用多张一卡通充值弹出充值页
    $("#ektnum2").change(function() {
        if ($("#ektnum2").val() == "2") {
            var zcurl = $("#zc2url").val();
            zcurl += "&num=" + (parseInt($("#ddl_buynum2").val()) / 10);
            zcurl += "&cknum=" + $("#ektnum2").val();
            zcurl += "&price=" + $("#ddl_buynum2").val() + "&flnid=711";
            window.open(zcurl);
            $("#ektnum2").val("1");
        }
    });

    //验证码默认不显示
    //    $("#verify_img").hide();
    //    $("#verify_img2").hide();
    //    $("#u-rdm-img").hide();
    //    $("#rdm-img").hide();

    $("#code1").focus(function() {
        showCodes("verify_img", "/Validator/getcode.aspx", false);
    });

    $("#code2").focus(function() {
        showCodes("verify_img2", "/Validator/getcode2.aspx", false);
    });

    $("#txt_usercode").focus(function() {
        showCodes("u-rdm-img", "/getimage.aspx", false);
    });

    $("#tb_getcode").focus(function() {
        showCodes("rdm-img", "/Validator/jumpcode.aspx", false);
    });


    //对应T点显示
    $("#ddl_buynum1").change(function() {
        sMsg = $(this).val() * 100;
        $("#buynumT1").html(sMsg);
    });
    $("#ddl_buynum2").change(function() {
        sMsg = $(this).val() * 100;
        $("#buynumT2").html(sMsg);
    });

});

function isIE7plus()
{
    var result = false;
    var Sys = {};
    var ua = navigator.userAgent.toLowerCase();
    if (window.ActiveXObject)
    {
        if(ua.indexOf('maxthon') >= 0)
            Sys.maxthon = 1;
        else if(ua.indexOf('theworld') >= 0)
            Sys.theworld = 1	
	else if(ua.indexOf('se') >= 0)
            Sys.sogou = 1;
	else if(ua.indexOf('tencent') >= 0)
            Sys.tencent = 1;
	else
            Sys.ie = ua.match(/msie ([\d.]+)/)[1]
    }   
    else if (ua.indexOf('firefox') >= 0)
    {
        Sys.firefox = 1;
    }
    else if (ua.indexOf('opera') >= 0)
    {
        Sys.opera = 1;
     }
     else if (ua.indexOf('safari') >= 0)
    {
        Sys.safari = 1;     
    }
    else if (ua.indexOf('chrome') >= 0)
    {
        Sys.chrome = 1;
    }
   if(parseInt(Sys.ie) >= 6)
        result = true;
   return result;
}
