function GetPageCode(url, coding) {
    GetCommon();
    D.BLL.B_Collection_Common.GetPageCode(url, coding, RetPageCode);
}

function RetPageCode(res) {
    DianCMS_$("txtHtml").value = res.value;
}

function GetCommon() {
    DianCMS_$("txtHtml").value = "正在获取中，请稍后... ...";
}

function PageType() {
    var TypeCount = document.getElementsByName("RadioPageType");
    var p = 0;
    if (navigator.appName == "Microsoft Internet Explorer") {
        p = 1;
    }

    for (var i = p; i < TypeCount.length; i++) {
        if (TypeCount[i].checked) {
            switch (TypeCount[i].value) {
                case "0":
                    DianCMS_$("PageType2_1").style.display = "none";
                    DianCMS_$("PageType2_2").style.display = "none";
                    DianCMS_$("PageType2_3").style.display = "none";
                    DianCMS_$("PageType3_1").style.display = "none";
                    DianCMS_$("PageType3_2").style.display = "none";
                    DianCMS_$("PageType4_1").style.display = "none";
                    DianCMS_$("PageType5_1").style.display = "none";
                    DianCMS_$("PageType5_2").style.display = "none";
                    DianCMS_$("PageType5_3").style.display = "none";
                    DianCMS_$("PageType5_4").style.display = "none";
                    break;
                case "1":
                    DianCMS_$("PageType2_1").style.display = "";
                    DianCMS_$("PageType2_2").style.display = "";
                    DianCMS_$("PageType2_3").style.display = "";
                    DianCMS_$("PageType3_1").style.display = "none";
                    DianCMS_$("PageType3_2").style.display = "none";
                    DianCMS_$("PageType4_1").style.display = "none";
                    DianCMS_$("PageType5_1").style.display = "none";
                    DianCMS_$("PageType5_2").style.display = "none";
                    DianCMS_$("PageType5_3").style.display = "none";
                    DianCMS_$("PageType5_4").style.display = "none";
                    break;
                case "2":
                    DianCMS_$("PageType2_1").style.display = "none";
                    DianCMS_$("PageType2_2").style.display = "none";
                    DianCMS_$("PageType2_3").style.display = "none";
                    DianCMS_$("PageType3_1").style.display = "";
                    DianCMS_$("PageType3_2").style.display = "";
                    DianCMS_$("PageType4_1").style.display = "none";
                    DianCMS_$("PageType5_1").style.display = "none";
                    DianCMS_$("PageType5_2").style.display = "none";
                    DianCMS_$("PageType5_3").style.display = "none";
                    DianCMS_$("PageType5_4").style.display = "none";
                    break;
                case "3":
                    DianCMS_$("PageType2_1").style.display = "none";
                    DianCMS_$("PageType2_2").style.display = "none";
                    DianCMS_$("PageType2_3").style.display = "none";
                    DianCMS_$("PageType3_1").style.display = "none";
                    DianCMS_$("PageType3_2").style.display = "none";
                    DianCMS_$("PageType4_1").style.display = "";
                    DianCMS_$("PageType5_1").style.display = "none";
                    DianCMS_$("PageType5_2").style.display = "none";
                    DianCMS_$("PageType5_3").style.display = "none";
                    DianCMS_$("PageType5_4").style.display = "none";
                    break;
                case "4":
                    DianCMS_$("PageType2_1").style.display = "none";
                    DianCMS_$("PageType2_2").style.display = "none";
                    DianCMS_$("PageType2_3").style.display = "none";
                    DianCMS_$("PageType3_1").style.display = "none";
                    DianCMS_$("PageType3_2").style.display = "none";
                    DianCMS_$("PageType4_1").style.display = "none";
                    DianCMS_$("PageType5_1").style.display = "";
                    DianCMS_$("PageType5_2").style.display = "";
                    DianCMS_$("PageType5_3").style.display = "";
                    DianCMS_$("PageType5_4").style.display = "";
                    break;
            }
        }
    }
}


/**********************/
function SelectErLinkage(obj, name) {
    var id = obj.id;
    var value = obj.value;
    var _id = id.split("_")[0] + "_" + id.split("_")[1] + "_";

    ResDefault(_id + name);
    if (value != "0") {
        D.BLL.B_Linkage.GetChildColumnTable(value, _id + name, CallBack);
    }
}

function SelectErLinkageByDictionary(obj, name) {
    var id = obj.id;
    var value = obj.value;
    var _id = id.split("_")[0] + "_" + id.split("_")[1] + "_";

    ResDefault(_id + name);
    if (value != "0") {
        D.BLL.B_Linkage.GetChildDictionaryTable(value, _id + name, CallBackDictionary);
    }
}

function SelectSanLinkage(obj, ErName, SanName) {
    var id = obj.id;
    var value = obj.value;
    var _id = id.split("_")[0] + "_" + id.split("_")[1] + "_";

    ResDefault(_id + ErName);
    ResDefault(_id + SanName);
    if (value != "0") {
        D.BLL.B_Linkage.GetChildColumnTable(value, _id + ErName, CallBack);
    }
}

function SelectSanLinkageByDictionary(obj, ErName, SanName) {
    var id = obj.id;
    var value = obj.value;
    var _id = id.split("_")[0] + "_" + id.split("_")[1] + "_";

    ResDefault(_id + ErName);
    ResDefault(_id + SanName);
    if (value != "0") {
        D.BLL.B_Linkage.GetChildDictionaryTable(value, _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].value = "0";
}


function WinOpenCollectionTemplate(obj, folder, css, template) {
    WinOpenLhgDialog('选择模板', '../../' + folder + '/' + template + '/SelectTemplate.aspx?ControlId=' + obj.id + '', 650, 450, '' + css + '');
}

function WinOpenCollectionTable(obj, name, url, css) {
    WinOpenLhgDialog('' + name + '', '' + url + '' + obj.id + '', 700, 550, '' + css + '');
}

function RadSet(obj) {
    var TypeCount = document.getElementsByName(obj.id.split("_")[0] + "$" + obj.id.split("_")[1] + "$Type");
    var p = 0;
    if (navigator.appName == "Microsoft Internet Explorer") {
        p = 1;
    }
    for (var i = p; i < TypeCount.length; i++) {

        if (TypeCount[i].checked) {
            if (TypeCount[i].value == "RadSet") {
                DianCMS_$(obj.id.split("_")[0] + "_" + obj.id.split("_")[1] + "_ButSet").disabled = false;
            }
            else {
                if (DianCMS_$(obj.id.split("_")[0] + "_" + obj.id.split("_")[1] + "_ButSet") != null) {
                    DianCMS_$(obj.id.split("_")[0] + "_" + obj.id.split("_")[1] + "_ButSet").disabled = true;
                }
            }
        }
    }
}

function AbortThread() {
    D.BLL.B_Collection_Common.AbortThread();
}
function SuspendThread() {
    D.BLL.B_Collection_Common.SuspendThread();
}
function ResumeThread() {
    D.BLL.B_Collection_Common.ResumeThread();
}
/*列表数据采集*/
function AbortThreadToListData() {
    D.BLL.B_Collection_Common.AbortThreadToListData();
}
function SuspendThreadToListData() {
    D.BLL.B_Collection_Common.SuspendThreadToListData();
}
function ResumeThreadToListData() {
    D.BLL.B_Collection_Common.ResumeThreadToListData();
}