//选择全部
function checkAllCommond(ca) {
    $(".cb input[type=checkbox]").each(function () {
        var able = $(this).attr("disabled");
        if (able != 'disabled') {
            $(this).attr("checked", true);
        }
        

    });
}

//反选
function invertCheckCommond() {
    $(".cb input[type=checkbox]").each(function () {
        var able = $(this).attr("disabled");
        if (able != 'disabled') {
            $(this).attr("checked", !($(this).attr("checked")));
        }
    });
}

//取消选择
function removeCheckCommond() {
    $(".cb input[type=checkbox]").each(function () {
        $(this).attr("checked", false);
    });
}

//打开商品类别
function openGoodCargoCommond(id) {
    $("#hfGoodCargoTemp").val(id);
    $("#goodCargoIftame").attr("src", "GoodCargoIframe.aspx");
    $("#goodCargoPopu").dialog({
        resizable: false,
        modal: true,
        title: "设置商品类别",
        buttons: {
            "确认": function () {
                setCargoPopuCommond();
                $(this).dialog("close");
            },
            "取消": function () {
                $(this).dialog("close");
            }
        }
    });
}

//获取类别数据
function setCargoPopuCommond() {
    var ddlParent1sel = $("#goodCargoIftame").contents().find("#ddlParent1");
    var ddlParent2sel = $("#goodCargoIftame").contents().find("#ddlParent2");
    var ddlParent3sel = $("#goodCargoIftame").contents().find("#ddlParent3");
    var ddlParent4sel = $("#goodCargoIftame").contents().find("#ddlParent4");
    var idTemp = ($("#hfGoodCargoTemp").val()).split(',');
    var id = idTemp[0];
    var shopid = idTemp[1];
    var cargoId;
    if (ddlParent4sel.val() != "-1") {
        $(".hfGoodCargoId[itemid=" + id + "]").val(ddlParent4sel.val());
        $(".goodCargo[itemid=" + id + "]").val(ddlParent4sel.find("option:selected").text());
        cargoId = ddlParent4sel.val();
    }
    else if (ddlParent3sel.val() != "-1") {
        $(".hfGoodCargoId[itemid=" + id + "]").val(ddlParent3sel.val());
        $(".goodCargo[itemid=" + id + "]").val(ddlParent3sel.find("option:selected").text());
        cargoId = ddlParent3sel.val();
    }
    else if (ddlParent2sel.val() != "-1") {
        $(".hfGoodCargoId[itemid=" + id + "]").val(ddlParent2sel.val());
        $(".goodCargo[itemid=" + id + "]").val(ddlParent2sel.find("option:selected").text());
        cargoId = ddlParent2sel.val();
    }
    else if (ddlParent1sel.val() != "-1") {
        $(".hfGoodCargoId[itemid=" + id + "]").val(ddlParent1sel.val());
        $(".goodCargo[itemid=" + id + "]").val(ddlParent1sel.find("option:selected").text());
    }
}


//弹出会员详情
function memberContactsCommon(id) {
    //获取会员站点ID
    var url = $("#hfMemUrl").val();
    $("#memberContactsIframe").attr("src", url + "MemberContacts.aspx?id=" + id);
    $("#memberContactsPopu").dialog({
        resizable: false,
        width: 1280,
        modal: true,
        title: "会员详情",
        buttons: {
            "确认": function () {
                setAddress();
                $(this).dialog("close");
            },
            "取消": function () {
                $(this).dialog("close");
            }
        }
    });
    return false;
}

//填快递单按钮
function expressClick(id) {
    $("#hfSelectID").val(id);
    $("#expressPopu").dialog({
        resizable: false,
        modal: true,
        width: 300,
        buttons: {
            "确认": function () {
                $("#hfOp").val("AddExpress");
                $(this).hide();
                $("#form1").append($(this));
                $("#form1").submit();
                $(this).dialog("close");
            },
            "取消": function () {
                $(this).dialog("close");
            }
        }
    });
}

//检查快递数量是否大于商品数量
function expressNumChange() {

}

function signClick(id, qty) {
    $("#hfSelectID").val(id);
    $("#expressPopu").dialog({
        resizable: false,
        modal: true,
        width: 300,
        buttons: {
            "确认": function () {
                $("#hfOp").val("Sign");
                $(this).hide();
                $("#form1").append($(this));
                $("#form1").submit();
                $(this).dialog("close");
            },
            "取消": function () {
                $(this).dialog("close");
            }
        }
    });
}

//检查输入
function ValidationCommond() {
    var ruselt = true;
    $(".noNull").each(function () {
        $(this).css("background", "#fff");
        if ($.trim($(this).val()).length == 0 || $.trim($(this).val()) < 0) {
            $(this).css("background", "red");
            if (ruselt) {
                ruselt = false;
            }
        }
    });
    //    if (!ruselt) {
    //        alert("红色必填或者非法输入");
    //    }
    //    if (ruselt) {
    //        if (!confirm("确定保存吗?")) {
    //            ruselt = false;
    //        }
    //    }
    return ruselt;
}

//检查是否有选择
function HasCecked() {
    if ($(".cb input[type=checkbox]:checked").length == 0) {
        return false;
    }
    return true;
}

//是否相等
function IsEqualSource(sId, tId) { 
    
}

//保存快递包裹
function SaveOrderExpress() {
    if (!ValidationCommond()) {
        alert("红色必填或者非法输入");
        return false;
    }
    if (!HasCecked()) {
        alert("没有选择项");
        return false;
    }
    if (confirm("确定认领这些SKU么？？？")) {
        return true;
     }
    else {
        return false;
    }
    
}

function SaveValidationCommond() {
    if (!ValidationCommond()) {
        alert("红色必填或者非法输入");
        return false;
    }
    return true;
}

//通过某个条件屏蔽某个控件
function IsConditionEnableSomeOne(condition, domConditionId, domEnableId) {
    if ($(domConditionId).val() == condition) {
        $(domEnableId).attr("disabled", "disabled");
        $(domEnableId).val(0);
    } else {
        $(domEnableId).attr("disabled", false);
    }
}