function SelectErLinkage(colid, name) {
    ResDefault(name);
    if (colid != "0") {
        D.BLL.B_Linkage.GetChildColumnTable(colid, name, CallBack);
    }
}

function SelectErLinkageByDictionary(id, name) {
    ResDefault(name);
    if (id != "0") {
        D.BLL.B_Linkage.GetChildDictionaryTable(id, name, CallBackDictionary);
    }
}

function SelectSanLinkage(colid, ErName,SanName) {
    ResDefault(ErName);
    ResDefault(SanName);
    if (colid != "0") {
        D.BLL.B_Linkage.GetChildColumnTable(colid, ErName, CallBack);
    }
}

function SelectSanLinkageByDictionary(id, ErName, SanName) {
    ResDefault(ErName);
    ResDefault(SanName);
    if (id != "0") {
        D.BLL.B_Linkage.GetChildDictionaryTable(id, ErName, CallBackDictionary);
    }
}

function CallBack(res) {
    if (res.value != null) {
        var DropName = res.value.Tables[1].Rows[0]["Name"];
        ResDefault(DropName);

        for (var i = 0, p = 1; i < res.value.Tables[0].Rows.length; i++, p++) {
            DianCMS_$(DropName).length++;
            DianCMS_$(DropName).options[p].text = res.value.Tables[0].Rows[i]["CnName"];
            DianCMS_$(DropName).options[p].value = res.value.Tables[0].Rows[i]["ColId"];
        }
    }
}

function CallBackDictionary(res) {
    if (res.value != null) {
        var DropName = res.value.Tables[1].Rows[0]["Name"];
        ResDefault(DropName);

        for (var i = 0, p = 1; i < res.value.Tables[0].Rows.length; i++, p++) {
            DianCMS_$(DropName).length++;
            DianCMS_$(DropName).options[p].text = res.value.Tables[0].Rows[i]["Text"];
            DianCMS_$(DropName).options[p].value = res.value.Tables[0].Rows[i]["Id"];
        }
    }
}

function ResDefault(DropName) {
    DianCMS_$(DropName).length = 1;
    DianCMS_$(DropName).options[0].text = DianCMS_$(DropName).options[0].text;
    DianCMS_$(DropName).options[0].value = DianCMS_$(DropName).options[0].value;
}

function GetJsRadom(id) {
    D.BLL.B_Linkage.GetRadom(id, RadomCallBack);
}

function RadomCallBack(res) {
    DianCMS_$(res.value.split(",")[0]).value=res.value.split(",")[1];
}