function scratch_column_class()
{
    global $blocks, $column_count, $columns, $flex, $offset;
    switch ($columns) {
        case 2:
            if ($offset === '1:2') {
                return two_columns_12($column_count);
            } elseif ($offset === '2:1') {
                return two_columns_21($column_count);
            } else {
                if ($flex === true) {
                    return two_columns_flex($blocks, $column_count);
                } else {
                    return two_columns($column_count);
                }
            }
            break;
        case 3:
            if ($offset === '1:1:2') {
                return three_columns_112($column_count);
            } elseif ($offset === '1:2:1') {
                return three_columns_121($column_count);
            } elseif ($offset === '2:1:1') {
                return three_columns_211($column_count);
            } else {
                if ($flex === true) {
                    return three_columns_flex($blocks, $column_count);
                } else {
                    return three_columns($column_count);
                }
            }
            break;
        case 4:
            if ($flex === true) {
                return four_columns_flex($blocks, $column_count);
            } else {
                return four_columns($column_count);
            }
            break;
        case 5:
            if ($flex === true) {
                return five_columns_flex($blocks, $column_count);
            } else {
                return five_columns($column_count);
            }
            break;
        case 6:
            if ($flex === true) {
                return six_columns_flex($blocks, $column_count);
            } else {
                return six_columns($column_count);
            }
            break;
        case 'custom':
            return custom_columns($column_count);
            break;
        default:
            return 'error';
            break;
    }
}
function five_columns_flex($blocks, $count)
{
    $block_count = count($blocks);
    if ($block_count % 5 == 0) {
        return five_columns($count);
    } elseif (($block_count + 1) % 5 == 0) {
        if ($count == $block_count || $count == $block_count - 1 || $count == $block_count - 2 || $count == $block_count - 3) {
            if (($count - 1) % 5 == 0) {
                return "threecol first";
            } elseif (($count - 2) % 5 == 0 || ($count - 3) % 5 == 0) {
                return "threecol";
            } else {
                return "threecol last";
            }
        } else {
            return five_columns($count);
        }
    } elseif (($block_count + 2) % 5 == 0) {
        if ($count == $block_count || $count == $block_count - 1 || $count == $block_count - 2) {
            if (($count - 1) % 4 == 0) {
                return "fourcol first";
            } elseif (($count - 2) % 4 == 0) {
                return "fourcol";
            } else {
                return "fourcol last";
            }
        } else {
            return five_columns($count);
        }
    } elseif (($block_count + 3) % 5 == 0) {
        if ($count == $block_count || $count == $block_count - 1) {
            if (($count - 1) % 5 == 0) {
                return "sixcol first";
            } else {
                return "sixcol last";
            }
        } else {
            return five_columns($count);
        }
    } elseif (($block_count - 1) % 5 == 0) {
        if ($count == $block_count) {
            return "twelvecol first";
        } else {
            return five_columns($count);
        }
    } else {
        return "error";
    }
}