
        $(function () {
            function checkTLength(o, o1, n, min, max) {
                if ((o.val().length + o1.length) > max || (o.val().length + o1.val().length) < min) {
                    o1.addClass("ui-state-error");
                    updateTips(n + "必须在" +
                                min + "到" + max + "位之间", o1.attr("id"));
                    return false;
                } else {
                    $("." + o1.attr("id")).html("<img src=\"/Common/Images/true.png\" />");
                    return true;
                }
            }

            var IsCnDomain = false;
            if (isChn(RegDomain)) {//中文域名
                IsCnDomain = true;
            }
            if (IsCnDomain) {
                $("#unamepinyin").css("display", "");
            }
            var uname1 = $("#uname1"),
            uname2 = $("#uname2"),
            rname1 = $("#rname1"),
            rname2 = $("#rname2"),
            uname3 = $("#uname3"),
            uname4 = $("#uname4"),
            location = $("#location"),
            unicode = $("#unicode"),
            certcode = $("#certcode"),
            uaddr1 = $("#uaddr1"),
            uaddr2 = $("#uaddr2"),
            uzip = $("#uzip"),
            uemail = $("#uemail"),
            utela = $("#utela"),
            uteln = $("#uteln"),
            ufaxa = $("#ufaxa"),
            ufaxn = $("#ufaxn"),
            aname1 = $("#aname1"),
            aname2 = $("#aname2"),
            atela = $("#atela"),
            ateln = $("#ateln"),
            atele = $("#atele"),
            afaxa = $("#afaxa"),
            afaxn = $("#afaxn"),
            afaxe = $("#afaxe"),
            aemail = $("#aemail"),
            allFields = $([])
            .add(uname1)
            .add(uname2)
            .add(rname1)
            .add(rname2)
            .add(uname3)
            .add(uname4)
            .add(location)
            .add(unicode)
            .add(certcode)
            .add(uaddr1)
            .add(uaddr2)
            .add(uzip)
            .add(uemail)
            .add(utela)
            .add(uteln)
            .add(ufaxa)
            .add(ufaxn)
            .add(aname1)
            .add(aname2)
            .add(atela)
            .add(ateln)
            .add(atele)
            .add(afaxa)
            .add(afaxn)
            .add(afaxe)
            .add(aemail)
            ;
            function ValidTemp() {
                var bValid = true;
                allFields.removeClass("ui-state-error");
                bValid = bValid && checkLength(uname1, "域名所有人中文名称", 1, 255);
                bValid = bValid && checkLength(uname2, "域名所有人英文名称", 1, 255);
                bValid = bValid && checkLength(rname1, "注册人中文名称", 1, 255);
                bValid = bValid && checkLength(rname2, "注册人英文名称", 1, 255);
                if (IsCnDomain) {
                    bValid = bValid && checkLength(uname3, "注册单位拼音", 1, 255);
                    bValid = bValid && checkLength(uname4, "注册单位缩写", 1, 255);
                    bValid = bValid && checkLength(location, "注册人单位所在地址", 1, 255);
                }
                if (DomainRoot == ".travel") {
                    bValid = bValid && checkLength(unicode, "UIN编码", 1, 255);
                }
                if (DomainRoot == ".asia") {
                    bValid = bValid && checkLength(certcode, "证件号码", 1, 255);
                }
                bValid = bValid && checkLength(uaddr1, "注册人中文地址", 1, 255);
                bValid = bValid && checkLength(uaddr2, "注册人英文地址", 1, 255);
                bValid = bValid && checkRegexp(uzip, Regex_Zip, "注册人英文地址");
                bValid = bValid && checkRegexp(uemail, Regex_EMail, "注册人Mail");
                bValid = bValid && checkLength(utela, "注册人电话区号", 0, 4);
                bValid = bValid && checkTLength(utela, uteln, "注册人电话区号+电话号码", 6, 11);
                bValid = bValid && checkLength(ufaxa, "注册人传真区号", 0, 4);
                bValid = bValid && checkTLength(ufaxa, ufaxn, "注册人传真区号+传真号码", 6, 11);

                if ($("#rMAR").attr("checked")) {//如果管理人信息单独填写
                    bValid = bValid && checkLength(aname1, "管理联系人中文名称", 1, 255);
                    bValid = bValid && checkLength(aname2, "管理联系人英文名称", 1, 255);
                    bValid = bValid && checkLength(atela, "管理人电话区号", 0, 4);
                    bValid = bValid && checkTLength(atela, ateln, "管理人电话区号+电话号码", 6, 11);
                    bValid = bValid && checkLength(afaxa, "管理人传真区号", 0, 4);
                    bValid = bValid && checkTLength(afaxa, afaxn, "管理人传真区号+传真号码", 6, 11);
                    bValid = bValid && checkRegexp(aemail, Regex_EMail, "管理人Mail");
                }
                return bValid;
            };
            $("form").submit(function () {
                return ValidTemp();
            });

            uname1.blur(function () {
                uname2.val(CC2PY(uname1.val(), false));
                uname3.val(CC2PY(uname1.val(), false));
                uname4.val(CC2PY(uname1.val(), true));
            });
            rname1.blur(function () {
                rname2.val(CC2PY(rname1.val(), false));
            });
            uaddr1.blur(function () {
                uaddr2.val(CC2PY(uaddr1.val(), false));
            });
            aname1.blur(function () {
                aname2.val(CC2PY(aname1.val(), false));
            });
            $("#api_type,#BuyYear").change(function () {
                CommonGetAjax(5000, "/common/ashx/global.ashx", {
                    "Action":"GetDomainRegMoney",
                    "UserName": LoginMember,
                    "DomainRoot": DomainRoot,
                    "IsCNDomain": IsCnDomain,
                    "APIType": $("#api_type").val(),
                    "BuyYear": $("#BuyYear").val()
                }, $("#BuyPrice"), "");
            });
        });