function getModules() {
    result = null;
        $.ajax({
            type: "POST",
            url: '/module/_get_modules',
            async: false,
            dataType: 'json',
            success:
            function(data) {
                result = data;
            },
            error:
            function(jqXHR, textStatus, errorThrown) {
                result = false;
            }
        });
        return result;
}

function getModuleFunctions(moduleId) {
    result = null;
        $.ajax({
            type: "POST",
            url: '/module/_get_modulefunctions',
            data: {
                module_id : moduleId
            },
            async: false,
            dataType: 'json',
            success:
            function(data) {
                result = data;
            },
            error:
            function(jqXHR, textStatus, errorThrown) {
                result = false;
            }
        });
        return result;
}

function addModuleBlock(method,criteria,module_id,function_id,user_id,ip,description,message) {
    result = null;
        $.ajax({
            type: "POST",
            url: '/module/_add_moduleblock',
            data: {
                block_method : method,
                block_criteria : criteria,
                block_module_id : module_id,
                block_function_id : function_id,
                block_user_id : user_id,
                block_ip : ip,
                block_description : description,
                block_message : message
            },
            async: false,
            dataType: 'json',
            success:
            function(data) {
                result = data;
            },
            error:
            function(jqXHR, textStatus, errorThrown) {
                result = false;
            }
        });
        return result;
}

function addModuleBlockByForm(formName) {
    result = null;
    formData = $('form[name='+formName+']').serialize();
        $.ajax({
            type: "POST",
            url: '/module/_add_moduleblock',
            data: formData,
            async: false,
            dataType: 'json',
            success:
            function(data) {
                result = data;
            },
            error:
            function(jqXHR, textStatus, errorThrown) {
                result = false;
            }
        });
        return result;
}

function showAddModuleBlock(placeholderId, eventHandler) {
    block_eventhandler = eventHandler;
    $('#'+placeholderId).load('/module/_show_add_moduleblock',{block_placeholderid: placeholderId});
    initDialog($('#'+placeholderId));
    showDialog($('#'+placeholderId));
}

function deleteModuleBlock(blockId) {
    result = null;
        $.ajax({
            type: "POST",
            url: '/module/_delete_moduleblock',
            data: {
                block_id : blockId
            },
            async: false,
            dataType: 'json',
            success:
            function(data) {
                result = data;
            },
            error:
            function(jqXHR, textStatus, errorThrown) {
                result = false;
            }
        });
        return result;
}
