<?php
include_once 'classes/Options.php';
$anps_media_data = $options->get_media();
if (isset($_GET['save_media'])) {
    $options->save_media(); 
}
?>
<form action="themes.php?page=theme_options&sub_page=options_media&save_media" method="post">
    <div class="content-top"><input type="submit" value="<?php _e("Save all changes", ANPS_TEMPLATE_LANG); ?>" /><div class="clear"></div></div>
    <div class="content-inner">
        <h3><?php _e("Heading background:", ANPS_TEMPLATE_LANG); ?></h3>
        <!-- Heading background -->
        <div class="input">
            <label for="heading_bg"><?php _e("Page heading background", ANPS_TEMPLATE_LANG); ?></label>
            <input id="heading_bg" type="text" size="36" name="heading_bg" value="<?php if(isset($anps_media_data['heading_bg'])){ echo $anps_media_data['heading_bg'];} else {echo "";} ?>" />
            <input id="_btn" class="upload_image_button" type="button" value="Upload" />
            <p><?php _e("Enter an URL or upload an image for the page heading background.", ANPS_TEMPLATE_LANG); ?></p>
        </div>
        <!-- Search heading background -->
        <div class="input">
            <label for="search_heading_bg"><?php _e("Search page heading background", ANPS_TEMPLATE_LANG); ?></label>
            <input id="search_heading_bg" type="text" size="36" name="search_heading_bg" value="<?php if(isset($anps_media_data['search_heading_bg'])){ echo $anps_media_data['search_heading_bg'];} else {echo "";} ?>" />
            <input id="_btn" class="upload_image_button" type="button" value="Upload" />
            <p><?php _e("Enter an URL or upload an image for the search page heading background.", ANPS_TEMPLATE_LANG); ?></p>
        </div>
        <hr>
        <h3><?php _e("Favicon and logo:", ANPS_TEMPLATE_LANG); ?></h3>
        <!-- Favicon -->
        <div class="input">
            <label for="favicon"><?php _e("Favicon", ANPS_TEMPLATE_LANG); ?></label>
            <div class="preview"><img src="<?php echo $anps_media_data['favicon']; ?>"></div>
            <input id="favicon" type="text" size="36" name="favicon" value="<?php if(isset($anps_media_data['favicon'])){ echo $anps_media_data['favicon'];} else {echo "";} ?>" />
            <input id="_btn" class="upload_image_button" type="button" value="Upload" />
            <p><?php _e("Enter an URL or upload an image for the favicon.", ANPS_TEMPLATE_LANG); ?></p>
        </div>
        <!-- Logo -->
        <div class="input">
            <label for="logo"><?php _e("Logo", ANPS_TEMPLATE_LANG); ?></label>
            <?php
                $logo_width = 160;
                $logo_height = 48;

                if(isset($anps_media_data['logo-width'])) {
                    $logo_width = $anps_media_data['logo-width'];
                }
                
                if(isset($anps_media_data['logo-height'])) {
                    $logo_height = $anps_media_data['logo-height'];
                }

                if(isset($anps_media_data['logo'])):
            ?>
            <div class="preview"><img width="<?php echo $logo_width; ?>" height="<?php echo $logo_height; ?>" src="<?php if(isset($anps_media_data['logo'])){ echo $anps_media_data['logo'];} else {echo "";} ?>"></div>
        <?php endif; ?>
            <input id="logo" type="text" size="36" name="logo" value="<?php if(isset($anps_media_data['logo'])){ echo $anps_media_data['logo'];} else {echo "";} ?>" />
            <input id="_btn" class="upload_image_button" type="button" value="Upload" />
            <p><?php _e("Enter an URL or upload an image for the logo.", ANPS_TEMPLATE_LANG); ?></p>
        </div>
        <!-- Secondary Logo -->
        <div class="input">
            <label for="secondary_logo"><?php _e("Secondary logo", ANPS_TEMPLATE_LANG); ?></label>
            <?php
                $logo_width = 160;
                $logo_height = 48;

                if(isset($anps_media_data['logo-width'])) {
                    $logo_width = $anps_media_data['logo-width'];
                }
                
                if(isset($anps_media_data['logo-height'])) {
                    $logo_height = $anps_media_data['logo-height'];
                }

                if(isset($anps_media_data['secondary_logo'])):
            ?>
            <div class="preview"><img width="<?php echo $logo_width; ?>" height="<?php echo $logo_height; ?>" src="<?php if(isset($anps_media_data['secondary_logo'])){ echo $anps_media_data['secondary_logo'];} else {echo "";} ?>"></div>
        <?php endif; ?>
            <input id="secondary_logo" type="text" size="36" name="secondary_logo" value="<?php if(isset($anps_media_data['secondary_logo'])){ echo $anps_media_data['secondary_logo'];} else {echo "";} ?>" style="width: 243px;"/>
            <input id="_btn" class="upload_image_button" type="button" value="Upload" />
            <p><?php _e("Enter an URL or upload an image for the secondary logo (logo will be on all other pages except home page).", ANPS_TEMPLATE_LANG); ?></p>
        </div>
        <!-- Sticky Logo -->
        <div class="input">
            <label for="sticky_logo"><?php _e("Sticky logo", ANPS_TEMPLATE_LANG); ?></label>
            <?php
                $logo_width = 160;
                $logo_height = 48;

                if(isset($anps_media_data['logo-width'])) {
                    $logo_width = $anps_media_data['logo-width'];
                }
                
                if(isset($anps_media_data['logo-height'])) {
                    $logo_height = $anps_media_data['logo-height'];
                }

                if(isset($anps_media_data['sticky_logo'])):
            ?>
            <div class="preview"><img width="<?php echo $logo_width; ?>" height="<?php echo $logo_height; ?>" src="<?php if(isset($anps_media_data['sticky_logo'])){ echo $anps_media_data['sticky_logo'];} else {echo "";} ?>"></div>
        <?php endif; ?>
            <input id="sticky_logo" type="text" size="36" name="sticky_logo" value="<?php if(isset($anps_media_data['sticky_logo'])){ echo $anps_media_data['sticky_logo'];} else {echo "";} ?>" style="width: 243px;"/>
            <input id="_btn" class="upload_image_button" type="button" value="Upload" />
            <p><?php _e("Enter an URL or upload an image for the sticky logo.", ANPS_TEMPLATE_LANG); ?></p>
        </div>

        <div class="input">
            <label for="logo-width"><?php _e("Logo width", ANPS_TEMPLATE_LANG); ?></label>
            <input style="width: 100px;" id="logo-width" type="text" name="logo-width" value="<?php echo $logo_width; ?>" /> px
        </div>

        <div class="input">
            <label for="logo-height"><?php _e("Logo height", ANPS_TEMPLATE_LANG); ?></label>
            <input style="width: 100px;" id="logo-height" type="text" name="logo-height" value="<?php echo $logo_height; ?>" /> px
        </div>
    </div>
    <div class="content-top" style="border-style: solid none; margin-top: 70px">
        <input type="submit" value="<?php _e("Save all changes", ANPS_TEMPLATE_LANG); ?>">
        <div class="clear"></div>
    </div>
</form>
<?php wp_enqueue_script('media-upload');
    wp_enqueue_script('thickbox');
    wp_register_script('my-upload', get_template_directory_uri() . '/anps-framework/js/upload_image.js', array('jquery', 'media-upload', 'thickbox'));
    wp_enqueue_script('my-upload');
    wp_enqueue_style('thickbox');
?>