<?php
/**
 * The Header for our theme.
 *
 * Displays all of the <head> section and everything up till <div class="container">
 *
 * @package Housing Lite
 */
?><!DOCTYPE html>
<html <?php language_attributes(); ?>>
<head>
<meta charset="<?php bloginfo( 'charset' ); ?>">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="profile" href="http://gmpg.org/xfn/11">
<?php if ( is_singular() && pings_open( get_queried_object() ) ) : ?>
	<link rel="pingback" href="<?php echo esc_url( get_bloginfo( 'pingback_url' )); ?>">
<?php endif; ?>
<?php wp_head(); ?>
</head>
<body <?php body_class(); ?>>
<?php
	if ( function_exists( 'wp_body_open' ) ) {
		wp_body_open();
	} else {
		do_action( 'wp_body_open' );
	}
?>
<a class="skip-link screen-reader-text" href="#site-content">
<?php esc_html_e( 'Skip to content', 'housing-lite' ); ?>
</a>
<?php
$housing_lite_show_contactinfo_sections 	           = esc_attr( get_theme_mod('housing_lite_show_contactinfo_sections', false) );
$housing_lite_show_sociallink_sections        = esc_attr( get_theme_mod('housing_lite_show_sociallink_sections', false) ); 
$housing_lite_show_aboutus_pgecolumn               = esc_attr( get_theme_mod('housing_lite_show_aboutus_pgecolumn', false) ); 
$housing_lite_show_homeslider_section 	       = esc_attr( get_theme_mod('housing_lite_show_homeslider_section', false) );
$housing_lite_show_features_sections   = esc_attr( get_theme_mod('housing_lite_show_features_sections', false) );
?>
<div id="templatelayout" <?php if( get_theme_mod( 'housing_lite_boxlayoutoptions' ) ) { echo 'class="boxlayout"'; } ?>>
<?php
if ( is_front_page() && !is_home() ) {
	if( !empty($housing_lite_show_homeslider_section)) {
	 	$inner_cls = '';
	}
	else {
		$inner_cls = 'siteinner';
	}
}
else {
$inner_cls = 'siteinner';
}
?>

<div class="site-header <?php echo esc_attr($inner_cls); ?> ">   
  <div class="orangetopstrip"> 
    <div class="container">           
     <?php if( $housing_lite_show_contactinfo_sections != ''){ ?>   
      <div class="left"> 
      
        <?php 
            $housing_lite_header_addressbar = get_theme_mod('housing_lite_header_addressbar');
               if( !empty($housing_lite_header_addressbar) ){ ?>                
                 <div class="infodtlbx">
                     <i class="fas fa-map-marker-alt"></i>
                     <span>			      
                      <?php echo esc_html($housing_lite_header_addressbar); ?>
                    </span> 
                </div>            
          <?php } ?>      
          <?php $housing_lite_phonenumber = get_theme_mod('housing_lite_phonenumber');
               if( !empty($housing_lite_phonenumber) ){ ?>              
                 <div class="infodtlbx">
                     <i class="fas fa-phone-volume"></i>               
                     <span><?php echo esc_html($housing_lite_phonenumber); ?></span>   
                 </div>       
         <?php } ?>         
      </div><!--end .left-->                 
    <?php } ?>               
          
          <div class="right">
               <?php if( $housing_lite_show_sociallink_sections != ''){ ?>                
                    <div class="socialmedia">                                                
					   <?php $housing_lite_fbiconlink = get_theme_mod('housing_lite_fbiconlink');
                        if( !empty($housing_lite_fbiconlink) ){ ?>
                        <a class="fab fa-facebook-f" target="_blank" href="<?php echo esc_url($housing_lite_fbiconlink); ?>"></a>
                       <?php } ?>
                    
                       <?php $housing_lite_twiconlink = get_theme_mod('housing_lite_twiconlink');
                        if( !empty($housing_lite_twiconlink) ){ ?>
                        <a class="fab fa-twitter" target="_blank" href="<?php echo esc_url($housing_lite_twiconlink); ?>"></a>
                       <?php } ?>
                
                      <?php $housing_lite_gplusiconlink = get_theme_mod('housing_lite_gplusiconlink');
                        if( !empty($housing_lite_gplusiconlink) ){ ?>
                        <a class="fab fa-google-plus" target="_blank" href="<?php echo esc_url($housing_lite_gplusiconlink); ?>"></a>
                      <?php }?>
                
                      <?php $housing_lite_linkediniconlink = get_theme_mod('housing_lite_linkediniconlink');
                        if( !empty($housing_lite_linkediniconlink) ){ ?>
                        <a class="fab fa-linkedin" target="_blank" href="<?php echo esc_url($housing_lite_linkediniconlink); ?>"></a>
                      <?php } ?> 
                      
                      <?php $housing_lite_instagramiconlink = get_theme_mod('housing_lite_instagramiconlink');
                        if( !empty($housing_lite_instagramiconlink) ){ ?>
                        <a class="fab fa-instagram" target="_blank" href="<?php echo esc_url($housing_lite_instagramiconlink); ?>"></a>
                      <?php } ?> 
                 </div><!--end .socialmedia--> 
               <?php } ?>  
           
                      
           </div><!--end .right-->                
                     
       <div class="clear"></div>   
     </div><!-- .container -->   
 </div><!--end .orangetopstrip-->    

  
 <div class="container">
   <div class="logo_wrapper"> 
     <div class="logo">
           <?php housing_lite_the_custom_logo(); ?>
            <h1><a href="<?php echo esc_url( home_url( '/' ) ); ?>" rel="home"><?php bloginfo('name'); ?></a></h1>
            <?php $description = get_bloginfo( 'description', 'display' );
            if ( $description || is_customize_preview() ) : ?>
                <p><?php echo esc_html($description); ?></p>
            <?php endif; ?>
     </div><!-- logo --> 
  
     <div id="housingmainmenu">       
		   <button class="menu-toggle" aria-controls="main-navigation" aria-expanded="false" type="button">
			<span aria-hidden="true"><?php esc_html_e( 'Menu', 'housing-lite' ); ?></span>
			<span class="dashicons" aria-hidden="true"></span>
		   </button>

		  <nav id="main-navigation" class="site-navigation primary-navigation" role="navigation">
			<?php
			wp_nav_menu( array(
				'theme_location' => 'primary',
				'container' => 'ul',
				'menu_id' => 'primary',
				'menu_class' => 'primary-menu menu',
			) );
			?>
		  </nav><!-- .site-navigation -->
	    </div><!-- #housingmainmenu -->
       <div class="clear"></div>       
    </div><!-- .logo_wrapper --> 
  </div><!-- .container --> 
</div><!--.site-header --> 
 
<?php 
if ( is_front_page() && !is_home() ) {
if($housing_lite_show_homeslider_section != '') {
	for($i=1; $i<=3; $i++) {
	  if( get_theme_mod('housing_lite_sliderpge'.$i,false)) {
		$slider_Arr[] = absint( get_theme_mod('housing_lite_sliderpge'.$i,true));
	  }
	}
?> 
<div class="homeslide-sections">              
<?php if(!empty($slider_Arr)){ ?>
<div id="slider" class="nivoSlider">
<?php 
$i=1;
$slidequery = new WP_Query( array( 'post_type' => 'page', 'post__in' => $slider_Arr, 'orderby' => 'post__in' ) );
while( $slidequery->have_posts() ) : $slidequery->the_post();
$image = wp_get_attachment_url( get_post_thumbnail_id($post->ID)); 
$thumbnail_id = get_post_thumbnail_id( $post->ID );
$alt = get_post_meta($thumbnail_id, '_wp_attachment_image_alt', true); 
?>
<?php if(!empty($image)){ ?>
<img src="<?php echo esc_url( $image ); ?>" title="#slidecaption<?php echo esc_attr( $i ); ?>" alt="<?php echo esc_attr($alt); ?>" />
<?php }else{ ?>
<img src="<?php echo esc_url( get_template_directory_uri() ) ; ?>/images/slides/slider-default.jpg" title="#slidecaption<?php echo esc_attr( $i ); ?>" alt="<?php echo esc_attr($alt); ?>" />
<?php } ?>
<?php $i++; endwhile; ?>
</div>   

<?php 
$j=1;
$slidequery->rewind_posts();
while( $slidequery->have_posts() ) : $slidequery->the_post(); ?>                 
    <div id="slidecaption<?php echo esc_attr( $j ); ?>" class="nivo-html-caption">         
    	<h2><?php the_title(); ?></h2>
    	<?php the_excerpt(); ?>
		<?php
        $housing_lite_sliderpgebutton = get_theme_mod('housing_lite_sliderpgebutton');
        if( !empty($housing_lite_sliderpgebutton) ){ ?>
            <a class="slide_morebtn" href="<?php the_permalink(); ?>"><?php echo esc_html($housing_lite_sliderpgebutton); ?></a>
        <?php } ?>                  
    </div>   
<?php $j++; 
endwhile;
wp_reset_postdata(); ?>   
<?php } ?>
 </div><!-- .homeslide-sections -->    
<?php } } ?>

   
        
<?php if ( is_front_page() && ! is_home() ) { ?>

  <?php if( $housing_lite_show_aboutus_pgecolumn != ''){ ?>  
<section id="about_section">
<div class="container">                               
<?php 
if( get_theme_mod('housing_lite_aboutus_pgecolumn',false)) {     
$queryvar = new WP_Query('page_id='.absint(get_theme_mod('housing_lite_aboutus_pgecolumn',true)) );			
    while( $queryvar->have_posts() ) : $queryvar->the_post(); ?>                               
     <div class="aboutus_contentcol">   
        <h3><?php the_title(); ?></h3>   
       <?php the_content();  ?>      
    </div>
    <div class="aboutus_thumbox"><?php the_post_thumbnail();?></div>                                          
    <?php endwhile;
     wp_reset_postdata(); ?>                                    
    <?php } ?>                                 
  <div class="clear"></div>                       
 </div><!-- .container -->
</section><!-- #about_section-->
<?php } ?>

 <?php if( $housing_lite_show_features_sections != ''){ ?> 
   <section id="themeservices_section">
     <div class="container">
       
       <?php
            $housing_lite_shorttitletext = get_theme_mod('housing_lite_shorttitletext');
            if( !empty($housing_lite_shorttitletext) ){ ?>
                <div class="shorttitle_left">
                   <h2><?php echo esc_html($housing_lite_shorttitletext); ?></h2>
               </div> 
         <?php } ?>
         <?php
            $housing_lite_shortdesctext = get_theme_mod('housing_lite_shortdesctext');
            if( !empty($housing_lite_shortdesctext) ){ ?>
                <div class="shortdesc_right">
                   <p><?php echo esc_html($housing_lite_shortdesctext); ?></p>
               </div>
             <div class="clear"></div> 
         <?php } ?>       
          
      <div class="column_wrapper">  
               <?php 
                for($n=1; $n<=3; $n++) {    
                if( get_theme_mod('housing_lite_features_pagecol'.$n,false)) {      
                    $queryvar = new WP_Query('page_id='.absint(get_theme_mod('housing_lite_features_pagecol'.$n,true)) );		
                    while( $queryvar->have_posts() ) : $queryvar->the_post(); ?>     
                    <div class="services_colorbx <?php if($n % 3 == 0) { echo "last_column"; } ?>"> 
                      <div class="column_fixer bgbx<?php echo esc_attr( $n ); ?>">                                      
                        <?php if(has_post_thumbnail() ) { ?>
                        <div class="imagebox"><a href="<?php the_permalink(); ?>"><?php the_post_thumbnail(); ?></a></div>        
                        <?php } ?>
                        <div class="description_area">              	
                          <h3><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></h3> 
                          <?php the_excerpt(); ?>                                               
                         </div> 
                       </div>                            
                    </div>
                    <?php endwhile;
                    wp_reset_postdata();                                  
                } } ?>                                 
            <div class="clear"></div>
         </div>
      </div><!-- .container -->
    </section><!-- #themeservices_section -->
  <?php } ?>
<?php } ?>