$(document).ready(function()
{
    $.setAjaxForm('#editForm', function()
    {
        setTimeout(function(){
            /* After the form posted, refresh the treeMenuBox content. */
            source = createLink('tree', 'browse', 'type=' + v.type + '&startModule=0&root=' + v.root) + ' #treeMenuBox';

            $('#treeMenuBox').parent().load(source, function()
            {
                $('#treeMenuBox li:has(ul)').each(function()
                {
                    $(this).children('.deleter').remove();
                });

                $.setAjaxLoader('#treeMenuBox .ajax, .panel-actions .ajax', '#categoryBox');

                /* Rebuild the tree menu after treeMenuBox refreshed. */
                $(".tree").tree('expand');
            });

            $('#categoryBox').load($('#editForm').attr('action'), function()
            {
                $.zui.initPage($('#categoryBox'));
            });
        }, 1200);
    });

    $.setAjaxLoader('.btn-back.ajax', '#categoryBox');

    $('.group-item label.checkbox').css('float', 'left').css('margin-right', '10px').css('width', '100px');
});
