function _object_to_array($object)
{
    if (is_array($object) or is_object($object)) {
        $result = array();
        foreach ((array) $object as $key => $value) {
            $result[$key] = _object_to_array($value);
        }
        return $result;
    }
    return $object;
}
function admin_styles_head($tab)
{
    $styles = get_option('SnazzyMapStyles', null);
    if ($styles == null) {
        $styles = array();
    }
    //When a new style is selected we have to go through some checks
    if (isset($_POST['new_style'])) {
        $json = new SnazzyMaps_Services_JSON();
        $newStyle = _object_to_array($json->decode(urldecode($_POST['new_style'])));
        if (!_getStyle($styles, $newStyle['id'])) {
            $styles[] = $newStyle;
            update_option('SnazzyMapStyles', $styles);
        }
    }
}