function cw_error_check_state($state, $section, &$full)
{
    global $tables;
    $display_states = cw_query_first_cell("select display_states from {$tables['map_countries']} where code = '{$section['country']}'") == 'Y';
    if (!$display_states) {
        return false;
    }
    if (empty($state) || !cw_user_check_state($state, $section['country'])) {
        return true;
    }
    return false;
}
function cw_user_check_county($county_id, $state_code, $country_code)
{
    global $tables;
    if (is_numeric($county_id)) {
        if (cw_user_check_state($state_code, $country_code) && cw_query_first_cell("select count(*) from {$tables['map_counties']}, {$tables['map_states']} where {$tables['map_counties']}.state_id={$tables['map_states']}.state_id AND {$tables['map_counties']}.county_id='{$county_id}' AND {$tables['map_states']}.code='{$state_code}'")) {
            return (bool) cw_query_first_cell("select count(*) from {$tables['map_counties']}, {$tables['map_states']} where {$tables['map_counties']}.state_id={$tables['map_states']}.state_id AND {$tables['map_counties']}.county_id='{$county_id}' AND {$tables['map_states']}.code='{$state_code}' AND {$tables['map_states']}.country_code='{$country_code}'");
        }
    }
    return true;
}