// Delete all related comments
                $sql = "DELETE FROM " . ALBUM_COMMENT_TABLE . "\n\t\t\t\t\t\tWHERE comment_pic_id IN " . $pic_id_sql;
                $result = $db->sql_query($sql);
                // Delete pic entries in db
                $sql = "DELETE FROM " . ALBUM_TABLE . "\n\t\t\t\t\t\tWHERE pic_cat_id = '{$cat_id}'";
                $result = $db->sql_query($sql);
            }
            // This category is now emptied, we can remove it!
            $sql = "DELETE FROM " . ALBUM_CAT_TABLE . "\n\t\t\t\t\tWHERE cat_id = '{$cat_id}'";
            $result = $db->sql_query($sql);
            // Re-order the rest of categories
            album_reorder_cat();
            // Return a message...
            $message = "";
            if ($parent_cat_deleted == true) {
                $message = sprintf($lang['Child_Category_Moved'], $parent_cat_title) . "<br />";
            }
            showResultMessage($message . $lang['Category_deleted']);
        } else {
            $sql = "UPDATE " . ALBUM_TABLE . "\n\t\t\t\t\tSET pic_cat_id = '{$target}'\n\t\t\t\t\tWHERE pic_cat_id = '{$cat_id}'";
            $result = $db->sql_query($sql);
            // This category is now emptied, we can remove it!
            $sql = "DELETE FROM " . ALBUM_CAT_TABLE . "\n\t\t\t\t\tWHERE cat_id = '{$cat_id}'";
            $result = $db->sql_query($sql);
            // Re-order the rest of categories
            album_reorder_cat();
            // Return a message...
            showResultMessage($lang['Category_deleted']);
        }
    }
}
function reorder_cat($user_id = ALBUM_PUBLIC_GALLERY)
{
    album_reorder_cat($user_id);
}
                // Delete all related ratings
                $sql = "DELETE FROM " . ALBUM_RATE_TABLE . "\n\t\t\t\t\t\tWHERE rate_pic_id IN " . $pic_id_sql;
                $result = $db->sql_query($sql);
                // Delete all related comments
                $sql = "DELETE FROM " . ALBUM_COMMENT_TABLE . "\n\t\t\t\t\t\tWHERE comment_pic_id IN " . $pic_id_sql;
                $result = $db->sql_query($sql);
                // Delete pic entries in db
                $sql = "DELETE FROM " . ALBUM_TABLE . "\n\t\t\t\t\t\tWHERE pic_cat_id = '" . $source_cat_id . "'";
                $result = $db->sql_query($sql);
            }
            // This category is now emptied, we can remove it!
            $sql = "DELETE FROM " . ALBUM_CAT_TABLE . "\n\t\t\t\t\tWHERE cat_id = '" . $source_cat_id . "'";
            $result = $db->sql_query($sql);
            // Re-order the rest of categories
            album_reorder_cat($album_user_id);
            // Return a message...
            $message = $parent_cat_deleted == true ? sprintf($lang['Child_Category_Moved'], $parent_cat_title) . '<br />' : '';
            showResultMessage($message . $lang['Category_deleted']);
        } else {
            $sql = "UPDATE " . ALBUM_TABLE . "\n\t\t\t\t\tSET pic_cat_id = '" . $target_cat_id . "'\n\t\t\t\t\tWHERE pic_cat_id = '" . $source_cat_id . "'";
            $result = $db->sql_query($sql);
            // This category is now emptied, we can remove it!
            $sql = "DELETE FROM " . ALBUM_CAT_TABLE . "\n\t\t\t\t\tWHERE cat_id = '" . $source_cat_id . "'";
            $result = $db->sql_query($sql);
            // Re-order the rest of categories
            album_reorder_cat($album_user_id);
            // Return a message...
            showResultMessage($lang['Category_deleted']);
        }
    }
}