<?php
if ( !defined('ABSPATH')) exit; // Exit if accessed directly
/**
 * The Header for our theme.
 *
 * Displays all of the <head> section and everything up till < div id="main" >
 *
 * @package WordPress
 * @subpackage Aspen
 * @since Aspen 1.0
 *
 * 	>>>> DO NOT EDIT THIS FILE <<<<
 *
 * Warning! DO NOT EDIT THIS FILE, or any other theme file! If you edit ANY theme
 * file, all your changes will be LOST when you update the theme to a newer version.
 * Instead, if you need to change theme functionality, CREATE A CHILD THEME!
 *
 *	>>>> DO NOT EDIT THIS FILE <<<<
 */
if (function_exists('aspen_ts_pp_switch'))
	aspen_ts_pp_switch();
?><!DOCTYPE html>
<!--[if IE 7]>	<html id="ie7" <?php language_attributes(); ?>> <![endif]-->
<!--[if IE 8]>	<html id="ie8" <?php language_attributes(); ?>> <![endif]-->
<!--[if IE 9]>	<html id="ie9" <?php language_attributes(); ?>> <![endif]-->
<!--[if !(IE 6) | !(IE 7) | !(IE 8) ] | !(IE 9) ><!-->	<html <?php language_attributes(); ?>> <!--<![endif]-->
<head>
<meta charset="<?php bloginfo( 'charset' ); ?>" />
<?php
	$viewport = "<meta name='viewport' content='width=device-width' />\n";
	echo $viewport;
?>
<title><?php		// ++++++ HEAD TITLE ++++++
	wp_title('');		// the title - will run through our filter
?></title>

<link rel="profile" href="http://gmpg.org/xfn/11" />
<link rel="pingback" href="<?php esc_url(bloginfo( 'pingback_url' )); ?>" />
<?php

	$sheet_dev = get_stylesheet_directory_uri() . '/style.css';	// get style.css
	$sheet = str_replace('.css', ASPEN_MINIFY.'.css',$sheet_dev); // default sheet
	$sheet_file = get_stylesheet_directory() . '/style' . ASPEN_MINIFY . '.css';
	if (! @file_exists($sheet_file))
	$sheet = $sheet_dev;		// no style.min.css available (need this check for child themes)
	$sheet_name = 'aspen-main-style-sheet';

	if (aspen_getopt('themename') == 'none-preview') {
        $sheet = str_replace('style.css','style-preview.min.css',$sheet_dev); // default sheet
	}

	wp_register_style($sheet_name,$sheet,array(),ASPEN_VERSION,'all');
	wp_enqueue_style($sheet_name);
	// the mobile style sheet

	if (!aspen_getopt_checked('theme_width_fixed')) {
        $sheet = get_template_directory_uri() . '/style-mobile'.ASPEN_MINIFY.'.css';
        $sheet_name = 'aspen-mobile-style-sheet';
        wp_register_style($sheet_name,$sheet,array(),ASPEN_VERSION,'all');
        wp_enqueue_style($sheet_name);
	}
?>
<!--[if lt IE 9]>
<script src="<?php echo esc_url(get_template_directory_uri()); ?>/js/html5.js" type="text/javascript"></script>
<![endif]-->

<?php			// ++++ CSS AND CUSTOM SCRIPTS ++++
	$icon = aspen_getopt('_favicon_url');
	if ($icon != '') {
        $url = esc_url(apply_filters('aspen_css',parse_url($icon,PHP_URL_PATH)));
        echo "<link rel=\"shortcut icon\"  href=\"$url\" />\n";
	}

	if ( !aspen_use_inline_css(aspen_get_css_filename()) ) { // don't generate inline CSS
        $vers = aspen_getopt('style_version');
        if (!$vers) $vers = '1';
        else $vers = sprintf("%d",$vers);
        wp_register_style('aspen-style-sheet',aspen_get_css_url(),array($sheet_name),$vers);
        wp_enqueue_style('aspen-style-sheet');
	}

	do_action('aspen_pro','head');	// stuff like other style files...

	wp_head();
?>
</head>

<body <?php body_class(); ?>>
<a href="#page-bottom" id="page-top">&darr;</a> <!-- add custom CSS to use this page-bottom link -->
<?php


	aspen_inject_area('prewrapper');

	aspen_e_notopt('header_first',"<div id=\"wrapper\" class=\"hfeed\">\n");	// put the header before the wrapper?

	aspen_inject_area('preheader');

	if ( !aspen_is_checked_page_opt('pp_hide_header') ) {
		echo "<div id=\"wrap-header\">\n";
        if (!aspen_getopt('top_menu_before_header'))
            do_action('aspen_nav', 'top');
?>
	<header id="branding" role="banner"><div id="branding-content">
<?php
		/* ======== SITE LOGO and TITLE ======== */
		$title = esc_html( get_bloginfo( 'name', 'display' ) );
?>
		<div id="site-logo"></div>
		<div id="site-logo-link" onclick="location.href='<?php echo esc_url(home_url( '/' )); ?>';"></div>

<?php
		$h_class = ' class="title-description"';
		if ( aspen_getopt('hide_site_title') || aspen_is_checked_page_opt('pp_hide_site_title') ) {
            $h_class = '';
		}
		if (aspen_getopt('title_over_header') || aspen_getopt('desc_over_header'))
            $h_class = '';

?>
		<div<?php echo $h_class; ?>>
			<h1 id="site-title"><span><a href="<?php echo esc_url( home_url( '/' ) ); ?>" title="<?php echo esc_attr( get_bloginfo( 'name', 'display' ) ); ?>" rel="home"><?php echo $title; ?></a></span></h1>
			<h2 id="site-description"> <?php bloginfo( 'description' ); ?></h2>
<?php
			$extra = aspen_getopt('header_html');
			$extra_img = aspen_getopt('header_html_img');
			if ($extra != '' || $extra_img != '') {
			$hide_mobile = aspen_getopt('header_html_hide_mobile') ? 'aspen-hide-mobile-mobile' : '';

			if ($hide_mobile != '')
			$hide_mobile = ' class="' . $hide_mobile . '"';
			if ($extra_img != '') {
                if (strstr($extra_img,'<img') === FALSE)
                    $extra_img = '<img class="header-logo" src="' . esc_url(apply_filters('aspen_css',esc_attr($extra_img))) .
                    '" alt="' . esc_attr( get_bloginfo( 'name', 'display' ) ) . '" />';
                else
                    $extra_img =  esc_attr($extra_img);
			}
?>
		<div id="header-extra-html"<?php echo $hide_mobile;?>><?php echo do_shortcode($extra) . $extra_img; ?></div>
<?php
		}
?>
		</div>

<?php
		if (aspen_getopt('top_menu_before_header'))
            do_action('aspen_nav', 'top');
		aspen_inject_area('header');	// inject header HTML
		aspen_inject_area('desktop_header');
		aspen_inject_area('mobile_header');

		do_action('aspen_pro','header_area_top');

		/* The Dynamic Headers shows headers on a per page basis - will also optionally add site link */
		if (function_exists('show_media_header'))
            show_media_header(); 			// Plugin support: **Dynamic Headers**

		/* ======== HEADER IMAGE ======== */
		global $aspen_header;

		if ( !( aspen_is_checked_page_opt('pp_hide_header_image') && !is_search() )
		&& ! aspen_getopt_checked('normal_hide_header_image' ) ) {

            if ( !aspen_getopt_checked('hide_header_image')
                && !(aspen_getopt('hide_header_image_front') && is_front_page() ) ) {

                echo("\t\t<div id=\"header_image\">\n");
                if (aspen_getopt('link_site_image')) {
    ?>
                <a href="<?php echo esc_url(home_url( '/' )); ?>" title="<?php echo esc_attr( get_bloginfo( 'name', 'display' ) ); ?>" rel="home">
    <?php
                }
                global $aspen_header;
                /* Check if this is a post or page, if it has a thumbnail,  and if it's a big one */
                if ( is_singular()
                    && !aspen_getopt('hide_featured_header')
                    && has_post_thumbnail( $post->ID )
                    && ($image = wp_get_attachment_image_src( get_post_thumbnail_id( $post->ID ), 'full' ) )  /* $src, $width, $height */
                    && $image[1] >= $aspen_header['width']
                ) {
                    echo get_the_post_thumbnail( $post->ID, 'full' );
                } else {
                    $hdr = get_header_image();
                    if ($hdr) {
        ?>
                    <img src="<?php echo $hdr ?>" <img src="<?php echo $hdr ?>" width="<?php echo get_custom_header()->width; ?>" height="<?php echo get_custom_header()->height; ?>" alt="<?php echo esc_attr( get_bloginfo( 'name', 'display' ) ); ?>" />
        <?php			} else {
                        echo '<div class="aspen-clear"></div>'; // needs a clear if not an img
                    }
                }
                aspen_e_opt('link_site_image',"</a>\n");	/* need to close link */
                echo("\t\t</div><!-- #header_image -->\n");
            } /* closes header > 0 */
		} /* end hide-header-image */

		do_action('aspen_pro','header_area_bottom');
?>
	</div></header><!-- #branding-content,#branding -->
<?php
		/* ======== BOTTOM MENU ======== */
		do_action('aspen_nav', 'bottom');
		echo "</div> <!-- #wrap-header -->\n";
		if (aspen_getopt('header_first'))
			echo '<div style="clear:both;"></div>';
	}	// end hide-header
	aspen_e_opt('header_first', "<div id=\"wrapper\" class=\"hfeed\">\n"); // wrapper after header
?>
