﻿
        function btnclick(v)
        {
            v.disabled=true;
            v.value = RS_js_Submitting;
            window.focus();
        }
        function updateAddressInfo(){
            $("#UpdateAddressLink").hide();
            $("#exitAddressLink").show();
            $("#showAddressInfoDiv").hide();
            $("#updateAddressInfoDiv").show();
            
            hideHomeDelive();
            detailEditAddressInfo();
            changeAddress();
         }
         function changeAddress() {
             //alert('change');
             $("#hidPostAddId").val($("#" + masterIdStart + "hdnPostAddressId").val());
             $("#" + masterIdStart + "hdnPostAddressId").val('');
         }
         function cancelChangeAddress() {
             //alert('cancel');
             $("#" + masterIdStart + "hdnPostAddressId").val($("#hidPostAddId").val());
         }        
         
        function exitAddressInfo(){
            $("#UpdateAddressLink").show();
            $("#exitAddressLink").hide();
            $("#showAddressInfoDiv").show();
            $("#updateAddressInfoDiv").hide();
            $("#viewAddressInfoDiv").hide();            
            
        }
        function viewAddressInfo(){
            $("#UpdateAddressLink").hide();
            $("#exitAddressLink").show();
            $("#showAddressInfoDiv").hide();
            $("#updateAddressInfoDiv").hide();
            $("#viewAddressInfoDiv").show();

            hideHomeDelive();

            var radDeliveTypelist = document.forms[0].radDeliveType;
            for (i = 0; i < radDeliveTypelist.length; i++) {
                radDeliveTypelist[i].checked = false;
            }
            var cartmoney = $("#_ctl0_ContentPlaceHolder1_totalcartAllPrices1").html();
            var minpaymentmoney = $("#_ctl0_ContentPlaceHolder1_shopMinDeliverMoney").html();
           

            $("#_ctl0_ContentPlaceHolder1_tranactionfee").html(0);
            $("#_ctl0_ContentPlaceHolder1_totalcartAllPrices").html("" + (parseFloat(cartmoney)));
            
            changeAddress();
            loadAddressList();
        }
        //省份变化，绑定城市
        var masterIdStart="_ctl0_ContentPlaceHolder1_";
        function loadCity(nowvalue) {
            if (nowvalue == "-1") {
                document.getElementById("drpPostCity").options.length = 1;
                document.getElementById("drpPostArea").options.length = 1;
                return false;
            }
            $.ajax({
               type: "Get",
               dataType:"json",
               url:"/Ajax/Ajax.ashx?type=province&value="+nowvalue+"&date="+new Date().getTime(),
               success:function(json, status) {
                    if (json != '') {
                        //var json = JSON.parse(data);
                        document.getElementById("drpPostCity").options.length = 1;
                        document.getElementById("drpPostArea").options.length = 1;
                        for (var i = 0; i < json.length; i++) {
                            if (LangType == 1)
                                document.getElementById("drpPostCity").options.add(new Option(json[i].NC_NAME_EN, json[i].C_BRIEFCODE + '|' + json[i].C_SECONDCODE));
                            else
                                document.getElementById("drpPostCity").options.add(new Option(json[i].NC_NAME, json[i].C_BRIEFCODE + '|' + json[i].C_SECONDCODE));
                                
                        }
                    }
                },
               error: function(data, status, e) {
                   //alert("收货人地址加载失败1.....");
                   document.getElementById("drpPostCity").options.length = 1;
                   document.getElementById("drpPostArea").options.length = 1;
                }
               });  
        }
        function selectProvicechange(v){
            loadCity(v);
        }
        function loadArea(nowvalue) {
            //alert(nowvalue);
            if (nowvalue =="-1") {
                document.getElementById("drpPostArea").options.length = 1;
                return false;
            }
            
            $.ajax({
               type: "Get",
               dataType:"json",
               url:"/Ajax/Ajax.ashx?type=city&value="+nowvalue+"&date="+new Date().getTime(),
               success:function(json, status) {
                    if (json != '') {
                        //var json = JSON.parse(data);
                        document.getElementById("drpPostArea").options.length = 1;
                        for (var i = 0; i < json.length; i++) {
                            if (LangType == 1)
                                document.getElementById("drpPostArea").options.add(new Option(json[i].NC_NAME_EN, json[i].C_BRIEFCODE + '|' + json[i].C_SECONDCODE));
                            else
                                document.getElementById("drpPostArea").options.add(new Option(json[i].NC_NAME, json[i].C_BRIEFCODE + '|' + json[i].C_SECONDCODE));
                            
                        }
                    }
                },
               error: function(data, status, e) {
                //alert("收货人地址加载失败2.....");
                document.getElementById("drpPostArea").options.length = 1;
                }
               });  
        }
        function selectCitychange(v){
            loadArea(v);
        }
        
        //基于option的text绑定
        function bindProvice(proviceV){
            var provicedrplist=document.getElementById(masterIdStart+"drpPostProvice");
            for(var i=0;i<provicedrplist.options.length;i++){
                if(provicedrplist.options[i].text==proviceV){
                    provicedrplist.options[i].selected = true; 
                    break;
                }
            }
        }
        function bindArea(proviceV,areaV){
            //alert(proviceV);
            if (proviceV == "-1") {
                document.getElementById("drpPostArea").options.length = 1;
                return false;
            }
            
            $.ajax({
                type: "Get",
                dataType: "json",
                url: "/Ajax/Ajax.ashx?type=city&value=" + proviceV + "&date=" + new Date().getTime(),
                success: function(json, status) {
                    if (json != '') {
                        //var json = JSON.parse(data);
                        document.getElementById("drpPostArea").options.length = 1;
                        var bFlag = false;
                        for (var i = 0; i < json.length; i++) {
                            var name = json[i].NC_NAME;

                            if (LangType == 1)
                                name = json[i].NC_NAME_EN;

                            var op = new Option($.trim(name), json[i].C_BRIEFCODE + '|' + json[i].C_SECONDCODE);

                            if (op.text == areaV) {
                                op.selected = true;
                                bFlag = true;
                            }

                            document.getElementById("drpPostArea").options.add(op);
                        }
                        if (bFlag) {
                            document.getElementById("drpPostArea").options[0].selected = false;
                        }
                    }
                },
                error: function(data, status, e) {
                //alert("收货人地址加载失败2.....");
                    document.getElementById("drpPostArea").options.length = 1;
                }
            }); 
        }
        function loadbindAdress(proviceV,cityV,areaV){
            //provice
            if (proviceV == "-1") {
                document.getElementById("drpPostCity").options.length = 1;
                document.getElementById("drpPostArea").options.length = 1;
                return false;
            }
            bindProvice(proviceV);
            //city
            var proviceV1=$("#"+masterIdStart+"drpPostProvice").attr("value");
            $.ajax({
               type: "Get",
               dataType:"json",
               url:"/Ajax/Ajax.ashx?type=province&value="+proviceV1+"&date="+new Date().getTime(),
               success:function(json, status) {
                    if (json != '') {
                        document.getElementById("drpPostCity").options.length = 1;
                        for (var i = 0; i < json.length; i++) {
                            var name = json[i].NC_NAME;

                            if (LangType == 1)
                                name = json[i].NC_NAME_EN;

                            var op = new Option($.trim(name), json[i].C_BRIEFCODE + '|' + json[i].C_SECONDCODE);
                            if(op.text==cityV){ 
                                op.selected = true;
                            }
                            
                            document.getElementById("drpPostCity").options.add(op);
                        }
                        //area
                        bindArea($("#drpPostCity").val(), areaV);
                    }
                },
               error: function(data, status, e) {
                   //alert("收货人地址加载失败1.....");
                   document.getElementById("drpPostCity").options.length = 1;
                }
               });
        }
        //显示收货人的信息
        function detailAddressInfo(seqId){
            $.ajax
            ({
                type: "Get",
                url: '/CheckOut.aspx',
                data: "action=showEditdetail&seqId=" + seqId + "&date=" + new Date().getTime(),
                success: function(data, status) {
                    if (data != '') {

                        var json = JSON.parse(data);
//                        alert('json.length=' + json.length);
                        for (var i = 0; i < json.length; i++) {
                            $("#" + masterIdStart + "lblPostName").html(json[i].NC_NAME);
                            $("#" + masterIdStart + "lblPostAddress").html(json[i].NC_ADDRESS2);
                            $("#" + masterIdStart + "lblPostCode").html(json[i].C_POSTCODE);
                            //$("#txtPostEmail").html(json[i].C_EMAIL);
                            $("#" + masterIdStart + "lblPostMobile").html(json[i].C_MOBILE);
                            $("#" + masterIdStart + "lblPostPhone").html(json[i].C_PHONE);
                            $("#" + masterIdStart + "lblPostProviceCityArea").html(json[i].NC_PROVINCE + " " + json[i].NC_DISTRICE + " " + json[i].NC_ADDRESS1);
                            checkPostCode2();
                        }
                    }
                },
                error: function(data, status, e) {
                    alert(data);
                }
            });
        }    
        //加载编辑的收货信息
        function detailEditAddressInfo(){
            var seqId=$("#"+masterIdStart+"hdnPostAddressId").val();
            if (/^[1-9][\d]*$/.test(seqId)) {
            $.ajax
            ({
                type: "Get",
                url: '/CheckOut.aspx',
                data: "action=showEditdetail&seqId="+seqId+"&date="+new Date().getTime(),
                success: function(data, status) {
                    if (data != '') {
                      
                       var json = JSON.parse(data);
                        for (var i = 0; i < json.length; i++) {
                           //json[i].SEQ_ID+"'/>"+json[i].NC_NAME+" | "+json[i].NC_ADDRESS2+"<br/>";
                           $("#txtPostName").val(json[i].NC_NAME);
                           $("#txtPostAddress").val(json[i].NC_ADDRESS2);
                           $("#txtPostCode").val(json[i].C_POSTCODE);
                           //$("#txtPostEmail").val(json[i].C_EMAIL);
                           $("#txtPostMobile").val(json[i].C_MOBILE);
                           $("#txtPostPhone").val(json[i].C_PHONE);
                           checkPostCode();
                           loadbindAdress(''+json[i].NC_PROVINCE,''+json[i].NC_DISTRICE,''+json[i].NC_ADDRESS1);
                           $("#btnUpdateAddressinfo").show();
                        }
                    }
                    else{
                        $("#btnUpdateAddressinfo").hide();
                    }
                },
                error: function(data, status, e) {
                    alert(data);
                }
            });
           }
           else {
                
                $("#btnUpdateAddressinfo").hide();
           }
        }
        //修改地址信息
        function updateAddressList(){
            //var seqId = $("#" + masterIdStart + "hdnPostAddressId").val();
            var seqId = $("#hidPostAddId").val();
            if (/^[1-9][\d]*$/.test(seqId)) {
                
                if ($("#txtPostName").val() == "") {
                    alert(RS_js_InputToUserNm);
                    $("#txtPostName").focus();
                    return;
                }
                if ($("#txtPostMobile").val() == "" && $("#txtPostPhone").val() == "") {
                    alert(RS_lt_CellPoneOrMobilePhone);
                    $("#txtPostMobile").focus();
                    return;
                }

                //验证手机
                var pre = new RegExp(/^(([0\+]\d{2,3}-)?(0\d{2,3})-)?(\d{7,8})(-(\d{4,}))?$/);
                var mre = new RegExp(/^((\(\d{3}\))|(\d{3}\-))?1\d{10}$/);

                if ($("#txtPostMobile").val() != "" && !mre.test($("#txtPostMobile").val())) {
                    alert(errormobile);
                    $("#txtPostMobile").focus();
                    return;
                }

                if ($("#txtPostPhone").val() != "" && !pre.test($("#txtPostPhone").val())) {
                    alert(errorphone);
                    $("#txtPostPhone").focus();
                    return;
                }
            //验证收货地址    
            var provicename="";
            var cityname="";
            var areaname="";
            var provicelist=document.getElementById(masterIdStart+"drpPostProvice");
            for(i=0;i<provicelist.options.length;i++){
                if (provicelist.options[i].selected && parseInt(provicelist.options[i].value) > 0) {
                    provicename=provicelist.options[i].text;
                    break;
                }
            }
            var citylist=document.getElementById("drpPostCity");
            for(j=0;j<citylist.options.length;j++){
                if (citylist.options[j].selected && parseInt(citylist.options[j].value) > 0) {
                    cityname=citylist.options[j].text;
                    break;
                }
            }
            var arealist=document.getElementById("drpPostArea");
            for (k = 0; k < arealist.options.length; k++) {
                if (arealist.options[k].selected && parseInt(arealist.options[k].value) > 0) {
                    areaname=arealist.options[k].text;
                    break;
                }
            }
            if(provicename==""){
                alert(RS_js_SelectProvince);
                document.getElementById(masterIdStart + "drpPostProvice").focus();
                return;
            }
            if(cityname==""){
                alert(RS_js_SelectCity);
                document.getElementById("drpPostCity").focus();
                return;
            }
            if(areaname==""){
                alert(RS_js_SelectArea);
                document.getElementById("drpPostArea").focus();
                return;
            }
            
            if ($("#txtPostAddress").val() == "") {
                alert(RS_js_InputToUserAdd);
                $("#txtPostAddress").focus();
                return;
            }
            
            
            var paten=/^\d{6}$/;
            if (!paten.test($("#txtPostCode").val())) {
                alert(RS_js_InputToUserZipCode);
                $("#txtPostCode").focus();
                return;
            }
            //alert("Id:"+seqId+":"+$("#txtPostName").val()+":"+$("#txtPostAddress").val()+":"+$("#txtPostCode").val()+":"+$("#txtPostMobile").val()+":"+":"+provicename+":"+cityname+":"+areaname);
            var urlstr="action=updateAddressInfo&seqId="+seqId;
            urlstr=urlstr+"&postname="+escape($("#txtPostName").val());
            urlstr=urlstr+"&postmobile="+$("#txtPostMobile").val();
            urlstr=urlstr+"&postphone="+$("#txtPostPhone").val();
            urlstr=urlstr+"&provicename="+escape(provicename);
            urlstr=urlstr+"&cityname="+escape(cityname);
            urlstr=urlstr+"&areaname="+escape(areaname);
            urlstr=urlstr+"&postaddress="+escape($("#txtPostAddress").val());
            urlstr=urlstr+"&postcode="+$("#txtPostCode").val();
            urlstr=urlstr+"&date="+new Date().getTime();
            $.ajax
            ({
                type: "Get",
                url: 'CheckOut.aspx',
                data: urlstr,
                success: function(data, status) {                    
                    if (data != '') {
                        alert(data);
                        selectAddressInfo(seqId);
                    }
                },
                error: function(data, status, e) {
                    alert(data);
                }
            });
           }
           else{
                $("#btnUpdateAddressinfo").hide();
           }
        }
        //验证邮编
        function checkPostCode(){
            var v=$("#txtPostCode").val();
            if(v==""){
                alert(RS_js_PostCodeErr);
            }
            else{
                $.ajax
            ({
                type: "Get",
                url: '/CheckOut.aspx?action=checkpostcode&postcode=' + v + "&datetime=" + new Date().getTime(),
                beforeSend: function() { $("#postcodeCheckInfo2").html(RS_js_Running); },
                success: function(data, status) {
                    
                    if (data >-1 ) {                    
                        $("#postcodeCheckInfo2").html(RS_js_ExPostCode);
                        deliver_fee = data;
                    }
                    else {
                        $("#postcodeCheckInfo2").html(RS_js_ImpPostCode);
                    }
//                    var cartmoney = $("#_ctl0_ContentPlaceHolder1_totalcartAllPrices1").html();
//                    var minpaymentmoney = $("#_ctl0_ContentPlaceHolder1_shopMinDeliverMoney").html();
                    
                    var radDeliveTypelist = document.forms[0].radDeliveType;
                    for (i = 0; i < radDeliveTypelist.length; i++) {
                        radDeliveTypelist[i].checked = false;
                    }
                    var cartmoney = $("#_ctl0_ContentPlaceHolder1_totalcartAllPrices1").html();
                    var minpaymentmoney = $("#_ctl0_ContentPlaceHolder1_shopMinDeliverMoney").html();


                    $("#_ctl0_ContentPlaceHolder1_tranactionfee").html(0);
                    $("#_ctl0_ContentPlaceHolder1_totalcartAllPrices").html("" + (parseFloat(cartmoney)));


                    if (parseFloat(cartmoney) < parseFloat(minpaymentmoney)) {
                        $("#DeliveTypeIshow").hide();
                        hideHomeDelive();
                        dopaymentRadio(1);
                        var radDeliveTypelist = document.forms[0].radDeliveType;
                        for (i = 0; i < radDeliveTypelist.length; i++) {
                            if (radDeliveTypelist[i].value == "2") {
                                radDeliveTypelist[i].style["display"] = "none";
                                break;
                            }
                        }
                        //                            var olderrorInfo=$("#postcodeCheckInfo2").html();
                        //                            $("#postcodeCheckInfo2").html(olderrorInfo+",购物金额小于100支持欧尚不能配送！");
                        $("#moneycheckInfo").html(RS_js_ComeToStore);
                    }
                },
                error: function(data, status, e) {
                    alert(data);
                }
            });
            }
        }
         //验证邮编2
        function checkPostCode2(){
            var v = $("#" + masterIdStart + "lblPostCode").html();
            
            //alert(v);
            if(v==""){
                alert(RS_js_PostCodeErr);
            }
            else{
                $.ajax
            ({
                type: "Get",
                url: '/CheckOut.aspx?action=checkpostcode&postcode=' + v + "&datetime=" + new Date().getTime(),
                success: function(data, status) {

                    if (data > -1) {
                        $("#postcodeCheckInfo").html(RS_js_ExPostCode);
                        $("#DeliveTypeIshow").show();
                        deliver_fee = data;
                        hideHomeDelive();
                        //dopaymentRadio(0);
                    }
                    else {
                        $("#postcodeCheckInfo").html(RS_js_ImpPostCode);
                        $("#DeliveTypeIshow").hide();
                        hideHomeDelive();

                        dopaymentRadio(1);
                        //                        var radDeliveTypelist=document.forms[0].radDeliveType;
                        //                        for(i=0;i<radDeliveTypelist.length;i++){
                        //                                if(radDeliveTypelist[i].value=="2"){
                        //                                    radDeliveTypelist[i].style["display"]="none";
                        //                                    break;
                        //                                }
                        //                        }
                    }
                    var radDeliveTypelist = document.forms[0].radDeliveType;
                    for (i = 0; i < radDeliveTypelist.length; i++) {
                        radDeliveTypelist[i].checked = false;
                    }
                    var cartmoney = $("#_ctl0_ContentPlaceHolder1_totalcartAllPrices1").html();
                    var minpaymentmoney = $("#_ctl0_ContentPlaceHolder1_shopMinDeliverMoney").html();
                    
                    
                    $("#_ctl0_ContentPlaceHolder1_tranactionfee").html(0);
                    $("#_ctl0_ContentPlaceHolder1_totalcartAllPrices").html("" + (parseFloat(cartmoney)));
                    
                    //alert(cartmoney+":"+minpaymentmoney);
                    if (parseFloat(cartmoney) < parseFloat(minpaymentmoney)) {
                        $("#DeliveTypeIshow").hide();
                        hideHomeDelive();
                        dopaymentRadio(1);
                        //var radDeliveTypelist = document.forms[0].radDeliveType;
                        for (i = 0; i < radDeliveTypelist.length; i++) {
                            if (radDeliveTypelist[i].value == "2") {
                                radDeliveTypelist[i].style["display"] = "none";
                                break;
                            }
                        }
                        //                            var olderrorInfo=$("#postcodeCheckInfo2").html();
                        //                            $("#postcodeCheckInfo2").html(olderrorInfo+",购物金额小于100支持欧尚不能配送！");
                        $("#moneycheckInfo").html(RS_js_ComeToStore);
                    }
                },
                error: function(data, status, e) {
                    alert(data);
                }
            });
            }
        }
        //处理货到付款或货到刷卡
        function dopaymentRadio(type) {
            //alert(type);
            if(type==0){
                $("#Radio20").attr("disabled", "false");
                //$("#Radio20").attr("checked", "false");
                $("#radpaymentfukuan").attr("disabled","");
                $("#radpaymentshaka").attr("disabled", "");
                
            }
            else{
                $("#Radio20").attr("disabled","");
                $("#radpaymentfukuan").attr("disabled","false");
                $("#radpaymentshaka").attr("disabled", "false");

                //$("#radpaymentfukuan").attr("checked", "false");
                //$("#radpaymentshaka").attr("checked", "false");

            }
            //支付方式，需要从新选择
            var radPayMentTypelist = document.forms[0].radPayMentType;
            for (i = 1; i < radPayMentTypelist.length; i++) {
               
                radPayMentTypelist[i].checked = false;               
            }
            
        }
        //添加修改
        function addAddressInfo() {
        
            if ($("#txtPostName").val() == "") {
                alert(RS_js_InputToUserNm);
                $("#txtPostName").focus();
                return;
            }
            if ($("#txtPostMobile").val() == "" && $("#txtPostPhone").val() == "") {
                alert(RS_lt_CellPoneOrMobilePhone);
                $("#txtPostMobile").focus();
                return;
            }
            //验证手机
            var pre = new RegExp(/^(([0\+]\d{2,3}-)?(0\d{2,3})-)?(\d{7,8})(-(\d{3,}))?$/);
            var mre = new RegExp(/^((\(\d{3}\))|(\d{3}\-))?1\d{10}$/);

            if ($("#txtPostMobile").val() != "" && !mre.test($("#txtPostMobile").val())) {
                alert(errormobile);
                $("#txtPostMobile").focus();
                return;
            }

            if ($("#txtPostPhone").val() != "" && !pre.test($("#txtPostPhone").val())) {
                alert(errorphone);
                $("#txtPostPhone").focus();
                return;
            }
            
            var provicename="";
            var cityname="";
            var areaname="";
            var provicelist=document.getElementById(masterIdStart+"drpPostProvice");
            //alert(provicelist.options.length);
            for(i=0;i<provicelist.options.length;i++){
                if (provicelist.options[i].selected && parseInt(provicelist.options[i].value) > 0) {
                    provicename = provicelist.options[i].text;
                    break;
                }
            }
            
            var citylist=document.getElementById("drpPostCity");
            //alert(citylist.options.length);
            for(j=0;j<citylist.options.length;j++){
                if (citylist.options[j].selected && parseInt(citylist.options[j].value)>0) {
                    cityname = citylist.options[j].text;
                    break;
                }
            }
            var arealist=document.getElementById("drpPostArea");
            //alert(arealist.options.length);
            for(k=0;k<arealist.options.length;k++){
                if (arealist.options[k].selected && parseInt(arealist.options[k].value) > 0) {
                    areaname=arealist.options[k].text;
                    break;
                }
            }
            
            if(provicename==""){
                alert(RS_js_SelectProvince);
                document.getElementById(masterIdStart + "drpPostProvice").focus();
                return;
            }
            if(cityname==""){
                alert(RS_js_SelectCity);
                document.getElementById("drpPostCity").focus();
                return;
            }
            if(areaname==""){
                alert(RS_js_SelectArea);
                document.getElementById("drpPostArea").focus();
                return;
            }

            
            if ($("#txtPostAddress").val() == "") {
                alert(RS_js_InputToUserAdd);
                $("#txtPostAddress").focus();
                return;
            }
            

            var paten = /^\d{6}$/;
            if (!paten.test($("#txtPostCode").val())) {
                alert(RS_js_InputToUserZipCode);
                $("#txtPostCode").focus();
                return;
            }
            
            var urlstr="action=AddAddressInfo";
            urlstr=urlstr+"&postname="+escape($("#txtPostName").val());
            urlstr=urlstr+"&postmobile="+$("#txtPostMobile").val();
            urlstr=urlstr+"&postphone="+$("#txtPostPhone").val();
            urlstr=urlstr+"&provicename="+escape(provicename);
            urlstr=urlstr+"&cityname="+escape(cityname);
            urlstr=urlstr+"&areaname="+escape(areaname);
            urlstr=urlstr+"&postaddress="+escape($("#txtPostAddress").val());
            urlstr=urlstr+"&postcode="+$("#txtPostCode").val();
            urlstr=urlstr+"&date="+new Date().getTime();
            //alert(urlstr);
            $.ajax
            ({
                type: "Get",
                url: '/CheckOut.aspx',
                data: urlstr,
                success: function(data, status) {
                    if (data != '') {
                        alert(data);
                        viewAddressInfo();
                    }
                },
                error: function(data, status, e) {
                    alert(data);
                }
            });
        }
        //查看地址薄
        function loadAddressList(){
            $.ajax
            ({
                type: "Get",
                url: '/CheckOut.aspx',
                data: "action=showAll&date="+new Date().getTime(),
                success: function(data, status) {
                    if (data != '') {
                       var strlist="";
                       var json = JSON.parse(data);
                        for (var i = 0; i < json.length; i++) {
                            strlist=strlist+"<input type='radio' onclick='selectAddressInfo(this.value)' name='radlistAddressInfo' value='"+json[i].SEQ_ID+"'/>"+json[i].NC_NAME+" | "+json[i].NC_ADDRESS2+"<br/>";
                            
                        }
                        $("#viewAddressInfoDiv").html(strlist);
                    }
                    else{
                        $("#viewAddressInfoDiv").html(RS_js_NoAddress);
                    }
                },
                error: function(data, status, e) {
                    alert(data);
                }
            });
        }
        //选择收货的地址
        function selectAddressInfo(v){
            $("#"+masterIdStart+"hdnPostAddressId").val(v);
            exitAddressInfo();
            detailAddressInfo(v);
        }
        function changeDeliveTypeDiv(type){            
            if(type==0){
              
                dopaymentRadio(1);
 
                $("#deliverTimeTypeDiv").hide();
                $("#deliverTimeTypeDiv1").show();
                 //处理费用(是否添加运费)
                var cartmoney1 = $("#_ctl0_ContentPlaceHolder1_totalcartAllPrices1").html();
                $("#_ctl0_ContentPlaceHolder1_tranactionfee").html("0.00");
                $("#_ctl0_ContentPlaceHolder1_totalcartAllPrices").html("" + cartmoney1);
            }
            else {
                
               dopaymentRadio(0);
               
                $("#deliverTimeTypeDiv").show();
                $("#deliverTimeTypeDiv1").hide();
                //处理费用(是否添加运费)
                var cartmoney = $("#_ctl0_ContentPlaceHolder1_totalcartAllPrices1").html();
                var minpaymentmoney = $("#_ctl0_ContentPlaceHolder1_shopMinDeliverMoney").html();
                var maxpaymentmoney = $("#_ctl0_ContentPlaceHolder1_shopNoFreightMoney").html();
                //alert('deliver_fee=' + deliver_fee + ' cartmoney=' + cartmoney + '  minpaymentmoney=' + minpaymentmoney + ' maxpaymentmoney=' + maxpaymentmoney);
                if(parseFloat(cartmoney)>=parseFloat(minpaymentmoney)&&parseFloat(cartmoney)<parseFloat(maxpaymentmoney)){
                    $("#_ctl0_ContentPlaceHolder1_tranactionfee").html(deliver_fee);
                    $("#_ctl0_ContentPlaceHolder1_totalcartAllPrices").html("" + (parseFloat(cartmoney) + parseFloat(deliver_fee)));
                }
//                else{
//                    
//                }
                
            }
        }
        function changePaymentDiv(type){
            if(type==0){
                $("#payMentDiv").hide();
            }
            else{
                $("#payMentDiv").show();
            }
        }
        function changeInvoiceDiv(type){
            if(type==0){
                $("#invoiceDiv").hide();
            }
            else{
                $("#invoiceDiv").show();
            }
        }
        function InitCartcheckInfo(){
            //购物车的商品信息
             $.ajax({
               type: "POST",
               dataType:"json",
               url:"/DoshoppingCart.aspx?action=show&date="+new Date().getTime(),
               success:showcheckoutDiv});    
        }
        function showcheckoutDiv(json){
             if(json.myCart.length==0){
                //$("#cartBottom").hide();
             }
             else{
                //alert(json.TotalPrices);
                $("#totalcartAllPrices1").html(json.TotalPrices);
                $("#totalcartAllPrices").html(json.TotalPrices);
                $("#totalcartPoints").html(json.TotalPoint);
                $("#totalcartRefunds").html(json.TotalRefundPrice);
             }
        }
        //使用储蓄币
        function changeRefundPayDiv(type){
            if(type==0){
                $("#refundPayDiv").hide();
            }
            else{
                $("#refundPayDiv").show();
            }
        }
        function checkRefund(){
            var inputRefund=$("#"+masterIdStart+"txtRefund").val();
            if(inputRefund==""){
                alert(RS_lt_InputPaid);
                return false;
            }
            else{
                var tolcartPrices=$("#"+masterIdStart+"totalcartAllPrices1").html();
                var currentRefund=$("#"+masterIdStart+"hidMemberRefund").val();
                try{
                    if(parseFloat(inputRefund)>0&&parseFloat(inputRefund)<=parseFloat(currentRefund)&&parseFloat(inputRefund)<=parseFloat(tolcartPrices)){
                        //$("#"+masterIdStart+"membercardDiscount").html(inputRefund);
                        return true;
                    }
                    else{
                        alert(RS_lt_InputCorrect);
                        return false;
                    }
                }catch(e){
                    return false;
                }
            }
        }
        function hideHomeDelive() {
            $("#deliverTimeTypeDiv").hide();
            $("#deliverTimeTypeDiv1").show();
            var radDeliveTypelist = document.forms[0].radDeliveType;
            for (i = 0; i < radDeliveTypelist.length; i++) {
                if (radDeliveTypelist[i].value == 1)
                   radDeliveTypelist[i].checked = true;

           }
           var radDeliverTimelist = document.forms[0].radDeliverTime;
           for (i = 0; i < radDeliverTimelist.length; i++) {
               radDeliverTimelist[i].checked = false;
           }
            
        }
        function checksubmitInfo()
        {
            ShowDiv('lockd');            
            if(!checksubmitInfo2())
            {
              LockDiv.ClearLockDiv();
              return false;
            }
            return true;
        }
        //check submit form
        function checksubmitInfo2(){
            //check 配送时间
            //确定是否提交订单提示
            if (!confirm(RS_btn_confirminfo))
                return false;
            var DeliveTypeInfo=0;
            var radDeliveTypelist=document.forms[0].radDeliveType;
            for(i=0;i<radDeliveTypelist.length;i++){
                    if(radDeliveTypelist[i].checked){
                        DeliveTypeInfo=radDeliveTypelist[i].value;
                        break;
                    }
                }
              
            if(DeliveTypeInfo==2){
                var delivetime="";
                var radDeliverTimelist=document.forms[0].radDeliverTime;
                for(i=0;i<radDeliverTimelist.length;i++){
                    if(radDeliverTimelist[i].checked){
                        delivetime=radDeliverTimelist[i].value;
                        break;
                    }
                }
                if(delivetime==""){
                    alert(RS_js_SelectDeliveTime);
                    return false;
                }
                //check 送货地址
                var seqId = $("#" + masterIdStart + "hdnPostAddressId").val();
                
                if(/^[1-9][\d]*$/.test(seqId)==false){
                    alert(RS_js_CheckToUserInfo);
                    return false;
                }
            }
            else{
                //if($("#"+masterIdStart+"txtDeliveByoneSelfTime").val()==""){
                //    alert(RS_js_InputTakeTime);
                //    return false;
                //}
                //check 送货地址
                var seqId = $("#" + masterIdStart + "hdnPostAddressId").val();
                
                if (/^[1-9][\d]*$/.test(seqId) == false) {
                    alert(RS_js_CheckToUserInfo);
                    return false;
                }
                
                if ($("#" + masterIdStart + "drpTakeDate").val() == "-1" || $("#" + masterIdStart + "drpTakeTime").val() == "-1") {
                    alert(RS_js_InputTakeTime);
                    return false;
                }
            }
            
            //总价
            var cartmoney=$("#_ctl0_ContentPlaceHolder1_totalcartAllPrices1").html();
            if(cartmoney=="0.00"){
                alert(RS_js_ShopCartEmpty);
                return false;
            }
            var minpaymentmoney=$("#"+masterIdStart+"shopMinDeliverMoney").html();
            if(parseFloat(cartmoney)<parseFloat(minpaymentmoney)){
                if(DeliveTypeInfo==2){
                    alert(RS_js_Sorry);
//                    $("#DeliveTypeIshow").hide();
//                    $("#deliverTimeTypeDiv").hide();
                    return false;
                }
            }
            //check 支付方式
            var payMentTypeInfo=0;
            var radPayMentTypelist=document.forms[0].radPayMentType;
            for(i=0;i<radPayMentTypelist.length;i++){
                    if(radPayMentTypelist[i].checked){
                        payMentTypeInfo=radPayMentTypelist[i].value;
                        break;
                    }
            }
            if(payMentTypeInfo==0){
                alert(RS_js_SelectPayMethod);
                return false;
            }
            else{
                if(payMentTypeInfo==1){
                    var paymentTypevInfo2="";
                    var paymentTypevalueList = document.forms[0].paymodel;
//                    alert(paymentTypevalueList.length);
                    for(i=0;i<paymentTypevalueList.length;i++){
                        if(paymentTypevalueList[i].checked){
                            paymentTypevInfo2=paymentTypevalueList[i].value;
                            break;
                        }
                    }
                    if(paymentTypevInfo2==""){
                        alert(RS_js_SelectPayOnline);
                        return false;
                    }
                }
            }
            //check 发票
            var radInvoicetitleTypev=0;
            var radInvoicetitleTypeList=document.forms[0].radInvoicetitleType;
            for(i=0;i<radInvoicetitleTypeList.length;i++){
                if(radInvoicetitleTypeList[i].checked){
                    radInvoicetitleTypev=radInvoicetitleTypeList[i].value;
                    break;
                }
            }
            if(radInvoicetitleTypev>0){
                if(radInvoicetitleTypev==2){
                    if($("#"+masterIdStart+"txtInvoicetitleType").val()==""){
                        alert(RS_js_InputBillInfo);
                        return false;
                    }
                }
            }
//            var bln;
//             bln=show("是否要将签核过程打印在页面后?")
//           switch(bln)   
//            {
//                 case   6://是
//                      $("#hidPayIm").val("1");
//                     break;
//                 case   7://否
//                     $("#hidPayIm").val("0");  
//                     break;   
//                 case   2://取消
//                    return false;
//             }

            
            
//            if (confirm("确定立即支付吗？")) {
//                $("#hidPayIm").val("1");
//            }
//            else {
//                $("#hidPayIm").val("0");                
//            }
            checkinput();
            document.getElementById(masterIdStart + "btnOK").style.dispaly = "none";
            //ShowDiv('lockd');
            return true;
        }
        function checkinput() {
            var mPat = /[<>]/g;
            //var reg = new RegExp(mPat);
            var remark = $("#" + masterIdStart + "txtRemark").val();
            var invoiceTitle = $("#" + masterIdStart + "txtInvoicetitleType").val();
            
            if (remark != "") {
                $("#" + masterIdStart + "txtRemark").val(remark.replace(mPat,""));
            }
            if (invoiceTitle != "") {
                $("#" + masterIdStart + "txtInvoicetitleType").val(invoiceTitle.replace(mPat, ""));
            }
        }
//*************************joson
    http://www.JSON.org/json2.js

// methods in a closure to avoid creating global variables.

var JSON = JSON || {};

(function () {

    function f(n) {
        // Format integers to have at least two digits.
        return n < 10 ? '0' + n : n;
    }

    if (typeof Date.prototype.toJSON !== 'function') {

        Date.prototype.toJSON = function (key) {

            return this.valueOf() ? this.getUTCFullYear()   + '-' +
                 f(this.getUTCMonth() + 1) + '-' +
                 f(this.getUTCDate())      + 'T' +
                 f(this.getUTCHours())     + ':' +
                 f(this.getUTCMinutes())   + ':' +
                 f(this.getUTCSeconds())   + 'Z' : null;
        };

        String.prototype.toJSON =
        Number.prototype.toJSON =
        Boolean.prototype.toJSON = function (key) {
            return this.valueOf();
        };
    }

    var cx = /[\u0000\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/g,
        escapable = /[\\\"\x00-\x1f\x7f-\x9f\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/g,
        gap,
        indent,
        meta = {    // table of character substitutions
            '\b': '\\b',
            '\t': '\\t',
            '\n': '\\n',
            '\f': '\\f',
            '\r': '\\r',
            '"' : '\\"',
            '\\': '\\\\'
        },
        rep;


    function quote(string) {

// If the string contains no control characters, no quote characters, and no
// backslash characters, then we can safely slap some quotes around it.
// Otherwise we must also replace the offending characters with safe escape
// sequences.

        escapable.lastIndex = 0;
        return escapable.test(string) ?
            '"' + string.replace(escapable, function (a) {
                var c = meta[a];
                return typeof c === 'string' ? c :
                    '\\u' + ('0000' + a.charCodeAt(0).toString(16)).slice(-4);
            }) + '"' :
            '"' + string + '"';
    }


    function str(key, holder) {

// Produce a string from holder[key].

        var i,          // The loop counter.
            k,          // The member key.
            v,          // The member value.
            length,
            mind = gap,
            partial,
            value = holder[key];

// If the value has a toJSON method, call it to obtain a replacement value.

        if (value && typeof value === 'object' &&
                typeof value.toJSON === 'function') {
            value = value.toJSON(key);
        }

// If we were called with a replacer function, then call the replacer to
// obtain a replacement value.

        if (typeof rep === 'function') {
            value = rep.call(holder, key, value);
        }

// What happens next depends on the value's type.

        switch (typeof value) {
        case 'string':
            return quote(value);

        case 'number':

// JSON numbers must be finite. Encode non-finite numbers as null.

            return isFinite(value) ? String(value) : 'null';

        case 'boolean':
        case 'null':

// If the value is a boolean or null, convert it to a string. Note:
// typeof null does not produce 'null'. The case is included here in
// the remote chance that this gets fixed someday.

            return String(value);

// If the type is 'object', we might be dealing with an object or an array or
// null.

        case 'object':

// Due to a specification blunder in ECMAScript, typeof null is 'object',
// so watch out for that case.

            if (!value) {
                return 'null';
            }

// Make an array to hold the partial results of stringifying this object value.

            gap += indent;
            partial = [];

// Is the value an array?

            if (Object.prototype.toString.apply(value) === '[object Array]') {

// The value is an array. Stringify every element. Use null as a placeholder
// for non-JSON values.

                length = value.length;
                for (i = 0; i < length; i += 1) {
                    partial[i] = str(i, value) || 'null';
                }

// Join all of the elements together, separated with commas, and wrap them in
// brackets.

                v = partial.length === 0 ? '[]' :
                    gap ? '[\n' + gap +
                            partial.join(',\n' + gap) + '\n' +
                                mind + ']' :
                          '[' + partial.join(',') + ']';
                gap = mind;
                return v;
            }

// If the replacer is an array, use it to select the members to be stringified.

            if (rep && typeof rep === 'object') {
                length = rep.length;
                for (i = 0; i < length; i += 1) {
                    k = rep[i];
                    if (typeof k === 'string') {
                        v = str(k, value);
                        if (v) {
                            partial.push(quote(k) + (gap ? ': ' : ':') + v);
                        }
                    }
                }
            } else {

// Otherwise, iterate through all of the keys in the object.

                for (k in value) {
                    if (Object.hasOwnProperty.call(value, k)) {
                        v = str(k, value);
                        if (v) {
                            partial.push(quote(k) + (gap ? ': ' : ':') + v);
                        }
                    }
                }
            }

// Join all of the member texts together, separated with commas,
// and wrap them in braces.

            v = partial.length === 0 ? '{}' :
                gap ? '{\n' + gap + partial.join(',\n' + gap) + '\n' +
                        mind + '}' : '{' + partial.join(',') + '}';
            gap = mind;
            return v;
        }
    }

// If the JSON object does not yet have a stringify method, give it one.

    if (typeof JSON.stringify !== 'function') {
        JSON.stringify = function (value, replacer, space) {

// The stringify method takes a value and an optional replacer, and an optional
// space parameter, and returns a JSON text. The replacer can be a function
// that can replace values, or an array of strings that will select the keys.
// A default replacer method can be provided. Use of the space parameter can
// produce text that is more easily readable.

            var i;
            gap = '';
            indent = '';

// If the space parameter is a number, make an indent string containing that
// many spaces.

            if (typeof space === 'number') {
                for (i = 0; i < space; i += 1) {
                    indent += ' ';
                }

// If the space parameter is a string, it will be used as the indent string.

            } else if (typeof space === 'string') {
                indent = space;
            }

// If there is a replacer, it must be a function or an array.
// Otherwise, throw an error.

            rep = replacer;
            if (replacer && typeof replacer !== 'function' &&
                    (typeof replacer !== 'object' ||
                     typeof replacer.length !== 'number')) {
                throw new Error('JSON.stringify');
            }

// Make a fake root object containing our value under the key of ''.
// Return the result of stringifying the value.

            return str('', {'': value});
        };
    }


// If the JSON object does not yet have a parse method, give it one.

    if (typeof JSON.parse !== 'function') {
        JSON.parse = function (text, reviver) {

// The parse method takes a text and an optional reviver function, and returns
// a JavaScript value if the text is a valid JSON text.

            var j;

            function walk(holder, key) {

// The walk method is used to recursively walk the resulting structure so
// that modifications can be made.

                var k, v, value = holder[key];
                if (value && typeof value === 'object') {
                    for (k in value) {
                        if (Object.hasOwnProperty.call(value, k)) {
                            v = walk(value, k);
                            if (v !== undefined) {
                                value[k] = v;
                            } else {
                                delete value[k];
                            }
                        }
                    }
                }
                return reviver.call(holder, key, value);
            }


// Parsing happens in four stages. In the first stage, we replace certain
// Unicode characters with escape sequences. JavaScript handles many characters
// incorrectly, either silently deleting them, or treating them as line endings.

            cx.lastIndex = 0;
            if (cx.test(text)) {
                text = text.replace(cx, function (a) {
                    return '\\u' +
                        ('0000' + a.charCodeAt(0).toString(16)).slice(-4);
                });
            }

// In the second stage, we run the text against regular expressions that look
// for non-JSON patterns. We are especially concerned with '()' and 'new'
// because they can cause invocation, and '=' because it can cause mutation.
// But just to be safe, we want to reject all unexpected forms.

// We split the second stage into 4 regexp operations in order to work around
// crippling inefficiencies in IE's and Safari's regexp engines. First we
// replace the JSON backslash pairs with '@' (a non-JSON character). Second, we
// replace all simple value tokens with ']' characters. Third, we delete all
// open brackets that follow a colon or comma or that begin the text. Finally,
// we look to see that the remaining characters are only whitespace or ']' or
// ',' or ':' or '{' or '}'. If that is so, then the text is safe for eval.

            if (/^[\],:{}\s]*$/.
test(text.replace(/\\(?:["\\\/bfnrt]|u[0-9a-fA-F]{4})/g, '@').
replace(/"[^"\\\n\r]*"|true|false|null|-?\d+(?:\.\d*)?(?:[eE][+\-]?\d+)?/g, ']').
replace(/(?:^|:|,)(?:\s*\[)+/g, ''))) {

// In the third stage we use the eval function to compile the text into a
// JavaScript structure. The '{' operator is subject to a syntactic ambiguity
// in JavaScript: it can begin a block or an object literal. We wrap the text
// in parens to eliminate the ambiguity.

                j = eval('(' + text + ')');

// In the optional fourth stage, we recursively walk the new structure, passing
// each name/value pair to a reviver function for possible transformation.

                return typeof reviver === 'function' ?
                    walk({'': j}, '') : j;
            }

// If the text is not JSON parseable, then a SyntaxError is thrown.

            throw new SyntaxError('JSON.parse');
        };
    }
}());

