function ostk_sandbox_page()
{
    ob_start();
    if (isset($_POST['submit'])) {
        $shortcode = stripslashes($_POST['shortcode']);
    }
    ?>
	<div class="ostk-plugin-settings">
		<?php 
    echo ostk_get_header('sandbox');
    ?>
		<div class="ostk-page ostk-sandbox-page">
			<h1>Sandbox</h1>
			<p>Insert your shortcodes here to test what the affilate link will look like.</p>
			<div class="shortcode-input">
				<h2>INPUT</h2>
				<div class="inner">
					<form method="post" action="<?php 
    echo $_SERVER['PHP_SELF'];
    ?>
?page=ostk-sandbox">
			            <textarea cols="60" rows="5" placeholder="Shortcode sandbox..." id="shortcode" name="shortcode"><?php 
    echo $shortcode;
    ?>
</textarea>
			            <input type="submit" name="submit" class="btn" value="Try It!" id="submit"/>
			        </form>
				</div>
			</div><!--.input-->
			<div class="shortcode-output">
				<h2>OUTPUT</h2>
				<div class="inner">
					<?php 
    if (isset($shortcode)) {
        echo do_shortcode($shortcode);
    }
    ?>
				</div>
			</div><!--.output-->
			<div class="clearfix"></div>
		</div><!--.ostk-sandbox-page-->
	</div><!--.ostk-plugin-settings-->
	<?php 
    echo ob_get_clean();
}
function ostk_doc_page()
{
    global $patterns;
    ob_start();
    ?>
	<div class="ostk-plugin-settings">
		<?php 
    echo ostk_get_header('doc');
    ?>
		<div class="ostk-page ostk-doc-page">
			<h1>Documentation</h1>
			<?php 
    $pattern_counter = 1;
    foreach ($patterns as $pattern) {
        $current_pattern = false;
        $url = '?page=ostk-doc';
        if ($pattern['slug'] == $_GET['pattern']) {
            $current_pattern = true;
        } else {
            $url .= '&pattern=' . $pattern['slug'];
        }
        echo '<div class="section-title">';
        echo '<a href="' . $url . '">';
        echo '<h2>' . $pattern_counter . ') ' . $pattern['name'] . '</h2>';
        echo '</a>';
        if ($current_pattern) {
            echo '<h3>' . $pattern['description'] . ' This shortcode type is "' . $pattern['slug'] . '."</h3>';
            if (isset($pattern['notes'])) {
                foreach ($pattern['notes'] as $pattern_note) {
                    echo '<p>' . $pattern_note . '</p>';
                }
                //foreach
            }
        }
        echo '</div><!-- section-title -->';
        if ($current_pattern) {
            $shortcodes = ostk_getShortCode($pattern['example_shortcodes']);
            foreach ($shortcodes as $shortcode) {
                echo '<h3 class="center">' . $pattern['name'] . ' Sample Shortcode</h3>';
                echo '<code>' . $shortcode . '</code>';
                echo '<div class="shortcode-output">';
                echo do_shortcode($shortcode);
                echo '</div><!--.shortcode-output-->';
            }
            //foreach
            echo '<div class="atts">';
            if (isset($pattern['required_attributes'])) {
                echo '<h3>' . $pattern['name'] . ' Required Attributes</h3>';
                echo '<ul>';
                echo ostk_get_pattern_attributes($pattern['required_attributes']);
                echo '</ul>';
            }
            if (isset($pattern['optional_attributes'])) {
                echo '<h3>' . $pattern['name'] . ' Optional Attributes</h3>';
                echo '<ul>';
                echo ostk_get_pattern_attributes($pattern['optional_attributes']);
                echo '</ul>';
            }
            echo '</div><!--atts-->';
        }
        $pattern_counter++;
    }
    //foreach
    ?>

		</div><!-- ostk-doc-page -->
	</div><!--.ostk-plugin-settings-->
	<?php 
    echo ob_get_clean();
}
function ostk_admin_page()
{
    ob_start();
    if (empty(get_option('ostk_settings'))) {
        $ostk_submitBtnText = 'Add ID';
    } else {
        $ostk_submitBtnText = 'Save Changes';
    }
    ?>

	<div class="ostk-plugin-settings">
		<?php 
    echo ostk_get_header('admin');
    ?>
		<div class="ostk-page ostk-home-page">
		 	<h1>Welcome to Overstock.com's Affiliate Shortcode Plugin!</h1>
		 	<p>We are honored that you would allow us to display some of our products on your blog. We spent a lot of time and effort creating the most beautiful embeddable objects on the internet :)</p>

			<div class="icon icon-chevron-down"></div>
			<i class="fa fa-envelope"></i>
			<i class="fa fa-email-envelope"></i>
			<i class="fa fa-o"></i>


			
		    <form action="options.php" method="post">
		      <?php 
    settings_fields('ostk_settings_group');
    ?>
		        <h2>Authenticate LinkShare ID: </h2>

				<?php 
    if (empty(get_option('ostk_settings'))) {
        ?>
					<div class="ostk-notification-block ostk-notification-danger">
						<p>You'll need an authentic LinkShare ID provided free at <a href="http://overstock.com/devapi/" target="_blank" title="Overstock DEV API">http://overstock.com/devapi/</a></p>
					</div>
				<?php 
    } else {
        ?>
					<div class="ostk-notification-block ostk-notification-success">
						<p>Thank you for submitting your LinkShare ID.</p>
					</div>
				<?php 
    }
    ?>

				<p>Paste your LinkShare ID here.</p> 
			 	<p>If the Link Share ID is not valid the affiliate links will bring the user to a page that says, "invalid site code"</p>
		        <input id="ostk_settings" name="ostk_settings" type="text" value="<?php 
    echo get_option('ostk_settings');
    ?>
"/>
		        <input name="Submit" type="submit" class="btn" value="<?php 
    esc_attr_e($ostk_submitBtnText);
    ?>
" />
		    </form>
		</div><!--.ostk-home-page-->
	</div><!--.ostk-plugin-settings-->
	<?php 
    echo ob_get_clean();
}