<?php
/**
 * The Header for our theme.
 *
 * Displays all of the <head> section and everything up till <div id="main">
 *
 * @package Morgan
 * @since Morgan 1.0
 */
?><!DOCTYPE html>
<html <?php language_attributes(); ?>>
<head>
<meta charset="<?php bloginfo( 'charset' ); ?>" />
<meta name="viewport" content="width=device-width" />
<title><?php wp_title( '|', true, 'right' ); ?></title>
<link rel="profile" href="http://gmpg.org/xfn/11" />
<link rel="pingback" href="<?php bloginfo( 'pingback_url' ); ?>" />
<!--[if lt IE 9]>
<script src="<?php echo get_template_directory_uri(); ?>/js/html5.js" type="text/javascript"></script>
<![endif]-->
<?php $heading_font = of_get_option('morgan_heading_font'); ?>
<?php $body_font = of_get_option('morgan_body_font'); ?>
<?php $home_message_font = of_get_option('morgan_home_message_font'); ?>
<?php if ($heading_font != "") : ?>
	<link rel="stylesheet" type="text/css" href="http://fonts.googleapis.com/css?family=<?php echo(urlencode($heading_font)); ?>:regular,italic,bold,bolditalic" />
<?php endif; ?>

<?php if ($body_font != "" && $body_font != $heading_font) : ?>
	<link rel="stylesheet" type="text/css" href="http://fonts.googleapis.com/css?family=<?php echo(urlencode($body_font)); ?>:regular,italic,bold,bolditalic" />
<?php endif; ?>

<?php if ($home_message_font != "") : ?>
	<link rel="stylesheet" type="text/css" href="http://fonts.googleapis.com/css?family=<?php echo(urlencode($home_message_font)); ?>:regular,italic,bold,bolditalic" />
<?php endif; ?>
	
<?php if (of_get_option('morgan_favicon') ) : ?>
	<link rel="shortcut icon" href="<?php echo of_get_option('morgan_favicon'); ?>" />
<?php endif; ?>
<link rel="apple-touch-icon" href="/wp-content/uploads/2014/02/ios_icon_57.png" />
<link rel="apple-touch-icon" sizes="72x72" href="/wp-content/uploads/2014/02/ios_icon_72.png"/>
<link rel="apple-touch-icon" sizes="114x114" href="/wp-content/uploads/2014/02/ios_icon_114.png"/>

<?php wp_head(); ?>
</head>

<body <?php body_class(); ?>>
<div id="page" class="hfeed site">
	<?php do_action( 'before' ); ?>
			<?php
			$morgan_fb = of_get_option( 'social_fb' );
			$morgan_twitter = of_get_option( 'social_twitter' );
			$morgan_gplus = of_get_option( 'social_gplus' );
			$morgan_phone = of_get_option( 'morgan_phone' );
			$morgan_street = of_get_option( 'morgan_street' );
			$morgan_address = of_get_option( 'morgan_address' );
	?>
	<header id="masthead" class="site-header <?php if($morgan_fb || $morgan_twitter || $morgan_gplus || $morgan_phone || $morgan_street || $morgan_address) : echo 'topline'; else : endif;?>" role="banner">
		<?php
		if( $morgan_fb || $morgan_twitter || $morgan_gplus || $morgan_phone || $morgan_street || $morgan_address ) :
		?>
		<div id="topline">
			<div class="wrapper">
				<ul class="top-contact">
					<?php if ( $morgan_street ) : 
						$address_url = preg_replace( '![^a-z0-9]+!i', '+', $morgan_street. ' ' .$morgan_address );?>
					<li class="church-address">
						<i class="icon-map-marker"></i> <a href="<?php echo 'http://maps.google.com/maps?q=' . $address_url; ?>" title="<?php esc_attr_e( 'Directions', 'morgan' ); ?>"><?php echo $morgan_street. ', ' .$morgan_address; ?></a>
					</li>
					<?php endif; ?>
					<?php if ( $morgan_phone ) : ?>
					<li class="church-phone">
						<i class="icon-mobile-phone"></i> <a href="tel:<?php echo $morgan_phone; ?>"><?php echo $morgan_phone; ?></a>
					</li>
					<?php endif; ?>
				</ul>
				<div id="top-social">
					<ul class="top-social">
						<?php if ( $morgan_fb ) : ?>
							<li><a class="facebook" href="<?php echo esc_url( $morgan_fb ); ?>" title="<?php esc_attr_e( 'Facebook', 'morgan' ); ?>"><i class="icon-facebook"></i><span><?php _e( 'Facebook', 'morgan' ); ?></span></a></li>
						<?php endif; ?>

						<?php if ( $morgan_twitter ) : ?>
							<li><a class="twitter" href="<?php echo esc_url( $morgan_twitter ); ?>" title="<?php esc_attr_e( 'Twitter', 'morgan' ); ?>"><i class="icon-twitter"></i><span><?php _e( 'Twitter', 'morgan' ); ?></span></a></li>
						<?php endif; ?>

						<?php if ( $morgan_gplus ) : ?>
							<li><a class="gplus" href="<?php echo esc_url( $morgan_gplus ); ?>" title="<?php esc_attr_e( 'Google+', 'morgan' ); ?>"><i class="icon-google-plus"></i><span><?php _e( 'Google+', 'morgan' ); ?></span></a></li>
						<?php endif; ?>
					</ul>
				</div><!-- #top-social -->
			</div><!-- .wrapper -->
		</div><!-- #topline -->
		<?php endif; ?>
		<div class="wrapper">
			<hgroup>
			<?php $morgan_logo = of_get_option('logo'); ?>
			<?php if($morgan_logo) : ?>				
				<p class="site-title"><a href="<?php echo home_url( '/' ); ?>"><img src="<?php echo $morgan_logo; ?>" alt="<?php bloginfo('name'); ?>" /></a></h1>
			<?php else : ?>				
				<p class="site-title"><a href="<?php echo home_url( '/' ); ?>" title="<?php echo esc_attr( get_bloginfo( 'name', 'display' ) ); ?>" rel="home"><?php bloginfo( 'name' ); ?></a></h1>
				<p class="site-description"><?php bloginfo( 'description' ); ?></h2>
			<?php endif; ?>	
			</hgroup>
			<div id="search-top">
				<?php get_search_form(); ?>
			</div>
			<nav role="navigation" class="site-navigation main-navigation <?php if($morgan_logo) : echo 'logo'; else : endif;?>">
				<h3 class="assistive-text"><?php _e( 'Menu', 'morgan' ); ?></h3>
				<div class="assistive-text skip-link"><a href="#content" title="<?php esc_attr_e( 'Skip to content', 'morgan' ); ?>"><?php _e( 'Skip to content', 'morgan' ); ?></a></div>

				<?php wp_nav_menu( array( 'theme_location' => 'primary' ) ); ?>
			</nav><!-- .site-navigation .main-navigation -->
		</div><!-- .wrapper -->
	</header><!-- #masthead .site-header -->
		
	<div id="main" class="site-main">
		<div class="wrapper">
		<?php 
		if ( function_exists( 'yoast_breadcrumb' ) && !is_home() )
			yoast_breadcrumb( '<p id="breadcrumbs">', '</p>' );
		?>