(function (document) {
    Joomla.submitbutton = function (pressbutton) {
        var form = document.adminForm;

        if (pressbutton === 'cancel') {
            Joomla.submitform(pressbutton, form);
        } else {
            //Validate the entered data before submitting
            if (jQuery('#jform_title').val() == '') 
			{
                alert(Joomla.JText._('EDOCMAN_ENTER_CATEGORY_TITLE'));
                jQuery('#jform_title').focus();
                return;
            }
			var accesspicker = jQuery("input[name='jform[accesspicker]']:checked").val();
			if(accesspicker == "2" && jQuery('#jformparent_id').val() == '0')
			{
				alert(Joomla.JText._('EDOCMAN_PLEASE_SELECT_PARENT_CATEGORY_TO_APPLY_ACCESS_PERMISSION'));
                jQuery('#jformparent_id').focus();
                return;
			}
            Joomla.submitform(pressbutton, form);
        }
    }
})(document);