function weaveriip_shortcoder_admin()
{
    if (!weaverii_pro_isset('wvpsc_num_opts')) {
        weaveriip_shortcoder_init();
    }
    $num_imgs = weaverii_pro_getopt('wvpsc_num_opts');
    if ($num_imgs < 1) {
        weaverii_pro_setopt('wvpsc_num_opts', 2);
        $num_imgs = 2;
    }
    ?>

	<div>
	<p class='wvr-option-section'>Weaver Shortcoder [weaver_sc] - <small>Define your own shortcodes.</small> <?php 
    weaveriip_help_link('pro-help.html#shortcoder', 'Shortcoder help');
    ?>
</p>
<p><code>[weaver_sc id="myname" v1="optional-replacement" ... v9="replacement"]</code></p>


	<p>This [weaver_sc] shortcode allows you to define your own named shortcodes. These really serve as "macros" - an easy way
	to define constant text or other fixed content you would like to add to your pages, posts, or widget areas.
	The content you define can include other <em>shortcodes</em> and <em>basic HTML</em>, as well as <em>Raw HTML</em>
	or <em>Scripts</em> if you have the role permissions to do that.</p>

	<p>[weaver_sc] supports nine (9) optional parameters, v1 to v9, that allow you to pass values to your shortcode
	definition text. The value of any parameter will replace the equivalent parameter specified as %v1% in your text.
	For example, if you had a shorcode "name" and definition text contained "My name is %v1%.", and you use the shortcode
	[weaver_sc id="name" v1="Bruce"], the output included in your content would be "My name is Bruce." This allows
	you to use the same short code in different pages or posts and supply variable content.</p>

	<form name="weaveriip_options_form" method="post">
	<input class="button-primary" type="submit" name="weaverii_pro_save_pro" value="Save Plus Shortcoder Options"/>
	<br />
		<fieldset class="options">
		<br /><strong style="color:blue;">Define Custom Shortcodes</strong>
		<p>You can add an arbitrary number of your own [weaver_sc] definitions by id.</p>
		<?php 
    for ($i = 1; $i <= $num_imgs; ++$i) {
        weaveriip_sc_add($i);
    }
    ?>
	<br /><strong>Custom shortcodes definitions allowed:</strong><input name="wvpsc_num_opts" id="wvpsc_num_opts" type="text" style="width:40px;height:20px;" class="regular-text" value="<?php 
    weaverii_esc_textarea(weaverii_pro_getopt('wvpsc_num_opts'));
    ?>
" />
	&nbsp;<small>Enter number of Weaver Shortcoder definitions you need (25 max).</small>
	</fieldset>
	<br />
	<input class="button-primary" type="submit" name="weaverii_pro_save_pro" value="Save Plus Shortcoder Options"/>
	<input type="hidden" name="weaveriip_save_shortcoder" value="Weaver II Pro Shortcoder Options Saved" />
	<?php 
    weaverii_nonce_field('weaverii_pro_save_pro');
    ?>
	</form>
	<hr />
	</div>
<?php 
}
function weaveriip_save_shortcoder()
{
    /* Save options from plus header: wvrx_plus_save_header */
    if (!weaverii_pro_isset('wvpsc_num_opts')) {
        weaveriip_header_init();
    }
    if (isset($_POST['wvpsc_num_opts'])) {
        weaverii_pro_setopt('wvpsc_num_opts', weaveriip_default_int($_POST['wvpsc_num_opts'], 1, 25, 2));
    }
    for ($i = 1; $i <= weaverii_pro_getopt('wvpsc_num_opts'); $i++) {
        $base = 'wvpsc_' . $i . '_';
        if (isset($_POST[$base . 'id'])) {
            $val = filter_var(strtolower(trim(weaverii_filter_textarea($_POST[$base . 'id']))), FILTER_SANITIZE_EMAIL);
            // close enough
            weaverii_pro_setopt($base . 'id', $val);
        }
        if (isset($_POST[$base . 'text'])) {
            weaverii_pro_setopt($base . 'text', weaverii_filter_textarea($_POST[$base . 'text']));
        }
    }
    weaverii_pro_update_options('shortcoder');
    /* and let the user know something happened */
    echo '<div id="message" class="updated fade"><p><strong>Weaver II Pro Shortcoder Options Saved</strong></p></div>';
}
function weaveriip_buttons_show_list()
{
    global $weaveriip_buttons_services;
    if (!weaverii_pro_isset('buttons')) {
        weaveriip_init_buttons();
        // just in case!
    }
    $buttons = weaverii_pro_getopt('buttons');
    $baseurl = get_template_directory_uri();
    /* from codex example */
    ?>
	<div>
		<table class='even-odd'>
			<tr>
				<td style="font-weight:bold;padding:5px;"></td>
				<td style="font-weight:bold;padding:5px;"><small>Image</small></td>
				<td style="font-weight:bold;padding:5px;"><small>Button Image - Full URL <span style="font-weight:normal">(required)</span></small></td>
				<td style="font-weight:bold;padding:5px;"><small>Hover Text Description</small></td>
				<td style="font-weight:bold;padding:5px;"><small>Link - Full URL</</td>
				<td style="font-weight:bold;padding:5px;"><small>New<br />Page</small></td>
			</tr>
<?php 
    for ($i = 0; $i < $buttons['maxbuttons']; $i++) {
        if ($i & 1) {
            echo "<tr>\n";
        } else {
            echo "<tr style=\"background:#eee;\">\n";
        }
        $id = 'b' . $i;
        ?>
	<td>&nbsp;<?php 
        echo $i + 1;
        ?>
&nbsp;</td>
<?php 
        if ($buttons[$id . '_img_url'] == '') {
            // special case - no link
            echo '    <td style="padding:5px;"><img src="' . trailingslashit($baseurl) . 'includes/pro/images/default-button.png" alt="no link" /></td>' . "\n";
        } else {
            echo '    <td style="padding:5px;"><img src="' . $buttons[$id . '_img_url'] . '" alt="button" /></td>' . "\n";
        }
        ?>
	<td>
		<input type="text" name="<?php 
        echo $id;
        ?>
_img_url" id="<?php 
        echo $id;
        ?>
_img_url"  style="width:240px;height:20px;" class="regular-text" value="<?php 
        echo esc_textarea($buttons[$id . '_img_url']);
        ?>
" /><?php 
        weaverii_media_lib_button($id . '_img_url');
        ?>
	</td>
	<td style="width:200px;padding-left:10px; padding-right:10px;">
		<input type="text" name="<?php 
        echo $id;
        ?>
_hover" id="<?php 
        echo $id;
        ?>
_hover"  style="width:200px;height:20px;" class="regular-text" value="<?php 
        echo esc_textarea($buttons[$id . '_hover']);
        ?>
" />
	</td>

	<td style="padding:5px;">
		<input type="text" name="<?php 
        echo $id;
        ?>
_link_url" id="<?php 
        echo $id;
        ?>
_link_url"  style="width:240px;height:20px;" class="regular-text" value="<?php 
        echo esc_textarea($buttons[$id . '_link_url']);
        ?>
" />
	</td>
	<td style="padding:5px;">
		<input type="checkbox" name="<?php 
        echo $id;
        ?>
_blank" id="<?php 
        echo $id;
        ?>
_blank" <?php 
        echo $buttons[$id . '_blank'] ? "checked" : "";
        ?>
 />
	</td>
<?php 
    }
    // end for
    ?>
		</table>
	</div>

<?php 
}
function weaveriip_slider_shortcode($args = '')
{
    extract(shortcode_atts(array('id' => '1'), $args));
    if (!weaverii_pro_getopt('slider_enable')) {
        return "<strong>[weaver_slider] shortcode used, but option not enabled.</strong>";
    }
    $sname = 'slider' . $id;
    if (!weaverii_pro_isset($sname . '_menu')) {
        return "<strong>[weaver_slider id={$id}] shortcode used, but Slider {$id} not defined.</strong>";
    }
    //if (weaverii_use_mobile('any') && weaverii_pro_getopt($sname . '_hidemobile')) {
    //  return '';
    //}
    $out = "<!-- Weaver Slider Shortcode -->\n";
    $out .= '<div id="weaver-slider' . $id . "\" class=\"weaver-slider\">\n";
    if (weaverii_pro_getopt($sname . '_menu') != '') {
        $menu_items = wp_get_nav_menu_items(weaverii_pro_getopt($sname . '_menu'));
        $menu_list = '<ul id="menu-' . $sname . '">';
        $img_num = 1;
        foreach ((array) $menu_items as $key => $menu_item) {
            $title = $menu_item->title;
            $url = $menu_item->url;
            $target = $menu_item->target;
            if ($target == '') {
                $target = '_self';
            }
            $img_url = weaverii_pro_getopt($sname . '_img' . $img_num);
            if ($img_url == '') {
                if (weaverii_pro_getopt($sname . '_vertical')) {
                    $img_url = weaverii_relative_url('includes/pro/images/' . $img_num . '-v.jpg');
                } else {
                    $img_url = weaverii_relative_url('includes/pro/images/' . $img_num . '.jpg');
                }
            }
            $menu_list .= '<li>';
            if (!weaverii_pro_getopt($sname . '_hidetext')) {
                $menu_text = '<span class="weaver-link-' . $sname . '">' . $title . '</span>';
            } else {
                $menu_text = '';
            }
            $menu_list .= '<a href="' . $url . '" title="' . $title . '" style="text-decoration:none;" target="' . $target . '">' . $menu_text . '<img src="' . $img_url . '" alt="' . $title . '" /></a></li>' . "\n";
            $img_num++;
            if ($img_num > weaverii_pro_getopt($sname . '_number_images')) {
                break;
            }
        }
        for (; $img_num <= weaverii_pro_getopt($sname . '_number_images'); $img_num++) {
            $img_url = weaverii_pro_getopt($sname . '_img' . $img_num);
            if ($img_url == '') {
                if (weaverii_pro_getopt($sname . '_vertical')) {
                    $img_url = weaverii_relative_url('includes/pro/images/' . $img_num . '-v.jpg');
                } else {
                    $img_url = weaverii_relative_url('includes/pro/images/' . $img_num . '.jpg');
                }
            }
            $menu_list .= '<li><img src="' . $img_url . '" alt="slider image" /></li>' . "\n";
        }
        $menu_list .= '</ul>';
    } else {
        $menu_list = "<h3>[weaver_slider id={$id}]: Menu not yet selected or defined.</h3>\n";
    }
    // $menu_list now ready to output
    $out .= $menu_list;
    $out .= "\n" . '</div> <!-- #weaver-slider' . $id . " -->\n";
    //$out .= '<div style="clear:both;"></div>' . "\n";
    /* compressSize = (MenuWidth-ImageWidth) / (NumImages-1)  (just for horizontal - use 50 for vertical) */
    $compressSize = (weaverii_pro_getopt($sname . '_menu_width') - weaverii_pro_getopt($sname . '_img_width')) / (weaverii_pro_getopt($sname . '_number_images') - 1);
    $vertical = 'false';
    if (weaverii_pro_getopt($sname . '_vertical')) {
        $compressSize = weaverii_pro_getopt($sname . '_vert_compress');
        $vertical = 'true';
    }
    if (!weaverii_pro_getopt($sname . '_noeffects')) {
        // no js for this menu
        $out .= "<script type=\"text/javascript\">window.addEvent('load', function(){\nnew BySlideMenu({\n'container' : 'menu-{$sname}',\n'selector' : 'li',\n'compressSize' : {$compressSize},\n'vertical' : {$vertical}\n}); });</script>\n";
    }
    return $out;
}
function weaveriip_header_gadget_code($which = 0)
{
    /* This is called from header.php, and will insert code into the #branding div of the header.
     */
    global $weaverii_cur_page_ID;
    if (!weaverii_pro_isset('hdr_num_opts')) {
        weaveriip_header_init();
    }
    // echo("<!-- Weaver II Pro Header Gadgets - Page ID: $weaverii_cur_page_ID; -->\n");
    $lim = weaverii_pro_getopt('hdr_num_opts');
    if ($which < 1) {
        // coming from header, not shortcode
        $max = weaverii_pro_getopt('hdr_use_for_header');
        if ($max != '' && $max < $lim) {
            $lim = $max;
        }
    }
    for ($i = 1; $i <= $lim; $i++) {
        if ($which > 0 && $which != $i) {
            continue;
        }
        $x = 0;
        $y = 0;
        $img = '';
        $imgalt = '';
        $text = '';
        $textstyle = '';
        $link = '';
        $linkalt = '';
        $base = 'hdr_' . $i . '_';
        if (weaverii_pro_getopt($base . 'hidemobile') && weaverii_use_mobile('mobile')) {
            continue;
        }
        if (weaverii_pro_getopt($base . 'hidetablet') && weaverii_use_mobile('tablet')) {
            continue;
        }
        if (weaverii_pro_isset($base . 'page')) {
            $page = weaverii_pro_getopt($base . 'page');
            if ($page != '' && $page != $weaverii_cur_page_ID) {
                continue;
            }
            // show only on one page, but not this one.
            if (weaverii_is_checked_page_opt('wvr_plus_hidecustomheader')) {
                // maybe skip
                if (!($page != '' && $page == $weaveriip_cur_page_ID)) {
                    continue;
                }
            }
        }
        if (weaverii_pro_isset($base . 'x')) {
            $x = weaverii_pro_getopt($base . 'x');
        }
        $xunits = weaverii_pro_isset($base . '_xunits') ? weaverii_pro_getopt($base . '_xunits') : 'px';
        if ($xunits == '') {
            $xunits = 'px';
        }
        if (weaverii_pro_isset($base . 'y')) {
            $y = weaverii_pro_getopt($base . 'y');
        }
        $yunits = weaverii_pro_isset($base . '_yunits') ? weaverii_pro_getopt($base . '_yunits') : 'px';
        if ($yunits == '') {
            $yunits = 'px';
        }
        if (weaverii_pro_isset($base . 'img')) {
            $img = weaverii_pro_getopt($base . 'img');
        }
        if (weaverii_pro_isset($base . 'imgalt')) {
            $imgalt = weaverii_pro_getopt($base . 'imgalt');
        }
        if (weaverii_pro_isset($base . 'text')) {
            $text = do_shortcode(weaverii_pro_getopt($base . 'text'));
        }
        if (weaverii_pro_isset($base . 'textstyle')) {
            $textstyle = weaverii_pro_getopt($base . 'textstyle');
        }
        if (weaverii_pro_isset($base . 'link')) {
            $link = weaverii_pro_getopt($base . 'link');
        }
        if (weaverii_pro_isset($base . 'linkalt')) {
            $linkalt = weaverii_pro_getopt($base . 'linkalt');
        }
        if (weaverii_pro_isset($base . 'newpage')) {
            $newpage = weaverii_pro_getopt($base . 'newpage');
        }
        if ($img == '' && $text == '' && $textstyle == '') {
            continue;
        }
        echo '<span id="wvr_gadget_' . $i . '" class="wvr_gadget" style="position:absolute;z-index:4;left:' . $x . $xunits . ';top:' . $y . $yunits . ';' . $textstyle . '">';
        if ($link != '') {
            $target = $newpage ? ' target="_blank"' : '';
            echo '<a href="' . $link . '" title="' . $linkalt . '"' . $target . ' style="color:inherit;">';
        }
        if ($img != '') {
            echo '<img class="wvr_gadget_img" src="' . $img . '" title="' . $imgalt . '" alt="' . $imgalt . '" />';
        }
        if ($text != '') {
            echo $text;
        }
        if ($link != '') {
            echo "</a>";
        }
        echo "</span>\n";
    }
    ?>

<?php 
}
function weaveriip_social_generate_code($height = 24, $number = 1000, $is_widget = true, $tag = 'span')
{
    global $weaveriip_social_services;
    if (!weaverii_pro_isset('social')) {
        weaveriip_init_social();
    }
    $soc = weaverii_pro_getopt('social');
    $out = '';
    // need to sort the buttons according to the order field. This code may not be the best way to do this,
    // but it was easier that figuring sorting the array of services.
    $sorted = array();
    $active_services = array();
    foreach ($weaveriip_social_services as $service) {
        // find all active buttons
        $id = $service['icon'];
        if (!isset($soc[$id . '_use']) || !$soc[$id . '_use']) {
            // not set to use
            continue;
        }
        $order = $soc[$id . '_order'];
        if ($order == '') {
            $order = 100000;
        }
        $sorted[$id] = $order;
        array_push($active_services, $service);
        // order doesn't matter here, so just push
    }
    asort($sorted);
    // sort the list of service names
    $sorted_ids = array_keys($sorted);
    // get the keys into an array - will be a sorted list of services
    $displayed = 0;
    $rm = $is_widget ? '6' : '0';
    $out .= '<' . $tag . ' class="weaver-social" >';
    foreach ($sorted_ids as $use_id) {
        foreach ($active_services as $service) {
            // find the active service that matches the next sorted id
            $id = $service['icon'];
            if ($id != $use_id) {
                continue;
            }
            $title = $soc[$id . '_hover'];
            // $service['blurb'];
            $url = $soc[$id . '_url'];
            $custom = isset($soc[$id . '_custom']) ? $soc[$id . '_custom'] : '';
            if ($custom != '') {
                $imgsrc = $custom;
            } else {
                $imgsrc = apply_filters('weaverii-social-dir', weaverii_relative_url('includes/pro/social/1/')) . $id . '.png';
            }
            $target = '_blank';
            if (isset($soc[$id . '_stay']) && $soc[$id . '_stay']) {
                $target = '_self';
            }
            $out .= '<a class="wvr-social-a" href="' . $url . '" target="' . $target . '" title="' . $title . '">' . '<img class="wvr-social-img" style="margin-right:' . $rm . 'px; width:' . $height . 'px !important;"  src="' . $imgsrc . '"  height="' . $height . '" width="' . $height . '" title="' . $title . '" alt="' . $title . '" /></a>' . "\n";
            if (++$displayed >= $number) {
                $out .= '</' . $tag . '>' . "\n";
                return $out;
                // bail when display number reached
            }
            break;
        }
    }
    // end foreach
    $out .= '</' . $tag . '>' . "\n";
    if ($is_widget) {
        $out .= '<div style="clear:both;"></div>' . "\n";
    }
    return $out;
}
function weaveriip_social_show_list()
{
    global $weaveriip_social_services;
    if (!weaverii_pro_isset('social')) {
        weaveriip_init_social();
        // make sane
    }
    $soc = weaverii_pro_getopt('social');
    // fetch the sub list
    $baseurl = trailingslashit(get_template_directory_uri());
    /* from codex example */
    ?>
	<div>
		<table class='even-odd'>
			<tr>
				<td><strong><small>Use</small></strong></td>
				<td style="text-align:center;font-weight:bold;"><small>Display<br />Order</small></td>
				<td></td>
				<td style="font-weight:bold;"><small>Social Site Description</small></td>
				<td style="font-weight:bold;"><small>Full URL link to your account</</td>
				<td style="font-weight:bold;"><small>Stay<br />on page</</td>
			</tr>
<?php 
    $i = 1;
    foreach ($weaveriip_social_services as $service) {
        if ($i++ & 1) {
            $rowbg = '#eee';
        } else {
            $rowbg = 'transparent';
        }
        echo "<tr style=\"background:{$rowbg};\">\n";
        $id = $service['icon'];
        if (!isset($soc[$id . '_use'])) {
            $soc[$id . '_use'] = '';
        }
        if (!isset($soc[$id . '_url'])) {
            $soc[$id . '_url'] = '';
        }
        if (!isset($soc[$id . '_order'])) {
            $soc[$id . '_order'] = '';
        }
        if (!isset($soc[$id . '_hover'])) {
            $soc[$id . '_hover'] = '';
        }
        if (!isset($soc[$id . '_stay'])) {
            $soc[$id . '_stay'] = '';
        }
        if (!isset($soc[$id . '_custom'])) {
            $soc[$id . '_custom'] = '';
        }
        ?>
	<td style="padding:5px;">
		<input type="checkbox" name="<?php 
        echo $id;
        ?>
_use" id="<?php 
        echo $id;
        ?>
_use" <?php 
        echo $soc[$id . '_use'] ? "checked" : "";
        ?>
 />
	</td>
	<td style="padding:5px;">
		<input type="text" name="<?php 
        echo $id;
        ?>
_order" id="<?php 
        echo $id;
        ?>
_order"  style="width:50px;height:20px;" class="regular-text" value="<?php 
        weaverii_esc_textarea($soc[$id . '_order']);
        ?>
" />
	</td>
<?php 
        if ($service['icon'][0] == '_') {
            if ($soc[$id . '_custom'] == '') {
                $img = '<img src="' . apply_filters('weaverii-social-dir', $baseurl . 'includes/pro/social/1/') . 'button-white.png" height="28" width="28" alt="white button" />';
            } else {
                $img = '<img src="' . $soc[$id . '_custom'] . '" height="28" width="28" alt="custom button" />';
            }
        } else {
            $img = '<img src="' . apply_filters('weaverii-social-dir', $baseurl . 'includes/pro/social/1/') . $service['icon'] . '.png" height="28" width="28" alt="social button" />';
        }
        if ($service['site'][0] == '#') {
            // special case - no link
            echo '<td style="padding:5px;">' . $img . '</td>' . "\n";
            echo '<td style="width:340px;padding-left:10px; padding-right:10px;">';
            ?>
<input type="text" name="<?php 
            echo $id;
            ?>
_hover" id="<?php 
            echo $id;
            ?>
_hover"  style="width:340px;height:20px;" class="regular-text" value="<?php 
            weaverii_esc_textarea($soc[$id . '_hover']);
            ?>
" /></td>
<?php 
        } else {
            echo '<td style="padding:5px;"><a href="http://' . $service['site'] . '" target="_blank">' . $img . '</td>' . "\n";
            ?>
			<td style="width:340px;padding-left:10px; padding-right:10px;"><input type="text" name="<?php 
            echo $id;
            ?>
_hover" id="<?php 
            echo $id;
            ?>
_hover"  style="width:340px;height:20px;" class="regular-text" value="<?php 
            weaverii_esc_textarea($soc[$id . '_hover']);
            ?>
" /></td>
<?php 
            // echo '<td style="width:340px;padding-left:10px; padding-right:10px;">' . $service['blurb'] . "</td>\n";
        }
        ?>
	<td style="padding:5px;">
<?php 
        if ($service['site'][0] == '#') {
            // special case - no link
            echo substr($service['site'], 1) . '<br />';
        }
        ?>
		<input type="text" name="<?php 
        echo $id;
        ?>
_url" id="<?php 
        echo $id;
        ?>
_url"  style="width:280px;height:20px;" class="regular-text" value="<?php 
        weaverii_esc_textarea($soc[$id . '_url']);
        ?>
" />
	</td>
	<td style="padding:5px;">
		<input type="checkbox" name="<?php 
        echo $id;
        ?>
_stay" id="<?php 
        echo $id;
        ?>
_stay" <?php 
        echo $soc[$id . '_stay'] ? "checked" : "";
        ?>
 />
	</td>

<?php 
        if ($service['icon'][0] == '_') {
            echo "<tr style=\"background:{$rowbg};\">\n";
            ?>
<td colspan>&nbsp;</td><td colspan="2"><small>Custom Icon URL:</td><td style="width:340px;padding-left:10px; padding-right:10px;">
<input type="text" name="<?php 
            echo $id;
            ?>
_custom" id="<?php 
            echo $id;
            ?>
_custom"  style="width:300px;" class="regular-text" value="<?php 
            weaverii_esc_textarea($soc[$id . '_custom']);
            ?>
" /><?php 
            weaverii_media_lib_button($id . '_custom');
            ?>
</td><td>&nbsp;&nbsp;<small>Suggested size: 32x32 px</td></tr>
<?php 
        }
        echo "</tr>\n";
    }
    // end foreach
    ?>
		</table>
	</div>

<?php 
}
function weaveriip_headergadget_admin()
{
    if (!weaverii_pro_isset('hdr_num_opts')) {
        weaveriip_header_init();
    }
    $num_imgs = weaverii_pro_getopt('hdr_num_opts');
    ?>

	<div>
	<p class='wvr-option-section'>Header Gadgets - <small>Links, Images & Text over the Header + [weaver_gadget] shortcode</small> <?php 
    weaveriip_help_link('pro-help.html#header_gadgets', 'Header Gadgets help');
    ?>
</p>


	<p>This tab allows you to add 'gadgets' (mini-widgets) anywhere over the site header. You can use images
	or text, and add links. You can place these anywhere over the header area of your site.</p>

	<h4>[weaver_gadget] shortcode</h4>
	<p>The gadgets defined here can also be used with a shortcode:
	<code>[weaver_gadget gadget=4]</code>
	where the 'gadget' parameter specifies the id number of which gadget to use. The shortcode version allows
	arbitrary placement of gadgets on the content area. You can split the usage of gadgets (some for the header,
	some for the shortcode) by specifying the "Max items" option at the bottom.
	</p>

	<form name="weaveriip_options_form" method="post">
	<input class="button-primary" type="submit" name="weaverii_pro_save_pro" value="Save Plus Header Gadget Options"/>
	<br />
		<fieldset class="options">
		<br /><strong style="color:blue;">Add Gadgets (Images or Text) over Header Area</strong>
		<p>You can add an arbitrary number of gadgets (images or text strings) over your header. You can specify how far down
		from the top (y) and the left (x) each one is displayed, in px or % (negative and decimal values OK).
		Gadgets will be displayed <em>behind</em> menu bars. You can also add a link to the gadget. Images will work best
		if you use an image from your Media Library (click the little image button to open Media Library). </p>
		<p><em><strong>Please note!</strong> Gadgets can cause unexpected results with the mobile view.</em> Gadgets placed
		beyond 320px to the right will cause an incorrect view on Mobile devices. You can check where they display
		using the Mobile:Simulate Mobile. Use % for X and Y position to give better responsive layout for
		gadgets on mobile devices.
		Specify a CSS styling rule "max-width=10%" (or other appropriate %)
		to make gadget images responsive/flexible sized.
		You can also check the hide box for gadgets if they display outside the main 320px wide content.</p>
		<?php 
    for ($i = 1; $i <= $num_imgs; ++$i) {
        weaveriip_header_add($i);
    }
    ?>
	<br /><strong>Gadget items allowed:</strong><input name="hdr_num_opts" id="hdr_num_opts" type="text" style="width:40px;height:20px;" class="regular-text" value="<?php 
    echo esc_textarea(weaverii_pro_getopt('hdr_num_opts'));
    ?>
" />
	&nbsp;<small>Enter number of gadget items you need to define (32 Max).</small>

	<br /><strong>Max items displayed over Header:</strong><input name="hdr_use_for_header" id="hdr_use_for_header" type="text" style="width:40px;height:20px;" class="regular-text" value="<?php 
    echo esc_textarea(weaverii_pro_getopt('hdr_use_for_header'));
    ?>
" />
	&nbsp;<small>Only the first "n" gadgets will be displayed over the header. The rest can be uses with the [weaver_gadget] shortcode. (Default: use all defined. Use 0 to disable all over the header.)</small>
	</fieldset>
	<br />
	<input class="button-primary" type="submit" name="weaverii_pro_save_pro" value="Save Plus Header Gadget Options"/>
	<input type="hidden" name="weaveriip_save_header" value="Weaver Plus Header Options Saved" />
	<?php 
    weaverii_nonce_field('weaverii_pro_save_pro');
    ?>
	</form>
	<hr />
	</div>
<?php 
}
function weaveriip_slider_sform($i)
{
    global $weaveriip_slider_opts;
    $sname = 'slider' . $i;
    if ($i & 1) {
        echo "<div style=\"width:99%;background:#eee;padding:4px;border-right:2px solid #eee;\">\n";
    } else {
        echo "<div style=\"width:99%;padding:4px;border:1px solid #ddd;\">\n";
    }
    $menus = get_terms('nav_menu', array('hide_empty' => false));
    // get defined custom menus
    $menu_selected = weaverii_pro_isset($sname . '_menu') ? weaverii_pro_getopt($sname . '_menu') : '';
    ?>
	<div><span style="color:blue;font-weight:bold;font-size:120%;">Slider <?php 
    echo $i;
    ?>
</span>
		&nbsp;&nbsp;<em>Shortcode:</em> <strong><code>[weaver_slider id=<?php 
    echo $i;
    ?>
]</code></strong>
		| <em>Note (where used, for example):</em>
		<input name="<?php 
    echo $sname;
    ?>
_note" id="<?php 
    echo $sname;
    ?>
_note" type="text" style="width:250px;height:22px;" class="regular-text" value="<?php 
    weaverii_esc_textarea(weaverii_pro_getopt($sname . '_note'));
    ?>
" />
	</div>
	<br />
	<table class="optiontable">
		<tr>
			<th scope="row" align="right" style="width:20%;">Select Menu:&nbsp;</th>
			<td>
<?php 
    // If no irect the user to go and create some.
    if (!$menus) {
        echo sprintf('No menus have been created yet. Please use <a href="$s">Appearance&rarr;Menus</a> to create some.', admin_url('nav-menus.php'));
    } else {
        ?>
					<select id="<?php 
        echo $sname . '_menu';
        ?>
" name="<?php 
        echo $sname . '_menu';
        ?>
">
<?php 
        foreach ($menus as $menu) {
            $selected = $menu_selected == $menu->term_id ? ' selected="selected"' : '';
            echo '<option' . $selected . ' value="' . $menu->term_id . '">' . $menu->name . '</option>' . "\n";
        }
    }
    ?>
					</select>
			</td>
			<td style="padding-left: 10px"><small>Select a custom menu to use for this slider. Sub-menus are not supported!.</small></td>

		</tr>
		<tr>
			<th scope="row" align="right" style="width:20%;">Hide Menu Text:&nbsp;</th>
			<td>
			<input type="checkbox" name="<?php 
    echo $sname;
    ?>
_hidetext" id="<?php 
    echo $sname;
    ?>
_hidetext" <?php 
    echo weaverii_pro_getopt($sname . '_hidetext') ? "checked" : "";
    ?>
 />
			</td>
			<td style="padding-left: 10px"><small>Hide standard Menu names over each image. Useful if your image
			contains the Menu name.</small></td>
		</tr>
		<tr>
			<th scope="row" align="right" style="width:20%;">Hide on Mobile View:&nbsp;</th>
			<td>
			<input type="checkbox" name="<?php 
    echo $sname;
    ?>
_hidemobile" id="<?php 
    echo $sname;
    ?>
_hidemobile" <?php 
    echo weaverii_pro_getopt($sname . '_hidemobile') ? "checked" : "";
    ?>
 />
			</td>
			<td style="padding-left: 10px"><small>Hide this slider on all mobile devices. Useful in combination with Main Options:
			Header: Hide Header Image on Normal View to show alternate header on mobile devices.</small></td>
		</tr>

		<tr>
			<th scope="row" align="right" style="width:20%;">Auto-Hide Primary Menu:&nbsp;</th>
			<td>
			<input type="checkbox" name="<?php 
    echo $sname;
    ?>
_hidemenu" id="<?php 
    echo $sname;
    ?>
_hidemenu" <?php 
    echo weaverii_pro_getopt($sname . '_hidemenu') ? "checked" : "";
    ?>
 />
			</td>
			<td style="padding-left: 10px"><small>Automatically hide Primary Menu on desktop or wide displays (slider on desktops,
			regular menu on mobile).</small></td>
		</tr>

		<tr>
			<th scope="row" align="right">Number of Images in Menu:&nbsp;</th>
			<td>
				<input name="<?php 
    echo $sname;
    ?>
_number_images" id="<?php 
    echo $sname;
    ?>
_number_images" type="text" style="width:60px;height:22px;" class="regular-text" value="<?php 
    weaverii_esc_textarea(weaverii_pro_getopt($sname . '_number_images'));
    ?>
" />
			<td style="padding-left: 10px"><small>Number of Images in Menu (must be between 2 and 8). Default is 7.</small></td>
			</td>
		</tr>
		<tr>
		<th scope="row" align="right">Menu Width:&nbsp;</th>
			<td>
				<input name="<?php 
    echo $sname;
    ?>
_menu_width" id="<?php 
    echo $sname;
    ?>
_menu_width" type="text" style="width:60px;height:22px;" class="regular-text" value="<?php 
    weaverii_esc_textarea(weaverii_pro_getopt($sname . '_menu_width'));
    ?>
" />
			<td style="padding-left: 10px"><small>Overall width of Slider Menu (in px). <em>(Typically matches image width for vertical menus, theme width for horizontal menus.)</em></small></td>
			</td>
		</tr>
		<tr>
			<th scope="row" align="right">Width of each image:&nbsp;</th>
			<td>
				<input name="<?php 
    echo $sname;
    ?>
_img_width" id="<?php 
    echo $sname;
    ?>
_img_width" type="text" style="width:60px;height:22px;" class="regular-text" value="<?php 
    weaverii_esc_textarea(weaverii_pro_getopt($sname . '_img_width'));
    ?>
" />
			<td style="padding-left: 10px"><small>Enter the width of each image (in px). For horizontal sliders, this will affect the exact look of the slider effect.
			The default 320 works well with 7 horizontal images. For vertical sliders, this will be the width of the slider. <em>Use 210 width for
			slider in text widget with default sidebar. (130 is good matching height.)</em></small></td>
			</td>
		</tr>
		<tr>
			<th scope="row" align="right">Height of each image:&nbsp;</th>
			<td>
				<input name="<?php 
    echo $sname;
    ?>
_img_height" id="<?php 
    echo $sname;
    ?>
_img_height" type="text" style="width:60px;height:22px;" class="regular-text" value="<?php 
    weaverii_esc_textarea(weaverii_pro_getopt($sname . '_img_height'));
    ?>
" />
			<td style="padding-left: 10px"><small>Enter the height of each image (in px). This will determine the height of your slider menu. Default is 200. Limits are 25 and 1000.</small></td>
			</td>
		</tr>
		<tr>
			<th scope="row" align="right" style="width:20%;">Vertical Menu:&nbsp;</th>
			<td>
			<input type="checkbox" name="<?php 
    echo $sname;
    ?>
_vertical" id="<?php 
    echo $sname;
    ?>
_vertical" <?php 
    echo weaverii_pro_getopt($sname . '_vertical') ? "checked" : "";
    ?>
 />
			</td>
			<td style="padding-left: 10px"><small>Check for vertical menu.</small> <strong>|</strong> Compressed height for each image:&nbsp;
			<input name="<?php 
    echo $sname;
    ?>
_vert_compress" id="<?php 
    echo $sname;
    ?>
_vert_compress" type="text" style="width:40px;height:20px;" class="regular-text" value="<?php 
    weaverii_esc_textarea(weaverii_pro_getopt($sname . '_vert_compress'));
    ?>
" />
			&nbsp;<small>This value, image height, and number of images interact to determine total height of vertical menu. Not used for horizontal menus.</small>
			</td>
		</tr>
		<tr>
			<th scope="row" align="right" style="width:20%;">Images Only, No Sliding:&nbsp;</th>
			<td>
			<input type="checkbox" name="<?php 
    echo $sname;
    ?>
_noeffects" id="<?php 
    echo $sname;
    ?>
_noeffects" <?php 
    echo weaverii_pro_getopt($sname . '_noeffects') ? "checked" : "";
    ?>
 />
			</td>
			<td style="padding-left: 10px"><small>Disable sliding effects. You will get an image menu only. You will have to adjust image sizes to fit.</small>
			</td>
		</tr>
		<tr>
			<th scope="row" align="right">CSS for Menu Text:&nbsp;</th>
			<td>&nbsp;</td>
			<td>
				<span style="padding-left: 10px"><small>You can control the font characteristics of the Slider Menu Text
				by editing this CSS. (Clear to blank to restore defaults.)</small></span>
				<br />
				<textarea name="<?php 
    echo $sname;
    ?>
_text_font" rows=2 style="width: 95%"><?php 
    weaverii_esc_textarea(weaverii_pro_getopt($sname . '_text_font'));
    ?>
</textarea>
				</td>
			</td>
		</tr>
		<tr>
			<th scope="row" align="right">Slider Menu CSS:&nbsp;</th>
			<td>&nbsp;</td>
			<td>
				<span style="padding-left: 10px"><small>Edit this CSS to change menu margins, etc. Use <code>border:0;</code> for no borders. Clear to blank to restore default.</small></span>
				<br />
				<textarea name="<?php 
    echo $sname;
    ?>
_borders" rows=1 style="width: 95%"><?php 
    weaverii_esc_textarea(weaverii_pro_getopt($sname . '_borders'));
    ?>
</textarea>
				</td>
			</td>
		</tr>
		</table>
		<h3>Slider Image Locations</h3>
		<p>
		Specify URLs for images for the menu. Each image should be
		<?php 
    echo weaveriip_default_int(weaverii_pro_getopt($sname . '_img_height'), 25, 1024, 200);
    ?>
px high and
		<?php 
    echo weaveriip_default_int(weaverii_pro_getopt($sname . '_img_width'), 25, 1024, 320);
    ?>
px wide. The most reliable place to
		keep your Slider images is in your Media Library. Click the small image icon to open the Medial Library selection dialog. Click "Insert into Post" to add URL. You can also enter any URL directly into the URL box below. If you have < 8 images, just leave the excess image links blank.</p>

		<table class="optiontable" style="padding-left:3%; padding-right:3%;">
		<tr>
			<td>
				1. Enter URL: <input type="text" name="<?php 
    echo $sname;
    ?>
_img1" id="<?php 
    echo $sname;
    ?>
_img1" size="55" value="<?php 
    weaverii_esc_textarea(weaverii_pro_getopt($sname . '_img1'));
    ?>
" /><?php 
    weaverii_media_lib_button($sname . '_img1');
    ?>
&nbsp;
			</td>
			<td>
				2. Enter URL: <input type="text" name="<?php 
    echo $sname;
    ?>
_img2" id="<?php 
    echo $sname;
    ?>
_img2" size="55" value="<?php 
    weaverii_esc_textarea(weaverii_pro_getopt($sname . '_img2'));
    ?>
" /><?php 
    weaverii_media_lib_button($sname . '_img2');
    ?>
			</td>
		</tr>
		<tr>
			<td>
				3. Enter URL: <input type="text" name="<?php 
    echo $sname;
    ?>
_img3" id="<?php 
    echo $sname;
    ?>
_img3" size="55" value="<?php 
    weaverii_esc_textarea(weaverii_pro_getopt($sname . '_img3'));
    ?>
" /><?php 
    weaverii_media_lib_button($sname . '_img3');
    ?>
&nbsp;
			</td>
			<td>
				4. Enter URL: <input type="text" name="<?php 
    echo $sname;
    ?>
_img4" id="<?php 
    echo $sname;
    ?>
_img4" size="55" value="<?php 
    weaverii_esc_textarea(weaverii_pro_getopt($sname . '_img4'));
    ?>
" /><?php 
    weaverii_media_lib_button($sname . '_img4');
    ?>
			</td>
		</tr>
		<tr>
			<td>
				5. Enter URL: <input type="text" name="<?php 
    echo $sname;
    ?>
_img5" id="<?php 
    echo $sname;
    ?>
_img5" size="55" value="<?php 
    weaverii_esc_textarea(weaverii_pro_getopt($sname . '_img5'));
    ?>
" /><?php 
    weaverii_media_lib_button($sname . '_img5');
    ?>
&nbsp;
			</td>
			<td>
				6. Enter URL: <input type="text" name="<?php 
    echo $sname;
    ?>
_img6" id="<?php 
    echo $sname;
    ?>
_img6" size="55" value="<?php 
    weaverii_esc_textarea(weaverii_pro_getopt($sname . '_img6'));
    ?>
" /><?php 
    weaverii_media_lib_button($sname . '_img6');
    ?>
			</td>
		</tr>
		<tr>
			<td>
				7. Enter URL: <input type="text" name="<?php 
    echo $sname;
    ?>
_img7" id="<?php 
    echo $sname;
    ?>
_img7" size="55" value="<?php 
    weaverii_esc_textarea(weaverii_pro_getopt($sname . '_img7'));
    ?>
" /><?php 
    weaverii_media_lib_button($sname . '_img7');
    ?>
&nbsp;
			</td>
			<td>
				8. Enter URL: <input type="text" name="<?php 
    echo $sname;
    ?>
_img8" id="<?php 
    echo $sname;
    ?>
_img8" size="55" value="<?php 
    weaverii_esc_textarea(weaverii_pro_getopt($sname . '_img8'));
    ?>
" /><?php 
    weaverii_media_lib_button($sname . '_img8');
    ?>
			</td>
		</tr>

		</table>
		<input class="button-primary" type="submit" name="weaverii_pro_save_pro" value="Save Slider Options"/>
</div>
<?php 
}
function weaveriip_buttons_generate_code($start = 1, $end = 64, $list = '')
{
    if (!weaverii_pro_isset('buttons')) {
        return 'No buttons defined.';
    }
    $buttons = weaverii_pro_getopt('buttons');
    $maxbuttons = $buttons['maxbuttons'];
    $out = '';
    if ($start < 1) {
        $start = 1;
    }
    // stay sane
    if ($end > $maxbuttons) {
        $end = $maxbuttons;
    }
    $out .= '<div class="weaver-buttons">';
    if ($list != '') {
        // list specified - it has priority
        $list_vals = explode(',', trim($list));
        foreach ($list_vals as $item) {
            $out .= weaveriip_buttons_button($buttons, trim($item));
        }
    } else {
        // start:end
        for ($i = $start; $i <= $end; $i++) {
            $out .= weaveriip_buttons_button($buttons, $i);
        }
        // end for
    }
    $out .= '</div>' . "\n";
    return $out;
}
function weaveriip_totalcss_output_style($sout)
{
    if (!weaverii_pro_isset('wvp_css')) {
        weaveriip_totalcss_init();
    }
    weaverii_f_write($sout, "/* Weaver II Pro Total CSS */\n");
    global $weaveriip_css;
    foreach ($weaveriip_css as $option => $val) {
        $css = weaverii_pro_getopt($val['id']);
        if ($css) {
            weaverii_f_write($sout, $val['tag'] . $css . "\n");
        }
    }
}