
var jsonPdtInfo = '';//添加商品时查询出的商品信息json数据
var Spec = '';
var SepcDesc = '';
var productID = '0';

$(document).ready(function(){
    //loading
    $('#loadingContainer').ajaxStart(function(){$(this).show();$('#loadingbackground').show().css({"opacity": "0.5"});}).ajaxStop(function(){$(this).hide();});
	settab();
    setInterval(function(){
        if(getQueryStringRegExp('from') != 'list'){
            $('div.save').css('top',$(window.parent.frames.right).height()-$('div.save').height()); //设置底部分页区域的位置
            $('div.sub_container_content').css('height',$(window.parent.frames.right).height()-$('div.save').height()-$(".sub_container_title").height()-20); //设置内容区域的高度
        }else{//从列表页面链接过来修改
            var windowHeight = $('#frmHeight',window.parent.document).val();
            $('div.save').css('top',windowHeight-$('div.save').height()); //设置底部分页区域的位置
            $('div.sub_container_content').css('height',windowHeight-$('div.save').height()-$(".sub_container_title").height()-25); //设置内容区域的高度
        }
    },1000);

    //取消修改
    $('#btnBack').click(function(){
        if(getQueryStringRegExp('from') == 'list'){
            $('#frmModify',window.parent.document).hide().siblings(':not("#loadingContainer")').show();
            window.parent.BindList();
        }
    });
    setEnable(paytype,status);
    $('input[@id^=cb]').click(function(){
        $('input[@id^=cb]').attr('checked',false);
		$(this).attr('checked',true);
    });
    
    //add time 2009-10-24
    $('input[@name=quantity]').each(function(i,obj){
        ChangeQuantity($(obj));
    });
    
    $('input[@name^=unitPrice]').each(function(i,obj){
        ChangeUnitPrice($(obj));
    });
    
    //add time 2009-10-26
    $('#chkNeedInvoice').click(function(){
        $('#txtTaxPrice').attr('readonly',!$('#chkNeedInvoice').attr('checked'));
        if($(this).attr('checked')){
            $('#txtTaxPrice').removeClass('disabled');
        }else{
            $('#txtTaxPrice').addClass('disabled');
        };
        setPrice();
    });
    
    $('input[@readonly]').addClass('disabled');
    
    //改变运费
    $('#txtShipPrice').change(function(){
        var shipPrice = $.trim($(this).val());
        if(shipPrice == ''){$(this).val('0');};        
        if(!isMoney($(this))){
            alert('商品运费填写有误!');
            return false;
        }else{
            setPrice();
        };
    });
    
    $('#btnChangePrice').click(function(){
        $('#showChangePrice').popup({width:'60%',height:'250px',top:'100',popupHead:'ChangePriceHead',btnClose:'ChangePriceClose'});
    });
    
    //改变税金
    $('#txtTaxPrice').change(function(){
        var taxPrice = $.trim($(this).val());
        if(taxPrice == ''){$(this).val('0');};
        if(!isMoney($(this))){
            alert('商品税金填写有误!');
            return false;
        }else{
            setPrice();
        };
    });
    
    //改变订单金额
    $('#txtChangedPrice').change(function(){
        var changedPrice = $.trim($(this).val());
        if(changedPrice == ''){
            $(this).val('0');
        };
        if(isNaN($(this).val())){
            alert('更改的订单价格填写有误!');return false;
        }else{
            setPrice();
        };
    });
    
    var tipwords = '输入商品编号或商品ID';
    $('#txtQueryKey').focus(function(){
        if($(this).val() == tipwords){
            $(this).val('').removeClass('disabled');
        };
    }).blur(function(){
        if($.trim($(this).val()) == ''){
            $(this).val(tipwords).addClass('disabled');
        }
    }).val(tipwords).addClass('disabled');
    
    //点击查询商品信息
    $('#btnQuery').click(function(){
        if($.trim($('#txtQueryKey').val()) == tipwords){
            alert('请在文本框里输入商品编号或ID');
            return false;
        }else{
            QueryPdtInfo();
        };
    });
    
    $('#btnAddPdt').click(function(){
        var gid = $('#tmp_GID').val();
        if(gid == '0'){
            alert('请先选择要添加的商品');return;
        }else{
            var isExist = false;
            $('[name=GID]').each(function(){
                if($(this).val() == gid){
                    isExist = true;
                    return;
                }
            });
            if(isExist){
                alert('此商品已在订单中');return;
            }else{
                var isDiscount = (jsonPdtInfo.IsDiscount.toLowerCase() == 'true');
                var row = '<tr>';
                row += '<td align="center" height="20">' + jsonPdtInfo.ProductNo + '</td>';
                row += '<td align="left">' + jsonPdtInfo.ProductName + '<input type="hidden" name="orderpid" value="' + jsonPdtInfo.ProductID + '" /><input type="hidden" name="GID" value="' + gid + '" /></td>';
                row += '<td align="left">' + unescape($('#spectext').val()) + '<input type="hidden" name="specvalue" value="' + $('#spectext').val() + '" /></td>';
                row += '<td align="center"><input name="quantity" type="text" class="inputstyle" value="1" size="7" maxlength="10"/></td>';
                row += '<td align="left"><input name="unitPrice" type="text" value="' + jsonPdtInfo.MemberPrice + '" size="7" maxlength="10"/>' + (isDiscount ? '×' + discount + '%' : '') + '</td>';
                var subPrice = (isDiscount ? (Number(jsonPdtInfo.MemberPrice) * Number(discount) / 100).toFixed(2) : Number(jsonPdtInfo.MemberPrice).toFixed(2));
                row += '<td align="center"><span name="SubPrice">' + subPrice + '</span><input type="hidden" name="SubPrice" value="' + subPrice + '" /></td>';
                row += '<td align="center">' + (isDiscount ? '是' : '否') + '<input type="hidden" name="discount" value="' + (jsonPdtInfo.IsDiscount == 'True' ? '1' : '0') + '"/></td>';
                row += '<td align="center"><span class="hand deletePdt" style="color:Red;">删除</span></td>';
                row += '</tr>';
                row = $(row);
                row.find('span.deletePdt').click(function(){
                    if(confirm('确定要删除此商品吗?')){
                        row.remove();
                        SetCurrPIDs();
                        setPrice();
                    };
                });
                $('#tbPdts tbody').append(row);
                row.find('[@name=quantity]').change(function(){ChangeQuantity($(this));});
                row.find('[@name=unitPrice]').change(function(){ChangeUnitPrice($(this));});
                
                SetCurrPIDs();
                setPrice();
            };//end else
        };//end else
    });//end click
    
    //add time 2009-10-27
    //记录当前订单里的PID
    var pid_old = '';
    $('input[@name=orderpid]').each(function(){
        pid_old += $(this).val() + ',';
    });
    if(pid_old != ''){
        pid_old = pid_old.substring(0,pid_old.length-1);
    };
    $('#OrderPID_old').val(pid_old);
    $('#OrderPID_curr').val(pid_old);
    
    //记录当前订单里的GoodsID
    var gid_old = '';
    $('input[@name=GID]').each(function(){
        gid_old += $(this).val() + ',';
    });
    if(gid_old != ''){
        gid_old = gid_old.substring(0,gid_old.length-1);
    };
    $('#OrderGID_old').val(gid_old);
    $('#OrderGID_curr').val(gid_old);
    
    $('span.deletePdt').click(function(){
        if(confirm('确定要删除此商品吗?')){
            $(this).parent().parent().remove();
            SetCurrPIDs();
            setPrice();
        };
    });
    
    $('#ddlPayType').change(function(){
        setPaymentVisible();
        var newPaytype = $(this).val();
        if(newPaytype == '5' || newPaytype == '6'){
            if(status == '0'){status='2'};
            $('label[@for=cb2]').text('未确认');
        }else{
            if(status == '2'){status='0'};
            $('label[@for=cb2]').text('已付款');
        }
        setEnable(newPaytype,status);
    });
    setPaymentVisible();
    
    //回复订单留言
    $('[@revid]').click(function(){
        var revID = $(this).attr('revid');
        var objRev = $(this);
        objRev.hide();
        $('#txtReview_'+revID).show();
        $('#saverev_'+revID).show().unbind().click(function(){
            var reply = $.trim($('#txtReview_'+revID).val());
            if(reply == ''){alert('请填写回复内容');return false;};
            $.ajax({
                url:'OrderModify.aspx?NoCopyRight=1&type=ajax&Action=ReviewReply&Reply=' + escape(reply) + '&ReviewID=' + revID,
                cache:false,
                success:function(data){
                    if(!checkLoginStatus(data)){return false;};
                    if(data > 0){
                        $('#txtReview_'+revID).hide().parent().text(reply);
                        $('#saverev_'+revID).parent().html('已回复');
                    };
                },
                error:function(){alert('error')}
            });
        });
        $('#cancelrev_'+revID).show().unbind().click(function(){
            $('#txtReview_'+revID).hide();
            objRev.show().siblings().hide();
        });
        
    });
    
    $('#btnRefund').click(function(){
        $('#ShowRefund').show();
    });
    
    //确认已签收
    $('#doReceived').click(function(){
        if(confirm('确认签收吗？')){
            var postdata = 'NoCopyRight=1&type=ajax&Action=ConfirmReceived&oid='+orderID;
            $.ajax({
                url:'OrderModify.aspx',
                type:'POST',
                data:postdata,
                success:function(data){
                    if(data==='ok'){
                        window.location.reload();
                    }else{
                        alert(data);
                    }
                },
                error:function(XMLHttpRequest,textStatus){if(textStatus=='parsererror'){alert('身份已过期,请重新登陆!')}else{alert('error')};}
            });//end ajax
        };//end if
    });
    
    //交易完成
    $('#doComplete').click(function(){
        if(confirm('确认完成吗？')){
            var postdata = 'NoCopyRight=1&type=ajax&Action=OrderComplete&oid='+orderID;
            $.ajax({
                url:'OrderModify.aspx',
                type:'POST',
                data:postdata,
                success:function(data){
                    if(data==='ok'){
                        window.location.reload();
                    }else{
                        alert(data);
                    }
                },
                error:function(XMLHttpRequest,textStatus){if(textStatus=='parsererror'){alert('身份已过期,请重新登陆!')}else{alert('error')};}
            });//end ajax
        };//end if
    });
    
});//end ready

function ChangeQuantity(curObj){
    curObj.blur(function(){
        if(!isInt(curObj)){
            alert('数量填写错误');
            return false;
        }else{
            if(curObj.val()==0){curObj.val('1')};
            var subTotal = Number(curObj.val())*Number(curObj.parent().siblings().find('input[@name=unitPrice]').val());
            var isDiscount = curObj.parent().siblings().find('input[@name=discount]').val();
            if(isDiscount != '0'){
                subTotal = subTotal * Number(discount)/100;
            }
            curObj.parent().siblings().find('span[@name=SubPrice]').text(subTotal.toFixed(2)).next().val(subTotal.toFixed(2));
        };
        setPrice();
    });
};

function ChangeUnitPrice(curObj,isDiscount){
    curObj.blur(function(){
        if(!isMoney(curObj)){
            alert('价格填写错误');
            return false;
        }else{
            var subTotal = Number(curObj.parent().siblings().find('input[@name=quantity]').val())*Number(curObj.val());
            var isDiscount = curObj.parent().siblings().find('input[@name=discount]').val();
            if(isDiscount != '0'){
                subTotal = subTotal * Number(discount)/100;
            }
            curObj.parent().siblings().find('span[name=SubPrice]').text(subTotal.toFixed(2)).next().val(subTotal.toFixed(2));
        };
        setPrice();
    });
};

function setPaymentVisible(){
    if($('#ddlPayType').val() == '1'){
        $('#ddlOnlinePayment').show();
    }else{
        $('#ddlOnlinePayment').hide();
    };
    
    if($('#ddlPayType').val() == '6'){
        $('#ddlZtds').show();
    }else{
        $('#ddlZtds').hide();
    };
};

//tab
function settab(){
    var items = $('li.menuitem').length;
    $('li.menuitem').each(function(index){
        $(this).click(function(){
            $(this).addClass('tabon').removeClass('tabout').siblings('.menuitem').removeClass('tabon').addClass('tabout');
            if(index != 0){
                $('div.tab').hide();
                $('div.tab').eq(index - 1).show();
            }else{
                $('div.tab').show();
            };
        });
    });
};

//获取URL中参数
function getQueryStringRegExp(name){    
	var reg = new RegExp("(^|\\?|&)"+ name +"=([^&]*)(\\s|&|$)", "i");
	if (reg.test(location.href))
		return unescape(RegExp.$2.replace(/\+/g, " "));
		return "";
};

//add time 2009-10-24
function isMoney(obj){
	var dot = 0;//小数点个数
	var tmp = obj.val();
	while(tmp.indexOf('.') != -1){
	    dot += 1;
	    tmp = tmp.replace('.','_');
	};
	var reg = new RegExp(/[^\d\.]/g);
	if(reg.test(obj.val()) || $.trim(obj.val()) == '' || dot > 1){
	    obj.focus();
	    return false;
	};
	return true;
};

function isInt(obj){
	var reg = new RegExp(/\D/g);
	if(reg.test(obj.val()) || $.trim(obj.val()) == ''){
	    obj.focus();
	    return false;
	};
	return true;
};

function setPrice(){
    var productPrice = 0;
    var orderTotalPrice = 0;
    var leftTotal = 0;
    $('span[name=SubPrice]').each(function(i,obj){
        productPrice += Number($(obj).text()); 
    });
    $('#txtProductPrice').val(productPrice.toFixed(2));//商品总价
    
    orderTotalPrice = productPrice + Number($('#txtShipPrice').val()) + Number($('#txtChangedPrice').val());
    if($('#chkNeedInvoice').attr('checked')){
        orderTotalPrice += Number($('#txtTaxPrice').val());
    }
    $('#txtTotalPrice').val(orderTotalPrice.toFixed(2));//订单总价
    
    leftTotal = orderTotalPrice - Number($('#txtAdvancePayment').val());
    $('#txtPaymentMoney').val(leftTotal.toFixed(2));
};

function QueryPdtInfo(){
    var flag = false;
    $.ajax({
        url:'OrderModify.aspx?NoCopyRight=1&type=ajax&Action=QueryProduct&QueryType=' + $('[@name=rdQueryType][@checked]').val() + '&QueryKey='+escape($('#txtQueryKey').val()) + '&OrderID='+orderID + '&deletedGids=' + ($('#OrderGID_deleted').val()),
        dataType:'json',
        cache:false,
        async:false,
        success:function(msg){
            var exist = msg.Exist;
            if(msg.Exist == 'true'){
                //商品在订单中已经存在
                alert('此商品在订单中已经存在');
            }else{
                var data = msg.Product;
                if(data.length > 0){
                    var n = data[0];
                    jsonPdtInfo = data[0];//全局变量
                    productID = n.ProductID
                    $('#queryResult').html('<td>查询结果：</td><td>商品名称：<a href="../products/product-' + n.ProductID + '.html" target="_blank">' + n.ProductName + '</a>　编号：' + n.ProductNo + '　会员价格：' + n.MemberPrice + '　是否打折：' + (n.IsDiscount.toLowerCase() == 'true' ? '是' : '否') + '　状态：' + (n.Status == -1 ? '已删除' : (n.Status == 1 ? '发布':'未发布')) + '</td>');
                    flag = true;
                    
                    //给全局变量赋值
                    Spec = n.Spec;
                    SpecDesc = n.SpecDesc;
                    ShowSpecs();
                }else{
                    alert('没找到商品');
                    $('#queryResult').html('<td>查询结果：</td><td>没找到商品</td>');
                    $('#Specs').hide();
                    $('#SpecItems').html('<tr><td></td></tr>');
                    $('#spectext').val('');
                    Spec = '';
                    SpecDesc = '';
                    $('#tmp_GID').val('0');
                    flag = false;
                };
            };
        },
        error:function(XMLHttpRequest,textStatus){if(textStatus=='parsererror'){alert('身份已过期,请重新登陆!')}else{alert('error')};}
    });
    return flag;
};

var mainSpecCount = 0;//记录主规格的数量
var subSpecCount = 0;//记录次规格数量
var mainSpecName = '';//当前商品的主规格名称
var mainSpecValue = '';//当前商品的主规格值
function ShowSpecs(){
    if($.trim(Spec) != ''){
        //有规格的情况，看是否有子规格
        var subSpecCount = 0;
        Spec = eval('(' + Spec + ')');
        $('#SpecItems').children().remove();
        $.each(Spec.Specs,function(i,n){
            if(n.IsMain == '1'){
                mainSpecCount += 1;
                mainSpecName = n.SpecName;
                $.each(n.Contain,function(j,m){
                    if(m.PID == productID){
                        mainSpecValue = m.Pro;
                    };
                });//end each
            }else{
                subSpecCount += 1;
                var tr = $('<tr></tr>');
                tr.append('<td>' + n.SpecName + '：</td>');
                var td = $('<td></td>');
                //循环次规格的每一项值
                $.each(n.Contain,function(j,m){
                    var radio = $('<input type="radio" id="spec_' + i + '_'+ j +'" name="spec_' + i + '" specname=' + n.SpecName + ' value="' + m + '" ' + (j == 0 ? 'checked=checked' : '') + ' /><label for="spec_' + i + '_'+ j +'">' + m + '</label>　　');
                    radio.click(function(){
                        SelectSpecs();
                    }).appendTo(td);
                });
                tr.append(td);
                $('#SpecItems').append(tr);
            };//end if
        });//end each
        if(subSpecCount > 0){$('#Specs').show()}else{$('#Specs').hide()};
    }else{
        //没有规格的情况，只需记录下GoodsID
        if($.trim(SpecDesc) != ''){
            var goods = eval('(' + SpecDesc + ')').Goods;
            $('#GID').val(goods[0].GID);
        };
    }//end else
    $('input[type=radio][name^=spec_][@checked]').eq(0).click();
};

function SelectSpecs(){
    var selected_values = '';//记录选择的尺寸,用来匹配对应的GoodsID
    var text_spec_result = '';//存入数据库的文本内容
    if(mainSpecCount > 0){
        text_spec_result += mainSpecName + '：' + mainSpecValue + '<br/>';
    };
    $('input[type=radio][name^=spec_][@checked]').each(function(){
        selected_values += $(this).val() + ' ';
        text_spec_result += $(this).attr('specname') + '：' + $(this).val() + '<br/>';
    });
    if(selected_values != ''){
        selected_values = selected_values.substring(0,selected_values.length-1);
        text_spec_result = text_spec_result.substring(0,text_spec_result.length-5);
    };
    
    if($.trim(SpecDesc) != ''){
        var goods = eval('(' + SpecDesc + ')').Goods;
        $.each(goods,function(i,n){
            if(selected_values == n.Desc){
                $('#tmp_GID').val(n.GID);
            };
        });
    };
    $('#spectext').val(escape(text_spec_result));
    
    if($('#tmp_GID').val() != '0'){
        $('#btnAddPdt').removeAttr('disabled');
    }else{
        $('#btnAddPdt').attr('disabled','disabled');
    };
};

function GetPIDs(oldIDs,currIDs){
    var arryPID_old = oldIDs.split(',');
    var arryPID_curr = currIDs.split(',');
    //循环后arryPID_old里剩下的ID为需要从数据库里删除的ID,arryPID_curr里剩下的ID为需要添加到数据库中的ID
    if(oldIDs != ''){
        for(var i=0;i<arryPID_old.length;i++){
            for(var j=0;j<arryPID_curr.length;j++){
                if(arryPID_old[i]==arryPID_curr[j]){
                    arryPID_old.splice(i,1);arryPID_curr.splice(j,1);
                    i--;j--;
                    break;
                };
            };
        };
    };
    
    return arryPID_curr.toString() + "|" + arryPID_old.toString();
}

function SetCurrPIDs(){
    var pid_curr = '';
    $('input[@name=orderpid]').each(function(i,n){
        pid_curr += $(this).val() + ',';
    });
    if(pid_curr != ''){
        pid_curr = pid_curr.substring(0,pid_curr.length-1);
    };
    $('#OrderPID_curr').val(pid_curr);
    
    var result = GetPIDs($('#OrderPID_old').val(),$('#OrderPID_curr').val()).split('|');
    $('#OrderPID_new').val(result[0]);
    $('#OrderPID_deleted').val(result[1]);
    
    //要删除的GoodsID和新增的GoodsID
    var gid_curr = '';
    $('input[@name=GID]').each(function(i,n){
        gid_curr += $(this).val() + ',';
    });
    if(gid_curr != ''){
        gid_curr = gid_curr.substring(0,gid_curr.length-1);
    };
    $('#OrderGID_curr').val(gid_curr);
    
    result = GetPIDs($('#OrderGID_old').val(),$('#OrderGID_curr').val()).split('|');
    $('#OrderGID_new').val(result[0]);
    $('#OrderGID_deleted').val(result[1]);
};

//2009-10-28

function checkLoginStatus(data){
    var result = true;
    if(data.indexOf('<!DOCTYPE') != -1){
        result = false;
        alert('身份已过期,请重新登陆!');
    };
    return result;
};

function setEnable(paytype,status){
	$('input[@id^=cb]').attr('disabled','disabled').attr('checked',false);
	$('#cb' + status).removeAttr('disabled');
	$('#cb' + status).attr('checked',true);
	switch(paytype)
	{
		case '1':
			switch(status)
			{
				case '0':
					$('#cb1').removeAttr('disabled');$('#cb2').removeAttr('disabled');
					break;
				case '1':
					$('#cb2').removeAttr('disabled');
					break;
				case '2':
					$('#cb3').removeAttr('disabled');
					break;
				case '3':
					$('#cb4').removeAttr('disabled');
					break;
				case '4':
					$('#cb5').removeAttr('disabled');$('#cb6').removeAttr('disabled');
					break;
				case '5':
					$('#cb7').removeAttr('disabled');$('#cb8').removeAttr('disabled');
					break;
				case '6':
					$('#cb7').removeAttr('disabled');$('#cb8').removeAttr('disabled');
					break;
				case '7':
					$('#cb8').removeAttr('disabled');$('#cb12').removeAttr('disabled');
					break;
				case '8':
					$('#cb9').removeAttr('disabled');
					break;
				case '9':
					$('#cb10').removeAttr('disabled');
					break;
				case '10':
					break;
				case '12':
					break;
			}
			break;
		case '2':
			switch(status)
			{
				case '0':
					$('#cb1').removeAttr('disabled');$('#cb2').removeAttr('disabled');
					break;
				case '1':
					$('#cb2').removeAttr('disabled');
					break;
				case '2':
					$('#cb3').removeAttr('disabled');
					break;
				case '3':
					$('#cb4').removeAttr('disabled');
					break;
				case '4':
					$('#cb5').removeAttr('disabled');$('#cb6').removeAttr('disabled');
					break;
				case '5':
					$('#cb7').removeAttr('disabled');$('#cb8').removeAttr('disabled');
					break;
				case '6':
					$('#cb7').removeAttr('disabled');$('#cb8').removeAttr('disabled');
					break;
				case '7':
					$('#cb8').removeAttr('disabled');$('#cb12').removeAttr('disabled');
					break;
				case '8':
					$('#cb9').removeAttr('disabled');
					break;
				case '9':
					$('#cb10').removeAttr('disabled');
					break;
				case '10':
					break;
				case '12':
					break;
			}
			break;
		case '3':
			switch(status)
			{
				case '0':
					$('#cb1').removeAttr('disabled');$('#cb2').removeAttr('disabled');
					break;
				case '1':
					$('#cb2').removeAttr('disabled');
					break;
				case '2':
					$('#cb3').removeAttr('disabled');
					break;
				case '3':
					$('#cb4').removeAttr('disabled');
					break;
				case '4':
					$('#cb5').removeAttr('disabled');$('#cb6').removeAttr('disabled');
					break;
				case '5':
					$('#cb7').removeAttr('disabled');$('#cb8').removeAttr('disabled');
					break;
				case '6':
					$('#cb7').removeAttr('disabled');$('#cb8').removeAttr('disabled');
					break;
				case '7':
					$('#cb8').removeAttr('disabled');$('#cb12').removeAttr('disabled');
					break;
				case '8':
					$('#cb9').removeAttr('disabled');
					break;
				case '9':
					$('#cb10').removeAttr('disabled');
					break;
				case '10':
					break;
				case '12':
					break;
			}
			break;
		case '4':
			switch(status)
			{
				case '0':
					$('#cb1').removeAttr('disabled');$('#cb2').removeAttr('disabled');
					break;
				case '1':
					$('#cb2').removeAttr('disabled');
					break;
				case '2':
					$('#cb3').removeAttr('disabled');
					break;
				case '3':
					$('#cb4').removeAttr('disabled');
					break;
				case '4':
					$('#cb5').removeAttr('disabled');$('#cb6').removeAttr('disabled');
					break;
				case '5':
					$('#cb7').removeAttr('disabled');$('#cb8').removeAttr('disabled');
					break;
				case '6':
					$('#cb7').removeAttr('disabled');$('#cb8').removeAttr('disabled');
					break;
				case '7':
					$('#cb8').removeAttr('disabled');$('#cb12').removeAttr('disabled');
					break;
				case '8':
					$('#cb9').removeAttr('disabled');
					break;
				case '9':
					$('#cb10').removeAttr('disabled');
					break;
				case '10':
					break;
				case '12':
					break;
			}
			break;
		case '5': //--货到付款
			switch(status)
			{
				case '1':
				    $('#cb3').removeAttr('disabled');$('label[@for=cb2]').text('已付款');
				    break;
				case '2':
					$('#cb3').removeAttr('disabled');$('label[@for=cb2]').text('已付款');
					break;
				case '3':
					$('#cb4').removeAttr('disabled');
					break;
				case '4':
					$('#cb5').removeAttr('disabled');$('#cb6').removeAttr('disabled');
					break;
				case '5':
					$('#cb7').removeAttr('disabled');$('#cb8').removeAttr('disabled');
					break;
				case '6':
					$('#cb7').removeAttr('disabled');$('#cb8').removeAttr('disabled');
					break;
				case '7':
					$('#cb8').removeAttr('disabled');$('#cb12').removeAttr('disabled');
					break;
				case '8':
					$('#cb10').removeAttr('disabled');
					break;
			}
			break;
		case '6': //--门店自提
			switch(status)
			{
				case '1':
				    $('#cb3').removeAttr('disabled');$('label[@for=cb2]').text('已付款');
				    break;
				case '2':
					$('#cb3').removeAttr('disabled');$('label[@for=cb2]').text('已付款');
					break;
				case '3':
					$('#cb4').removeAttr('disabled');
					break;
				case '4':
					$('#cb7').removeAttr('disabled');$('#cb8').removeAttr('disabled');
					break;
				case '7':
					$('#cb12').removeAttr('disabled');
					break;
				case '8':
					$('#cb10').removeAttr('disabled');
					break;
			}
			break;
		default: //--拍卖团购用的上
			switch(status)
			{
				case '0':
					$('#cb1').removeAttr('disabled');$('#cb2').removeAttr('disabled');
					break;
				case '1':
					$('#cb2').removeAttr('disabled');
					break;
				case '2':
					$('#cb3').removeAttr('disabled');
					break;
				case '3':
					$('#cb4').removeAttr('disabled');
					break;
				case '4':
					$('#cb5').removeAttr('disabled');$('#cb6').removeAttr('disabled');
					break;
				case '5':
					$('#cb7').removeAttr('disabled');$('#cb8').removeAttr('disabled');
					break;
				case '6':
					$('#cb7').removeAttr('disabled');$('#cb8').removeAttr('disabled');
					break;
				case '7':
					$('#cb8').removeAttr('disabled');$('#cb12').removeAttr('disabled');
					break;
				case '8':
					$('#cb9').removeAttr('disabled');
					break;
				case '9':
					$('#cb10').removeAttr('disabled');
					break;
				case '10':
					break;
				case '12':
					break;
			}
			break;
	}
};
function ChangePriceConfirm()
{
    var dprice=$("#dprice").val();
    var sprice=$("#sprice").val();
    var remark=$("#cpRemark").val();
    var postdata = 'NoCopyRight=1&type=ajax&Action=ChangeOrderPrice&oid='+orderID + '&dprice='+dprice+'&sprice='+sprice+'&remark='+remark;
    $.ajax({
        url:'OrderModify.aspx',
        type:'POST',
        data:postdata,
        success:function(data){
            if(data==='ok'){
                window.location.reload();
            }else{
                alert(data);
            }
        },
        error:function(XMLHttpRequest,textStatus){if(textStatus=='parsererror'){alert('身份已过期,请重新登陆!')}else{alert('error')};}
    });
}

function UpdateOrderRemark()
{
    var remark=$('#txtRemark').val();
    if(remark==''){
    alert('订单附言不能为空！');
    return;
    }
    var postdata = 'NoCopyRight=1&type=ajax&Action=UpdateOrderRemark&oid='+orderID+'&remark='+remark;
    $.ajax({
        url:'OrderModify.aspx',
        type:'POST',
        data:postdata,
        success:function(data){
            if(data==='ok'){
                window.location.reload();
            }else{
                alert(data);
            }
        },
        error:function(XMLHttpRequest,textStatus){if(textStatus=='parsererror'){alert('身份已过期,请重新登陆!')}else{alert('error')};}
    });
}