
function deletePermissions()
{
    if (confirm(lang('By disabling this permission you will disable all permissions that depend on it. \n \n Are you sure you want to do this?'))) {
        return true;
    }
    return false;
}

function changeCheckBox(parent, checkBox, grandParent)
{
    var parentChecked   = document.getElementById(parent.id);
    var currentDiv = document.getElementById(checkBox);
    var siblingDivs = 0;
    var newArrayCollection;

    if(parentChecked.checked){
        while(currentDiv = currentDiv.nextSibling) {
            if(currentDiv.nodeName == "DIV"){
                newArrayCollection = currentDiv.getElementsByTagName("input");
                newArrayCollection[0].disabled = false;
            }
            siblingDivs++;
        }
    } else if( !parentChecked.checked ) {
        newElement = document.getElementById(grandParent);

        newArrayCollection = newElement.getElementsByTagName("input");
        if(newArrayCollection.length > 1){
            if(!deletePermissions()) {
                parentChecked.checked = true;
                return false;
            }
        }

        for(var i=1; i < newArrayCollection.length; i++) {
            newArrayCollection[i].disabled = true;
            newArrayCollection[i].checked  = false;
        }
    }
}
