public static function optionsframework_media_uploader_function($id, $std, $mod)
    {
        global $smof_data;
        $uploader = '';
        $upload = "";
        if (isset($smof_data[$id])) {
            $upload = $smof_data[$id];
        }
        $hide = '';
        if ($mod == "min") {
            $hide = 'hide';
        }
        if ($upload != "") {
            $val = $upload;
        } else {
            $val = $std;
        }
        $uploader .= '<input class="' . $hide . ' upload of-input" name="' . $id . '" id="' . $id . '_upload" value="' . $val . '" />';
        //Upload controls DIV
        $uploader .= '<div class="upload_button_div">';
        //If the user has WP3.5+ show upload/remove button
        if (function_exists('wp_enqueue_media')) {
            $uploader .= '<span class="button media_upload_button" id="' . $id . '">Upload</span>';
            if (!empty($upload)) {
                $hide = '';
            } else {
                $hide = 'hide';
            }
            $uploader .= '<span class="button remove-image ' . $hide . '" id="reset_' . $id . '" title="' . $id . '">Remove</span>';
        } else {
            $output .= '<p class="upload-notice"><i>Upgrade your version of WordPress for full media support.</i></p>';
        }
        $uploader .= '</div>' . "\n";
        //Preview
        $uploader .= '<div class="screenshot">';
        if (!empty($upload)) {
            $uploader .= '<a class="of-uploaded-image" href="' . $upload . '">';
            $uploader .= '<img class="of-option-image" id="image_' . $id . '" src="' . $upload . '" alt="" />';
            $uploader .= '</a>';
        }
        $uploader .= '</div>';
        $uploader .= '<div class="clear"></div>' . "\n";
        return $uploader;
    }
    public static function Options_Machine_Marup_Generate($options)
    {
        global $smof_output, $smof_details, $smof_data;
        //$smof_data = of_get_options();
        $smof_data_current = of_get_options();
        if (count($smof_data) < count($smof_data_current)) {
            $smof_data = $smof_data_current;
        }
        $defaults = array();
        $counter = 0;
        $menu = '';
        $output = '';
        foreach ($options as $value) {
            $counter++;
            $val = '';
            //create array of defaults
            if ($value['type'] == 'multicheck') {
                if (is_array($value['std'])) {
                    foreach ($value['std'] as $i => $key) {
                        $defaults[$value['id']][$key] = true;
                    }
                } else {
                    $defaults[$value['id']][$value['std']] = true;
                }
            } else {
                if (isset($value['id'])) {
                    $defaults[$value['id']] = $value['std'];
                }
            }
            //echo "<pre";
            //print_r($defaults);
            //Start Heading
            if ($value['type'] != "heading") {
                $class = '';
                if (isset($value['class'])) {
                    $class = $value['class'];
                }
                //hide items in checkbox group
                $fold = '';
                if (array_key_exists("fold", $value)) {
                    if (isset($smof_data[$value['fold']]) && $smof_data[$value['fold']]) {
                        $fold = "f_" . $value['fold'] . " ";
                    } else {
                        $fold = "f_" . $value['fold'] . " temphide ";
                    }
                }
                if (!isset($value['id'])) {
                    $value['id'] = rand(1, 100);
                }
                //var_dump($value);
                $output .= '<div id="section-' . $value['id'] . '" class="' . $fold . 'section section-' . $value['type'] . ' ' . $class . '">' . "\n";
                //only show header if 'name' value exists
                if ($value['name']) {
                    $output .= '<h3 class="heading">' . $value['name'] . '</h3>' . "\n";
                }
                $output .= '<div class="option">' . "\n" . '<div class="controls">' . "\n";
            }
            //switch statement to handle various options type
            switch ($value['type']) {
                //pattern tiles
                case 'pattern_tiles':
                    $output .= print_r($value['transparent_options'], true);
                    $output .= ' <div>Transparent patterns:</div><br />';
                    $output .= ' <div style="float:left;margin-bottom:20px" class="bg_transparent">';
                    $i = 0;
                    $checked = '';
                    $saved_std = isset($smof_data[$value['id']]) && !empty($smof_data[$value['id']]) ? $smof_data[$value['id']] : '';
                    $std = $value['std'];
                    foreach ($value['transparent_options'] as $key => $option) {
                        $i++;
                        //sellya_body_bg
                        //  print_r($option."<br/><br/>");
                        //die();
                        if (!empty($saved_std)) {
                            if ($saved_std == $option) {
                                $selected = 'of-radio-tile-selected';
                                $chk = 'checked';
                            } else {
                                $selected = '';
                                $chk = '';
                            }
                        } elseif ($std == $option) {
                            $selected = 'of-radio-tile-selected';
                            $chk = 'checked';
                        } else {
                            $selected = '';
                            $chk = '';
                        }
                        //$saved_std=$saved_std
                        $output .= '<span>';
                        $output .= '<input type="radio" id="of-radio-tile-' . $value['id'] . $i . '" class="checkbox of-radio-tile-radio" value="' . $option . '" name="' . $value['id'] . '"  ' . $chk . '  />';
                        $output .= '<div class="of-radio-tile-img ' . $selected . '" style="background: url(' . $option . ')" onClick="document.getElementById(\'of-radio-tile-' . $value['id'] . $i . '\').checked = true;"></div>';
                        $output .= '</span>';
                    }
                    $output .= '</div>';
                    $output .= ' <div style="float:left;margin-bottom:20px" class="bg_non_transparent">';
                    $checked = '';
                    $output .= '<div style="float:left;margin-bottom:20px">Non-transparent patterns</div>  ';
                    $output .= '<div style="float:left"> ';
                    foreach ($value['non_transparent_options'] as $key => $option) {
                        $i++;
                        //sellya_body_bg
                        // print_r($key."<br/><br/>");
                        //die();
                        if (!empty($saved_std)) {
                            if ($saved_std == $option) {
                                $selected = 'of-radio-tile-selected';
                                $chk = 'checked';
                            } else {
                                $selected = '';
                                $chk = '';
                            }
                        } elseif ($std == $option) {
                            $selected = 'of-radio-tile-selected';
                            $chk = 'checked';
                        } else {
                            $selected = '';
                            $chk = '';
                        }
                        //$saved_std=$saved_std
                        $output .= '<span>';
                        $output .= '<input type="radio" id="of-radio-tile-' . $value['id'] . $i . '" class="checkbox of-radio-tile-radio" value="' . $option . '" name="' . $value['id'] . '"  ' . $chk . '  />';
                        $output .= '<div class="of-radio-tile-img ' . $selected . '" style="background: url(' . $option . ')" onClick="document.getElementById(\'of-radio-tile-' . $value['id'] . $i . '\').checked = true;"></div>';
                        $output .= '</span>';
                    }
                    $output .= '</div>';
                    $output .= '</div>';
                    break;
                    //text input
                //text input
                case 'text':
                    $t_value = '';
                    $t_value = stripslashes($smof_data[$value['id']]);
                    $mini = '';
                    if (!isset($value['mod'])) {
                        $value['mod'] = '';
                    }
                    if ($value['mod'] == 'mini') {
                        $mini = 'mini';
                    }
                    $output .= '<input class="of-input ' . $mini . '" name="' . $value['id'] . '" id="' . $value['id'] . '" type="' . $value['type'] . '" value="' . $t_value . '" />';
                    break;
                    //select option
                //select option
                case 'select':
                    $mini = '';
                    if (!isset($value['mod'])) {
                        $value['mod'] = '';
                    }
                    if ($value['mod'] == 'mini') {
                        $mini = 'mini';
                    }
                    $output .= '<div class="select_wrapper ' . $mini . '">';
                    $output .= '<select class="select of-input" name="' . $value['id'] . '" id="' . $value['id'] . '">';
                    foreach ($value['options'] as $select_ID => $option) {
                        $theValue = $option;
                        if (!is_numeric($select_ID)) {
                            $theValue = $select_ID;
                        }
                        $output .= '<option id="' . $select_ID . '" value="' . $select_ID . '" ' . selected($smof_data[$value['id']], $select_ID, false) . ' />' . $option . '</option>';
                    }
                    $output .= '</select></div>';
                    break;
                    //textarea option
                //textarea option
                case 'textarea':
                    $cols = '8';
                    $ta_value = '';
                    if (isset($value['options'])) {
                        $ta_options = $value['options'];
                        if (isset($ta_options['cols'])) {
                            $cols = $ta_options['cols'];
                        }
                    }
                    $ta_value = stripslashes($smof_data[$value['id']]);
                    $output .= '<textarea class="of-input" name="' . $value['id'] . '" id="' . $value['id'] . '" cols="' . $cols . '" rows="8">' . $ta_value . '</textarea>';
                    break;
                    //radiobox option
                //radiobox option
                case "radio":
                    $checked = isset($smof_data[$value['id']]) ? checked($smof_data[$value['id']], $option, false) : '';
                    foreach ($value['options'] as $option => $name) {
                        $output .= '<input class="of-input of-radio" name="' . $value['id'] . '" type="radio" value="' . $option . '" ' . checked($smof_data[$value['id']], $option, false) . ' /><label class="radio">' . $name . '</label><br/>';
                    }
                    break;
                    //checkbox option
                //checkbox option
                case 'checkbox':
                    if (!isset($smof_data[$value['id']])) {
                        $smof_data[$value['id']] = 0;
                    }
                    $fold = '';
                    if (array_key_exists("folds", $value)) {
                        $fold = "fld ";
                    }
                    $output .= '<input type="hidden" class="' . $fold . 'checkbox of-input" name="' . $value['id'] . '" id="' . $value['id'] . '" value="0"/>';
                    $output .= '<input type="checkbox" class="' . $fold . 'checkbox of-input" name="' . $value['id'] . '" id="' . $value['id'] . '" value="1" ' . checked($smof_data[$value['id']], 1, false) . ' />';
                    break;
                    //multiple checkbox option
                //multiple checkbox option
                case 'multicheck':
                    isset($smof_data[$value['id']]) ? $multi_stored = $smof_data[$value['id']] : ($multi_stored = "");
                    foreach ($value['options'] as $key => $option) {
                        if (!isset($multi_stored[$key])) {
                            $multi_stored[$key] = '';
                        }
                        $of_key_string = $value['id'] . '_' . $key;
                        $output .= '<input type="checkbox" class="checkbox of-input" name="' . $value['id'] . '[' . $key . ']' . '" id="' . $of_key_string . '" value="1" ' . checked($multi_stored[$key], 1, false) . ' /><label class="multicheck" for="' . $of_key_string . '">' . $option . '</label><br />';
                    }
                    break;
                    //select option
                    // Color picker
                //select option
                // Color picker
                case "color":
                    $default_color = '';
                    if (isset($value['std'])) {
                        $default_color = ' data-default-color="' . $value['std'] . '" ';
                    }
                    $output .= '<input name="' . $value['id'] . '" id="' . $value['id'] . '" class="of-color"  type="text" value="' . $smof_data[$value['id']] . '"' . $default_color . ' />';
                    break;
                    //typography option
                //typography option
                case 'typography':
                    $typography_stored = isset($smof_data[$value['id']]) ? $smof_data[$value['id']] : $value['std'];
                    /* Font Size */
                    if (isset($typography_stored['size'])) {
                        $output .= '<div class="select_wrapper typography-size" original-title="Font size">';
                        $output .= '<select class="of-typography of-typography-size select" name="' . $value['id'] . '[size]" id="' . $value['id'] . '_size">';
                        for ($i = 9; $i < 20; $i++) {
                            $test = $i . 'px';
                            $output .= '<option value="' . $i . 'px" ' . selected($typography_stored['size'], $test, false) . '>' . $i . 'px</option>';
                        }
                        $output .= '</select></div>';
                    }
                    /* Line Height */
                    if (isset($typography_stored['height'])) {
                        $output .= '<div class="select_wrapper typography-height" original-title="Line height">';
                        $output .= '<select class="of-typography of-typography-height select" name="' . $value['id'] . '[height]" id="' . $value['id'] . '_height">';
                        for ($i = 20; $i < 38; $i++) {
                            $test = $i . 'px';
                            $output .= '<option value="' . $i . 'px" ' . selected($typography_stored['height'], $test, false) . '>' . $i . 'px</option>';
                        }
                        $output .= '</select></div>';
                    }
                    /* Font Face */
                    if (isset($typography_stored['face'])) {
                        $output .= '<div class="select_wrapper typography-face" original-title="Font family">';
                        $output .= '<select class="of-typography of-typography-face select" name="' . $value['id'] . '[face]" id="' . $value['id'] . '_face">';
                        $faces = array('arial' => 'Arial', 'verdana' => 'Verdana, Geneva', 'trebuchet' => 'Trebuchet', 'georgia' => 'Georgia', 'times' => 'Times New Roman', 'tahoma' => 'Tahoma, Geneva', 'palatino' => 'Palatino', 'helvetica' => 'Helvetica');
                        foreach ($faces as $i => $face) {
                            $output .= '<option value="' . $i . '" ' . selected($typography_stored['face'], $i, false) . '>' . $face . '</option>';
                        }
                        $output .= '</select></div>';
                    }
                    /* Font Weight */
                    if (isset($typography_stored['style'])) {
                        $output .= '<div class="select_wrapper typography-style" original-title="Font style">';
                        $output .= '<select class="of-typography of-typography-style select" name="' . $value['id'] . '[style]" id="' . $value['id'] . '_style">';
                        $styles = array('normal' => 'Normal', 'italic' => 'Italic', 'bold' => 'Bold', 'bold italic' => 'Bold Italic');
                        foreach ($styles as $i => $style) {
                            $output .= '<option value="' . $i . '" ' . selected($typography_stored['style'], $i, false) . '>' . $style . '</option>';
                        }
                        $output .= '</select></div>';
                    }
                    /* Font Color */
                    if (isset($typography_stored['color'])) {
                        $output .= '<div id="' . $value['id'] . '_color_picker" class="colorSelector typography-color"><div style="background-color: ' . $typography_stored['color'] . '"></div></div>';
                        $output .= '<input class="of-color of-typography of-typography-color" original-title="Font color" name="' . $value['id'] . '[color]" id="' . $value['id'] . '_color" type="text" value="' . $typography_stored['color'] . '" />';
                    }
                    break;
                    //border option
                //border option
                case 'border':
                    /* Border Width */
                    $border_stored = $smof_data[$value['id']];
                    $output .= '<div class="select_wrapper border-width">';
                    $output .= '<select class="of-border of-border-width select" name="' . $value['id'] . '[width]" id="' . $value['id'] . '_width">';
                    for ($i = 0; $i < 21; $i++) {
                        $output .= '<option value="' . $i . '" ' . selected($border_stored['width'], $i, false) . '>' . $i . '</option>';
                    }
                    $output .= '</select></div>';
                    /* Border Style */
                    $output .= '<div class="select_wrapper border-style">';
                    $output .= '<select class="of-border of-border-style select" name="' . $value['id'] . '[style]" id="' . $value['id'] . '_style">';
                    $styles = array('none' => 'None', 'solid' => 'Solid', 'dashed' => 'Dashed', 'dotted' => 'Dotted');
                    foreach ($styles as $i => $style) {
                        $output .= '<option value="' . $i . '" ' . selected($border_stored['style'], $i, false) . '>' . $style . '</option>';
                    }
                    $output .= '</select></div>';
                    /* Border Color */
                    $output .= '<div id="' . $value['id'] . '_color_picker" class="colorSelector"><div style="background-color: ' . $border_stored['color'] . '"></div></div>';
                    $output .= '<input class="of-color of-border of-border-color" name="' . $value['id'] . '[color]" id="' . $value['id'] . '_color" type="text" value="' . $border_stored['color'] . '" />';
                    break;
                    //images checkbox - use image as checkboxes
                //images checkbox - use image as checkboxes
                case 'images':
                    $i = 0;
                    $select_value = isset($smof_data[$value['id']]) ? $smof_data[$value['id']] : '';
                    foreach ($value['options'] as $key => $option) {
                        $i++;
                        $checked = '';
                        $selected = '';
                        if (NULL != checked($select_value, $key, false)) {
                            $checked = checked($select_value, $key, false);
                            $selected = 'of-radio-img-selected';
                        }
                        $output .= '<span>';
                        $output .= '<input type="radio" id="of-radio-img-' . $value['id'] . $i . '" class="checkbox of-radio-img-radio" value="' . $key . '" name="' . $value['id'] . '" ' . $checked . ' />';
                        $output .= '<div class="of-radio-img-label">' . $key . '</div>';
                        $output .= '<img src="' . $option . '" alt="" class="of-radio-img-img ' . $selected . '" onClick="document.getElementById(\'of-radio-img-' . $value['id'] . $i . '\').checked = true;" />';
                        $output .= '</span>';
                    }
                    break;
                    //info (for small intro box etc)
                //info (for small intro box etc)
                case "info":
                    $info_text = $value['std'];
                    $output .= '<div class="of-info">' . $info_text . '</div>';
                    break;
                    //display a single image
                //display a single image
                case "image":
                    $src = $value['std'];
                    $output .= '<img src="' . $src . '">';
                    break;
                    //drag & drop slide manager
                //drag & drop slide manager
                case 'slider':
                    $output .= '<div class="slider"><ul id="' . $value['id'] . '">';
                    $slides = $smof_data[$value['id']];
                    $count = count($slides);
                    if ($count < 2) {
                        $oldorder = 1;
                        $order = 1;
                        $output .= Options_Machine::optionsframework_slider_function($value['id'], $value['std'], $oldorder, $order);
                    } else {
                        $i = 0;
                        foreach ($slides as $slide) {
                            $oldorder = $slide['order'];
                            $i++;
                            $order = $i;
                            $output .= Options_Machine::optionsframework_slider_function($value['id'], $value['std'], $oldorder, $order);
                        }
                    }
                    $output .= '</ul>';
                    $output .= '<a href="#" class="button slide_add_button">Add New Slide</a></div>';
                    break;
                    //drag & drop block manager
                //drag & drop block manager
                case 'sorter':
                    // Make sure to get list of all the default blocks first
                    $all_blocks = $value['std'];
                    $temp = array();
                    // holds default blocks
                    $temp2 = array();
                    // holds saved blocks
                    foreach ($all_blocks as $blocks) {
                        $temp = array_merge($temp, $blocks);
                    }
                    $sortlists = isset($smof_data[$value['id']]) && !empty($smof_data[$value['id']]) ? $smof_data[$value['id']] : $value['std'];
                    foreach ($sortlists as $sortlist) {
                        $temp2 = array_merge($temp2, $sortlist);
                    }
                    // now let's compare if we have anything missing
                    foreach ($temp as $k => $v) {
                        if (!array_key_exists($k, $temp2)) {
                            $sortlists['disabled'][$k] = $v;
                        }
                    }
                    // now check if saved blocks has blocks not registered under default blocks
                    foreach ($sortlists as $key => $sortlist) {
                        foreach ($sortlist as $k => $v) {
                            if (!array_key_exists($k, $temp)) {
                                unset($sortlist[$k]);
                            }
                        }
                        $sortlists[$key] = $sortlist;
                    }
                    // assuming all sync'ed, now get the correct naming for each block
                    foreach ($sortlists as $key => $sortlist) {
                        foreach ($sortlist as $k => $v) {
                            $sortlist[$k] = $temp[$k];
                        }
                        $sortlists[$key] = $sortlist;
                    }
                    $output .= '<div id="' . $value['id'] . '" class="sorter">';
                    if ($sortlists) {
                        foreach ($sortlists as $group => $sortlist) {
                            $output .= '<ul id="' . $value['id'] . '_' . $group . '" class="sortlist_' . $value['id'] . '">';
                            $output .= '<h3>' . $group . '</h3>';
                            foreach ($sortlist as $key => $list) {
                                $output .= '<input class="sorter-placebo" type="hidden" name="' . $value['id'] . '[' . $group . '][placebo]" value="placebo">';
                                if ($key != "placebo") {
                                    $output .= '<li id="' . $key . '" class="sortee">';
                                    $output .= '<input class="position" type="hidden" name="' . $value['id'] . '[' . $group . '][' . $key . ']" value="' . $list . '">';
                                    $output .= $list;
                                    $output .= '</li>';
                                }
                            }
                            $output .= '</ul>';
                        }
                    }
                    $output .= '</div>';
                    break;
                    //background images option
                //background images option
                case 'tiles':
                    $i = 0;
                    $select_value = isset($smof_data[$value['id']]) && !empty($smof_data[$value['id']]) ? $smof_data[$value['id']] : '';
                    if (is_array($value['options'])) {
                        foreach ($value['options'] as $key => $option) {
                            $i++;
                            $checked = '';
                            $selected = '';
                            if (NULL != checked($select_value, $option, false)) {
                                $checked = checked($select_value, $option, false);
                                $selected = 'of-radio-tile-selected';
                            }
                            $output .= '<span>';
                            $output .= '<input type="radio" id="of-radio-tile-' . $value['id'] . $i . '" class="checkbox of-radio-tile-radio" value="' . $option . '" name="' . $value['id'] . '" ' . $checked . ' />';
                            $output .= '<div class="of-radio-tile-img ' . $selected . '" style="background: url(' . $option . ')" onClick="document.getElementById(\'of-radio-tile-' . $value['id'] . $i . '\').checked = true;"></div>';
                            $output .= '</span>';
                        }
                    }
                    break;
                    //JQuery UI Slider
                //JQuery UI Slider
                case 'sliderui':
                    $s_val = $s_min = $s_max = $s_step = $s_edit = '';
                    //no errors, please
                    $s_val = stripslashes($smof_data[$value['id']]);
                    if (!isset($value['min'])) {
                        $s_min = '0';
                    } else {
                        $s_min = $value['min'];
                    }
                    if (!isset($value['max'])) {
                        $s_max = $s_min + 1;
                    } else {
                        $s_max = $value['max'];
                    }
                    if (!isset($value['step'])) {
                        $s_step = '1';
                    } else {
                        $s_step = $value['step'];
                    }
                    if (!isset($value['edit'])) {
                        $s_edit = ' readonly="readonly"';
                    } else {
                        $s_edit = '';
                    }
                    if ($s_val == '') {
                        $s_val = $s_min;
                    }
                    //values
                    $s_data = 'data-id="' . $value['id'] . '" data-val="' . $s_val . '" data-min="' . $s_min . '" data-max="' . $s_max . '" data-step="' . $s_step . '"';
                    //html output
                    $output .= '<input type="text" name="' . $value['id'] . '" id="' . $value['id'] . '" value="' . $s_val . '" class="mini" ' . $s_edit . ' />';
                    $output .= '<div id="' . $value['id'] . '-slider" class="smof_sliderui" style="margin-left: 7px;" ' . $s_data . '></div>';
                    break;
                    //Switch option
                //Switch option
                case 'switch':
                    if (!isset($smof_data[$value['id']])) {
                        $smof_data[$value['id']] = 0;
                    }
                    $fold = '';
                    if (array_key_exists("folds", $value)) {
                        $fold = "s_fld ";
                    }
                    $cb_enabled = $cb_disabled = '';
                    //no errors, please
                    //Get selected
                    if ($smof_data[$value['id']] == 1) {
                        $cb_enabled = ' selected';
                        $cb_disabled = '';
                    } else {
                        $cb_enabled = '';
                        $cb_disabled = ' selected';
                    }
                    //Label ON
                    if (!isset($value['on'])) {
                        $on = "On";
                    } else {
                        $on = $value['on'];
                    }
                    //Label OFF
                    if (!isset($value['off'])) {
                        $off = "Off";
                    } else {
                        $off = $value['off'];
                    }
                    $output .= '<p class="switch-options">';
                    $output .= '<label class="' . $fold . 'cb-enable' . $cb_enabled . '" data-id="' . $value['id'] . '"><span>' . $on . '</span></label>';
                    $output .= '<label class="' . $fold . 'cb-disable' . $cb_disabled . '" data-id="' . $value['id'] . '"><span>' . $off . '</span></label>';
                    $output .= '<input type="hidden" class="' . $fold . 'checkbox of-input" name="' . $value['id'] . '" id="' . $value['id'] . '" value="0"/>';
                    $output .= '<input type="checkbox" id="' . $value['id'] . '" class="' . $fold . 'checkbox of-input main_checkbox" name="' . $value['id'] . '"  value="1" ' . checked($smof_data[$value['id']], 1, false) . ' />';
                    $output .= '</p>';
                    break;
                    // Uploader 3.5
                // Uploader 3.5
                case "upload":
                case "media":
                    if (!isset($value['mod'])) {
                        $value['mod'] = '';
                    }
                    $u_val = '';
                    if ($smof_data[$value['id']]) {
                        $u_val = stripslashes($smof_data[$value['id']]);
                    }
                    $output .= Options_Machine::optionsframework_media_uploader_function($value['id'], $u_val, $value['mod']);
                    break;
                case "iphone_checkboxes":
                    if (!isset($smof_data[$value['id']])) {
                        $smof_data[$value['id']] = $value['std'];
                    }
                    $saved_std = $smof_data[$value['id']] == '' ? '' : $smof_data[$value['id']];
                    $std = $value['std'];
                    $checked = '';
                    if (isset($saved_std)) {
                        $saved_std = intval($saved_std);
                        if ($saved_std == 1) {
                            $checked = 'checked="checked"';
                        } else {
                            $checked = '';
                        }
                    } elseif ($std == 'true') {
                        $checked = 'checked="checked"';
                    } else {
                        $checked = '';
                    }
                    $fold = '';
                    if (array_key_exists("folds", $value)) {
                        $fold = "fld ";
                    }
                    $output .= '<input type="hidden" class="' . $fold . 'checkbox aq-input" name="' . $value['id'] . '" id="' . $value['id'] . '" value="0"/>';
                    $output .= '<input type="checkbox" class="iphone_checkboxes"   name="' . $value['id'] . '" id="' . $value['id'] . '" value="1" ' . $checked . ' />';
                    break;
                case 'jslider':
                    if (isset($smof_data[$value['id']])) {
                        $t_value = stripslashes($smof_data[$value['id']]);
                    } else {
                        $t_value = $value['std'];
                    }
                    $output .= '<div class="rm_input rm_text">';
                    $output .= '<div style="float:left;width:270px;padding-left:10px">';
                    $output .= '<input  class="jslider"  class="jslider" name="' . $value['id'] . '" id="' . $value['id'] . '" type="' . $value['type'] . '" value="' . $t_value . '" />';
                    $output .= '<script>jQuery(document).ready(function(){jQuery("#' . $value['id'] . '").slider({ from: ' . $value['from'] . ' , to: ' . $value['to'] . ', step: ' . $value['step'] . ' , smooth: true });  });</script>';
                    $output .= '</div></div>';
                    break;
                case 'category_color_title':
                    $output .= "";
                    $categories = get_categories();
                    foreach ($categories as $cat) {
                        $value = "";
                        if (isset($smof_data[$value['id'] . $cat->cat_ID])) {
                            $value = $smof_data[$value['id'] . $cat->cat_ID];
                        }
                        //$output .= $cat->name;
                        $output .= '<div class="category_color_element">';
                        $output .= '<div id="' . $value['id'] . $cat->id . '_picker" class="colorSelector">
				<span class="category_name">' . $cat->name . '</span>
				<div style="background-color: ' . $smof_data[$value['id'] . $cat->cat_ID] . '"></div></div>';
                        $output .= '<input class="of-color" name="cat_color_' . $cat->cat_ID . '" id="cat_color_' . $cat->cat_ID . '" type="text" value="' . $value . '" />';
                        $output .= '</div>';
                    }
                    break;
                    //select option
                //select option
                case 'google_webfonts':
                    $mini = '';
                    if (!isset($value['mod'])) {
                        $value['mod'] = '';
                    }
                    if ($value['mod'] == 'mini') {
                        $mini = 'mini';
                    }
                    $output .= '<div class="select_wrapper ' . $mini . '">';
                    $faces = Options_Machine::google_fonts();
                    $output .= '<select class="of-typography of-typography-face select" name="' . $value['id'] . '[face]" id="' . $value['id'] . '_face">';
                    //selected($smof_data[$value['id']], $option, false) .
                    foreach ($faces->items as $cut) {
                        foreach ($cut->variants as $variant) {
                            $output .= '<option value="' . $cut->family . ':' . $variant . '" ' . selected($value['id'], $cut->family . ':' . $variant, false) . '>' . $cut->family . ' - ' . $variant . '</option>';
                        }
                    }
                    $output .= '</select></div>';
                    break;
                    //color_schema
                //color_schema
                case 'color_schema':
                    $i = 0;
                    $output .= '<div id="div_' . $value['id'] . '" class="color_scheme">';
                    //		if(!isset($value['id'])) $value['mod'] = '';
                    if (isset($value['id'])) {
                        $select_value = $smof_data[$value['id']];
                    } else {
                        $select_value = isset($smof_data[$value['id']]) && !empty($smof_data[$value['id']]) ? $smof_data[$value['id']] : $value['std'];
                    }
                    foreach ($value['sbubtype'] as $key => $option) {
                        $i++;
                        $active = $style = $class = $data_attribute = "";
                        if (isset($option['style'])) {
                            $style = " style ='" . $option['style'] . "'";
                        }
                        if ($select_value == $option['color_scheme']) {
                            $active = " active_color_scheme";
                        }
                        #active
                        //color_scheme
                        foreach ($option as $datakey => $datavalue) {
                            $data_attribute .= "data-" . $datakey . "='" . $datavalue . "'";
                        }
                        $output .= "<a id='color_scheme_" . $i . "' href='#'" . $data_attribute . " " . $style . " class ='color_schema_link_list color_scheme_" . $i . $active . $class . "'>" . $key . "</a>";
                    }
                    $output .= '<input type="hidden" value="' . $select_value . '" id="' . $value['std'] . '" name ="' . $value['id'] . '"/>';
                    $output .= '</div>';
                    break;
                case 'jslider':
                    if (isset($smof_data[$value['id']])) {
                        $t_value = stripslashes($smof_data[$value['id']]);
                    } else {
                        $t_value = $value['std'];
                    }
                    $output .= '<div class="rm_input rm_text">';
                    $output .= '<div style="float:left;width:270px;padding-left:10px">';
                    $output .= '<input  class="jslider"  class="jslider" name="' . $value['id'] . '" id="' . $value['id'] . '" type="' . $value['type'] . '" value="' . $t_value . '" />';
                    $output .= '<script>$(document).ready(function(){$("#' . $value['id'] . '").slider({ from: ' . $value['from'] . ' , to: ' . $value['to'] . ', step: ' . $value['step'] . ' , smooth: true });  });</script>';
                    $output .= '</div></div>';
                    break;
                    //checkbox option
                //checkbox option
                case 'checkbox':
                    if (!isset($smof_data[$value['id']])) {
                        $smof_data[$value['id']] = 0;
                    }
                    $fold = '';
                    if (array_key_exists("folds", $value)) {
                        $fold = "fld ";
                    }
                    $output .= '<input type="hidden" class="' . $fold . 'checkbox of-input" name="' . $value['id'] . '" id="' . $value['id'] . '" value="0"/>';
                    $output .= '<input type="checkbox" class="' . $fold . 'checkbox of-input" name="' . $value['id'] . '" id="' . $value['id'] . '" value="1" ' . checked($smof_data[$value['id']], 1, false) . ' />';
                    break;
                    //multiple checkbox option
                //multiple checkbox option
                case 'multicheck':
                    isset($smof_data[$value['id']]) ? $multi_stored = $smof_data[$value['id']] : ($multi_stored = "");
                    foreach ($value['options'] as $key => $option) {
                        if (!isset($multi_stored[$key])) {
                            $multi_stored[$key] = '';
                        }
                        $of_key_string = $value['id'] . '_' . $key;
                        $output .= '<input type="checkbox" class="checkbox of-input" name="' . $value['id'] . '[' . $key . ']' . '" id="' . $of_key_string . '" value="1" ' . checked($multi_stored[$key], 1, false) . ' /><label class="multicheck" for="' . $of_key_string . '">' . $option . '</label><br />';
                    }
                    break;
                    // Uploader 3.5
                // Uploader 3.5
                case "upload":
                case "media":
                    if (!isset($value['mod'])) {
                        $value['mod'] = '';
                    }
                    $u_val = '';
                    if ($smof_data[$value['id']]) {
                        $u_val = stripslashes($smof_data[$value['id']]);
                    }
                    $output .= Options_Machine::optionsframework_media_uploader_function($value['id'], $u_val, $value['mod']);
                    break;
                    //colorpicker option
                //colorpicker option
                case 'color':
                    //$output .= !empty($smof_data[$value['id']])?$smof_data[$value['id']]:$value['std'];
                    $colorcode = !empty($smof_data[$value['id']]) ? $smof_data[$value['id']] : $value['std'];
                    $output .= '<div id="' . $value['id'] . '_picker" class="colorSelector"><div style="background-color: ' . $colorcode . '"></div></div>';
                    $output .= '<input class="of-color" name="' . $value['id'] . '" id="' . $value['id'] . '" type="text" value="' . $colorcode . '" />';
                    break;
                    //typography option
                //typography option
                case 'typography':
                    $typography_stored = isset($smof_data[$value['id']]) ? $smof_data[$value['id']] : $value['std'];
                    /* Font Size */
                    if (isset($typography_stored['size'])) {
                        $output .= '<div class="select_wrapper typography-size" original-title="Font size">';
                        $output .= '<select class="of-typography of-typography-size select" name="' . $value['id'] . '[size]" id="' . $value['id'] . '_size">';
                        for ($i = 9; $i < 20; $i++) {
                            $test = $i . 'px';
                            $output .= '<option value="' . $i . 'px" ' . selected($typography_stored['size'], $test, false) . '>' . $i . 'px</option>';
                        }
                        $output .= '</select></div>';
                    }
                    /* Line Height */
                    if (isset($typography_stored['height'])) {
                        $output .= '<div class="select_wrapper typography-height" original-title="Line height">';
                        $output .= '<select class="of-typography of-typography-height select" name="' . $value['id'] . '[height]" id="' . $value['id'] . '_height">';
                        for ($i = 20; $i < 38; $i++) {
                            $test = $i . 'px';
                            $output .= '<option value="' . $i . 'px" ' . selected($typography_stored['height'], $test, false) . '>' . $i . 'px</option>';
                        }
                        $output .= '</select></div>';
                    }
                    /* Font Face */
                    if (isset($typography_stored['face'])) {
                        $output .= '<div class="select_wrapper typography-face" original-title="Font family">';
                        $output .= '<select class="of-typography of-typography-face select" name="' . $value['id'] . '[face]" id="' . $value['id'] . '_face">';
                        $faces = array('arial' => 'Arial', 'verdana' => 'Verdana, Geneva', 'trebuchet' => 'Trebuchet', 'georgia' => 'Georgia', 'times' => 'Times New Roman', 'tahoma' => 'Tahoma, Geneva', 'palatino' => 'Palatino', 'helvetica' => 'Helvetica');
                        foreach ($faces as $i => $face) {
                            $output .= '<option value="' . $i . '" ' . selected($typography_stored['face'], $i, false) . '>' . $face . '</option>';
                        }
                        $output .= '</select></div>';
                    }
                    /* Font Weight */
                    if (isset($typography_stored['style'])) {
                        $output .= '<div class="select_wrapper typography-style" original-title="Font style">';
                        $output .= '<select class="of-typography of-typography-style select" name="' . $value['id'] . '[style]" id="' . $value['id'] . '_style">';
                        $styles = array('normal' => 'Normal', 'italic' => 'Italic', 'bold' => 'Bold', 'bold italic' => 'Bold Italic');
                        foreach ($styles as $i => $style) {
                            $output .= '<option value="' . $i . '" ' . selected($typography_stored['style'], $i, false) . '>' . $style . '</option>';
                        }
                        $output .= '</select></div>';
                    }
                    /* Font Color */
                    if (isset($typography_stored['color'])) {
                        $output .= '<div id="' . $value['id'] . '_color_picker" class="colorSelector typography-color"><div style="background-color: ' . $typography_stored['color'] . '"></div></div>';
                        $output .= '<input class="of-color of-typography of-typography-color" original-title="Font color" name="' . $value['id'] . '[color]" id="' . $value['id'] . '_color" type="text" value="' . $typography_stored['color'] . '" />';
                    }
                    break;
                    //border option
                //border option
                case 'border':
                    /* Border Width */
                    $border_stored = $smof_data[$value['id']];
                    $output .= '<div class="select_wrapper border-width">';
                    $output .= '<select class="of-border of-border-width select" name="' . $value['id'] . '[width]" id="' . $value['id'] . '_width">';
                    for ($i = 0; $i < 21; $i++) {
                        $output .= '<option value="' . $i . '" ' . selected($border_stored['width'], $i, false) . '>' . $i . '</option>';
                    }
                    $output .= '</select></div>';
                    /* Border Style */
                    $output .= '<div class="select_wrapper border-style">';
                    $output .= '<select class="of-border of-border-style select" name="' . $value['id'] . '[style]" id="' . $value['id'] . '_style">';
                    $styles = array('none' => 'None', 'solid' => 'Solid', 'dashed' => 'Dashed', 'dotted' => 'Dotted');
                    foreach ($styles as $i => $style) {
                        $output .= '<option value="' . $i . '" ' . selected($border_stored['style'], $i, false) . '>' . $style . '</option>';
                    }
                    $output .= '</select></div>';
                    /* Border Color */
                    $output .= '<div id="' . $value['id'] . '_color_picker" class="colorSelector"><div style="background-color: ' . $border_stored['color'] . '"></div></div>';
                    $output .= '<input class="of-color of-border of-border-color" name="' . $value['id'] . '[color]" id="' . $value['id'] . '_color" type="text" value="' . $border_stored['color'] . '" />';
                    break;
                    //images checkbox - use image as checkboxes
                //images checkbox - use image as checkboxes
                case 'images':
                    $i = 0;
                    $select_value = $smof_data[$value['id']] == '' ? $value['std'] : $smof_data[$value['id']];
                    foreach ($value['options'] as $key => $option) {
                        $i++;
                        $checked = '';
                        $selected = '';
                        if (NULL != checked($select_value, $key, false)) {
                            $checked = checked($select_value, $key, false);
                            $selected = 'of-radio-img-selected';
                        }
                        $output .= '<span>';
                        $output .= '<input type="radio" id="of-radio-img-' . $value['id'] . $i . '" class="checkbox of-radio-img-radio" value="' . $key . '" name="' . $value['id'] . '" ' . $checked . ' />';
                        $output .= '<div class="of-radio-img-label">' . $key . '</div>';
                        $output .= '<img src="' . $option . '" alt="" class="of-radio-img-img ' . $selected . '" onClick="document.getElementById(\'of-radio-img-' . $value['id'] . $i . '\').checked = true;" />';
                        $output .= '</span>';
                    }
                    break;
                    //info (for small intro box etc)
                //info (for small intro box etc)
                case "info":
                    $info_text = $value['std'];
                    $output .= '<div class="of-info">' . $info_text . '</div>';
                    break;
                    //display a single image
                //display a single image
                case "image":
                    $src = $value['std'];
                    $output .= '<img src="' . $src . '">';
                    break;
                    //tab heading
                //tab heading
                case 'heading':
                    if ($counter >= 2) {
                        $output .= '</div>' . "\n";
                    }
                    $header_class = str_replace(' ', '', strtolower($value['name']));
                    $jquery_click_hook = str_replace(' ', '', strtolower($value['name']));
                    $jquery_click_hook = "of-option-" . $jquery_click_hook;
                    $menu .= '<li class="' . $header_class . '"><a title="' . $value['name'] . '" href="#' . $jquery_click_hook . '">' . $value['name'] . '</a></li>';
                    $output .= '<div class="group" id="' . $jquery_click_hook . '"><h2>' . $value['name'] . '</h2>' . "\n";
                    break;
                    //drag & drop slide manager
                //drag & drop slide manager
                case 'slider':
                    $output .= '<div class="slider"><ul id="' . $value['id'] . '">';
                    $slides = $smof_data[$value['id']];
                    $count = count($slides);
                    if ($count < 2) {
                        $oldorder = 1;
                        $order = 1;
                        $output .= Options_Machine::optionsframework_slider_function($value['id'], $value['std'], $oldorder, $order);
                    } else {
                        $i = 0;
                        foreach ($slides as $slide) {
                            $oldorder = $slide['order'];
                            $i++;
                            $order = $i;
                            $output .= Options_Machine::optionsframework_slider_function($value['id'], $value['std'], $oldorder, $order);
                        }
                    }
                    $output .= '</ul>';
                    $output .= '<a href="#" class="button slide_add_button">Add New Slide</a></div>';
                    break;
                    //drag & drop block manager
                //drag & drop block manager
                case 'sorter':
                    $sortlists = isset($smof_data[$value['id']]) && !empty($smof_data[$value['id']]) ? $smof_data[$value['id']] : $value['std'];
                    $output .= '<div id="' . $value['id'] . '" class="sorter">';
                    if ($sortlists) {
                        foreach ($sortlists as $group => $sortlist) {
                            $output .= '<ul id="' . $value['id'] . '_' . $group . '" class="sortlist_' . $value['id'] . '">';
                            $output .= '<h3>' . $group . '</h3>';
                            foreach ($sortlist as $key => $list) {
                                $output .= '<input class="sorter-placebo" type="hidden" name="' . $value['id'] . '[' . $group . '][placebo]" value="placebo">';
                                if ($key != "placebo") {
                                    $output .= '<li id="' . $key . '" class="sortee">';
                                    $output .= '<input class="position" type="hidden" name="' . $value['id'] . '[' . $group . '][' . $key . ']" value="' . $list . '">';
                                    $output .= $list;
                                    $output .= '</li>';
                                }
                            }
                            $output .= '</ul>';
                        }
                    }
                    $output .= '</div>';
                    break;
                    //background images option
                //background images option
                case 'tiles':
                    $i = 0;
                    $select_value = $smof_data[$value['id']] != '' ? $smof_data[$value['id']] : $value['std'];
                    foreach ($value['options'] as $key => $option) {
                        $i++;
                        $checked = '';
                        $selected = '';
                        if (NULL != checked($select_value, $option, false)) {
                            $checked = checked($select_value, $option, false);
                            $selected = 'of-radio-tile-selected';
                        }
                        $output .= '<span>';
                        $output .= '<input type="radio" id="of-radio-tile-' . $value['id'] . $i . '" class="checkbox of-radio-tile-radio" value="' . $option . '" name="' . $value['id'] . '" ' . $checked . ' />';
                        $output .= '<div class="of-radio-tile-img ' . $selected . '" style="background: url(' . $option . ')" onClick="document.getElementById(\'of-radio-tile-' . $value['id'] . $i . '\').checked = true;"></div>';
                        $output .= '</span>';
                    }
                    break;
                    //backup and restore options data
                //backup and restore options data
                case 'backup':
                    $instructions = $value['desc'];