﻿function AttributeCheckBoxCheckedChanged(checkBox) {
    simpleNumericValueTextBoxId = checkBox.id.replace(/AttributeCheckBox/, "SimpleNumericValueTextBox");
    simpleTextValueTextBoxId = checkBox.id.replace(/AttributeCheckBox/, "SimpleTextValueTextBox");
    largeTextValueTextBoxId = checkBox.id.replace(/AttributeCheckBox/, "LargeTextValueTextBox");
    comboBoxValueDropDownListId = checkBox.id.replace(/AttributeCheckBox/, "ComboBoxValueDropDownList");
    radioButtonValueDropDownListId = checkBox.id.replace(/AttributeCheckBox/, "RadioButtonValueRadioButtonList");
    attributePanelMyId = $('#' + checkBox.id.replace(/AttributeCheckBox/, "AttributePanel")).attr("myId");
    attributePanelMyAg = $('#' + checkBox.id.replace(/AttributeCheckBox/, "AttributePanel")).attr("myAg");
    attributePanelMyIdTruncated = attributePanelMyId.replace(/\d*$/, '');

    if (checkBox.checked) {
        $('#' + simpleNumericValueTextBoxId).removeAttr('disabled');
        $('#' + simpleTextValueTextBoxId).removeAttr('disabled');
        $('#' + largeTextValueTextBoxId).removeAttr('disabled');
        $('#' + comboBoxValueDropDownListId).removeAttr('disabled');
        $("[ID^='" + radioButtonValueDropDownListId + "']").removeAttr('disabled').parent().removeAttr('disabled');
        $("[myId^='" + attributePanelMyId + "_']").show();
        if (attributePanelMyAg != "")
            $("[myId!='" + attributePanelMyId + "'][myId^='" + attributePanelMyIdTruncated + "'][myAg='" + attributePanelMyAg + "'] input:checkbox").attr('disabled', 'disabled');
    }
    else {
        $('#' + simpleNumericValueTextBoxId).attr('disabled', 'disabled');
        $('#' + simpleTextValueTextBoxId).attr('disabled', 'disabled');
        $('#' + largeTextValueTextBoxId).attr('disabled', 'disabled');
        $('#' + comboBoxValueDropDownListId).attr('disabled', 'disabled');
        $("[ID^='" + radioButtonValueDropDownListId + "']").attr('disabled', 'disabled');
        $("[myId^='" + attributePanelMyId + "_']").hide();
        if (attributePanelMyAg != "")
            $("[myId!='" + attributePanelMyId + "'][myId^='" + attributePanelMyIdTruncated + "'][myAg='" + attributePanelMyAg + "'] input:checkbox").removeAttr('disabled').parent().removeAttr('disabled'); ;
    }
}

function SetClassChoice(enableArray, disableArray) {
    if (enableArray != null) {
        $.each(enableArray, function(index, value) {
            $("[myId='" + value + "']").show();
        });
    }

    if (disableArray != null) {
        $.each(disableArray, function(index, value) {
            $("[myId='" + value + "']").hide();
            $("[myId='" + value + "'] > input:checked").removeAttr("checked");
            $("[myId='" + value.replace(/Class/, "AttributeGroup") + "']").hide();
        });
    }
}

function ShowHideAttributes(registrationId, classId) {
    $("[myId^='AttributeGroup_" + registrationId + "_']").hide();
    $("[myId='AttributeGroup_" + registrationId + "_" + classId + "']").show();
}
