function GetPlugs(ClassID) {
    $("#Plugs").html("");
    $("#Parameters").html("");
    var GroupID = $("#GroupID").attr('value');
    $.getJSON("/GetPlug.gdr?GroupID=" + GroupID + "&ClassID=" + ClassID + "&tmp=" + (new Date()).getTime(), { "resultType": "json" }, function(data, textStatus) {
        if (data.length > 0) {
            for (var i = 0; i < data.length; i++) {
                $('<li><input type="checkbox" value="' + data[i].ID + '" id="Plug' + data[i].ID + '" /><span id="liPlug' + data[i].ID + '">' + data[i].PlugName + '</span></li>').appendTo($("#Plugs"));
                $("#Plug" + data[i].ID).bind("click", function() { PlugClick(this); });
                $("#liPlug" + data[i].ID).bind("click", function() { ShowPlugParameters(this.id); });
                if (data[i].Checked) { $("#Plug" + data[i].ID).attr("checked", "checked") }
            }
        }
    });
}
function ShowPlugParameters(PlugID) {
    $("#Parameters").html("");
    var GroupID = $("#GroupID").attr('value');
    var mPlugID = PlugID.replace("liPlug", "");
    $.getJSON("/GetPar.gdr?GroupID=" + GroupID + "&PlugID=" + mPlugID + "&tmp=" + (new Date()).getTime(), { "resultType": "json" }, function(data, textStatus) {
        if (data.length > 0) {
            for (var i = 0; i < data.length; i++) {
                $('<input type="checkbox" value="' + data[i].ParID + '" id="Par' + data[i].ParID + '" /><span>' + data[i].ParNote + '</span>').appendTo($("#Parameters"));
                $("#Par" + data[i].ParID).bind("click", function() { ParameterClick(mPlugID, this); });
                if (data[i].Checked) { $("#Par" + data[i].ParID).attr("checked", "checked");}
            }
        }
    });
}
function PlugClick(objPlug) {
    var plugID = objPlug.id.replace("Plug", "");
    var GroupID = $("#GroupID").attr('value');
    $.get("/SavePlugSec.gdr?GroupID=" + GroupID + "&PlugID=" + plugID + "&Change=" + objPlug.checked + "&tmp=" + (new Date()).getTime(), { "resultType": "html" }, function(data, textStatus) {
        if (data == "0") {
            alert("操作失败！");
        } else {
            $("input", "#Parameters").each(function() {
                this.checked = objPlug.checked;
            });
            ShowPlugParameters(objPlug.id.replace("Plug", "liPlug"));
        }
    });
}

function GetParameter(PlugID, strReplace) {
    $("#Parameters").html("");
    var GroupID = $("#GroupID").attr('value');
    var mPlugID = PlugID.replace(strReplace, "");
    $.getJSON("/GetPar.gdr?GroupID=" + GroupID + "&PlugID=" + mPlugID + "&tmp=" + (new Date()).getTime(), { "resultType": "json" }, function(data, textStatus) {
        if ($("#Plug" + mPlugID).attr("checked") == 'checked') { ParameterClick(mPlugID, $("#Plug" + mPlugID)[0]);}
        if (data.length > 0) {
            for (var i = 0; i < data.length; i++) {
                $('<input type="checkbox" value="' + data[i].ParID + '" id="Par' + data[i].ParID + '" /><span>' + data[i].ParNote + '</span>').appendTo($("#Parameters"));
                $("#Par" + data[i].ParID).bind("click", function() { ParameterClick(mPlugID, this);});
                if (data[i].Checked) { $("#Par" + data[i].ParID).attr("checked", "checked"); }
            }
        }
    });
}
function ParameterClick(pID, objCheck) {
    var GroupID = $("#GroupID").attr('value');
    $.get("/SaveSec.gdr?GroupID=" + GroupID + "&PlugID=" + pID + "&ParID=" + objCheck.value + "&Change=" + objCheck.checked + "&tmp=" + (new Date()).getTime(), { "resultType": "html" }, function(data, textStatus) {
        if (data == "0") {
            alert("操作失败！");
        }
    });
}



