<?php
/**
 * The Header for our theme.
 *
 * Displays all of the <head> section and everything up till <div class="container">
 *
 * @package Home Guard
 */
?><!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="#TabNavigator">
<?php esc_html_e( 'Skip to content', 'home-guard' ); ?>
</a>
<?php
$home_guard_show_hdinfodetails 	   	= esc_attr( get_theme_mod('home_guard_show_hdinfodetails', false) ); 
$home_guard_show_frontslider_sections 	  		= esc_attr( get_theme_mod('home_guard_show_frontslider_sections', false) );
$home_guard_show_fix3page_sections      	= esc_attr( get_theme_mod('home_guard_show_fix3page_sections', false) );
$home_guard_show_securitysolution      	= esc_attr( get_theme_mod('home_guard_show_securitysolution', false) );
$home_guard_show_sixcolumnservices_sections      	= esc_attr( get_theme_mod('home_guard_show_sixcolumnservices_sections', false) );

?>
<div id="SiteWrapper" <?php if( get_theme_mod( 'home_guard_layoutoption' ) ) { echo 'class="boxlayout"'; } ?>>
<?php
if ( is_front_page() && !is_home() ) {
	if( !empty($home_guard_show_frontslider_sections)) {
	 	$innerpage_cls = '';
	}
	else {
		$innerpage_cls = 'innerpage_header';
	}
}
else {
$innerpage_cls = 'innerpage_header';
}
?>

<div id="masthead" class="site-header <?php echo esc_attr($innerpage_cls); ?> "> 
      <div class="hdr-topstrip"> 
        <div class="container">
          <div class="hdrinfofixer"> 
            <?php if( $home_guard_show_hdinfodetails != ''){ ?>            
				<?php $email = get_theme_mod('home_guard_emailid');
					if( !empty($email) ){ ?>                
					<div class="hdrtop-Info">
                        <i class="far fa-envelope"></i>
                        <a href="<?php echo esc_url('mailto:'.sanitize_email($email)); ?>"><?php echo sanitize_email($email); ?></a>
					</div>            
                <?php } ?>
				<?php $home_guard_phoneno = get_theme_mod('home_guard_phoneno');
					if( !empty($home_guard_phoneno) ){ ?>              
					<div class="hdrtop-Info">
						<i class="fas fa-phone fa-rotate-90"></i>
						<?php echo esc_html($home_guard_phoneno); ?>
					</div>       
               <?php } ?>
              <div class="hdrtop-Info last-child">               
                    <div class="hdrsocial">                                                
					   <?php $home_guard_topfblink = get_theme_mod('home_guard_topfblink');
                        if( !empty($home_guard_topfblink) ){ ?>
                        <a class="fab fa-facebook-f" target="_blank" href="<?php echo esc_url($home_guard_topfblink); ?>"></a>
                       <?php } ?>
                    
                       <?php $home_guard_toptwlink = get_theme_mod('home_guard_toptwlink');
                        if( !empty($home_guard_toptwlink) ){ ?>
                        <a class="fab fa-twitter" target="_blank" href="<?php echo esc_url($home_guard_toptwlink); ?>"></a>
                       <?php } ?>
                
                      <?php $home_guard_topinlink = get_theme_mod('home_guard_topinlink');
                        if( !empty($home_guard_topinlink) ){ ?>
                        <a class="fab fa-linkedin" target="_blank" href="<?php echo esc_url($home_guard_topinlink); ?>"></a>
                      <?php } ?> 
                      
                      <?php $home_guard_topigramlink = get_theme_mod('home_guard_topigramlink');
                        if( !empty($home_guard_topigramlink) ){ ?>
                        <a class="fab fa-instagram" target="_blank" href="<?php echo esc_url($home_guard_topigramlink); ?>"></a>
                      <?php } ?> 
                 </div><!--end .hdrsocial--> 
                </div> 
              <?php } ?>
           </div><!--end .container-->   
         </div><!--end .container-->   
      </div><!-- .hdr-topstrip --> 
 
       <div class="container">       
        <div class="logo <?php if( empty($home_guard_show_hdinfodetails)) { ?>logofix<?php } ?>">
           <?php home_guard_the_custom_logo(); ?>
            <div class="site_branding">
                <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>
         </div><!-- logo --> 
         
          <div class="RightNavMenu"> 
             <div id="navigationpanel"> 
                 <nav id="main-navigation" class="site-navigation" role="navigation" aria-label="Primary Menu">
                    <button type="button" class="menu-toggle">
                        <span class="icon-bar"></span>
                        <span class="icon-bar"></span>
                        <span class="icon-bar"></span>
                    </button>
                    <?php
                    wp_nav_menu( array(
                        'theme_location' => 'primary',
                        'menu_id'        => 'primary-menu',
                        'menu_class'     => 'nav-menu',
                    ) );
                    ?>
                </nav><!-- #main-navigation -->  
            </div><!-- #navigationpanel -->   
          </div><!-- .RightNavMenu --> 
         <div class="clear"></div>   
      </div><!-- .container -->           
 <div class="clear"></div> 
</div><!--.site-header --> 
 
<?php 
if ( is_front_page() && !is_home() ) {
if($home_guard_show_frontslider_sections != '') {
	for($i=1; $i<=3; $i++) {
	  if( get_theme_mod('home_guard_frontslider_pge'.$i,false)) {
		$slider_Arr[] = absint( get_theme_mod('home_guard_frontslider_pge'.$i,true));
	  }
	}
?> 
<div class="HomepageSlider">              
<?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>
     <p><?php $excerpt = get_the_excerpt(); echo esc_html( home_guard_string_limit_words( $excerpt, esc_attr(get_theme_mod('home_guard_excerpt_length_frontslider','15')))); ?></p>
		<?php
        $home_guard_frontslider_pge_btntext = get_theme_mod('home_guard_frontslider_pge_btntext');
        if( !empty($home_guard_frontslider_pge_btntext) ){ ?>
            <a class="slidermorebtn" href="<?php the_permalink(); ?>"><?php echo esc_html($home_guard_frontslider_pge_btntext); ?></a>
        <?php } ?>                  
    </div>   
<?php $j++; 
endwhile;
wp_reset_postdata(); ?>   
<?php } ?>
 </div><!-- .HomepageSlider -->    
<?php } } ?> 

<?php if ( is_front_page() && ! is_home() ) { ?>  
 <?php if( $home_guard_show_fix3page_sections != ''){ ?> 
   <section id="PageSections-1">
     <div class="container"> 
       <div class="best-3-features">        
          <?php 
                for($n=1; $n<=3; $n++) {    
                if( get_theme_mod('home_guard_fix3page_column'.$n,false)) {      
                    $queryvar = new WP_Query('page_id='.absint(get_theme_mod('home_guard_fix3page_column'.$n,true)) );		
                    while( $queryvar->have_posts() ) : $queryvar->the_post(); ?>     
                     <div class="fix3column <?php if($n % 2 == 0) { echo "highlight"; } ?>">   
							 <?php if(has_post_thumbnail() ) { ?>
                                <div class="sm-iconbx">
                                  <a href="<?php the_permalink(); ?>"><?php the_post_thumbnail(); ?></a>                                
                                </div>        
                             <?php } ?>
                                <h4><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></h4> 
                                <p><?php $excerpt = get_the_excerpt(); echo esc_html( home_guard_string_limit_words( $excerpt, esc_attr(get_theme_mod('home_guard_fix3pagecolumn_excerpt_length','0')))); ?></p> 
                                <a class="morehg" href="<?php the_permalink(); ?>"></a>
                              
                      </div>
                    <?php endwhile;
                    wp_reset_postdata();                                  
                } } ?>                                 
               <div class="clear"></div>  
         </div><!-- .best-3-features-->       
      </div><!-- .container -->
    </section><!-- #PageSections-1 -->
  <?php } ?> 
  
  <?php if( $home_guard_show_securitysolution != ''){ ?>  
    <section id="security-solution-section">
    <div class="container">                               
		<?php 
        if( get_theme_mod('home_guard_securitysolution',false)) {     
        $queryvar = new WP_Query('page_id='.absint(get_theme_mod('home_guard_securitysolution',true)) );			
            while( $queryvar->have_posts() ) : $queryvar->the_post(); ?>            
              
              <div class="security-left-50">   
                <h3><?php the_title(); ?></h3>   
                <?php the_content();  ?>      
              </div>              
              <div class="security-right-45">
			    <?php the_post_thumbnail();?>
                
                  <div class="security-phoneBX">				
                    <div class="phoneicon"><i class="fas fa-phone fa-rotate-90"></i></div> 
					 <?php
						$home_guard_callustextfor2sec = get_theme_mod('home_guard_callustextfor2sec');
						if( !empty($home_guard_callustextfor2sec) ){ ?>
						<span><?php echo esc_html($home_guard_callustextfor2sec); ?></span>
                     <?php } ?> 
                    
                     <?php
						$home_guard_phonefor2sec = get_theme_mod('home_guard_phonefor2sec');
						if( !empty($home_guard_phonefor2sec) ){ ?>
						<h2><?php echo esc_html($home_guard_phonefor2sec); ?></h2>
					 <?php } ?> 			
                 </div> 
            </div>                                          
            <?php endwhile;
             wp_reset_postdata(); ?>                                    
            <?php } ?>                                 
      <div class="clear"></div>                       
     </div><!-- .container -->
    </section><!-- #welcome_section-->
 <?php } ?>  
 
 
 <?php if( $home_guard_show_sixcolumnservices_sections != ''){ ?> 
   <section id="PageSections-3">
     <div class="container"> 
         <div class="box-equal-height">  
          <?php 
                for($n=1; $n<=6; $n++) {    
                if( get_theme_mod('home_guard_sixcolumnservices_pg'.$n,false)) {      
                    $queryvar = new WP_Query('page_id='.absint(get_theme_mod('home_guard_sixcolumnservices_pg'.$n,true)) );		
                    while( $queryvar->have_posts() ) : $queryvar->the_post(); ?>     
                     <div class="sixcirclecolumn  <?php if($n % 6 == 0) { echo "last_column"; } ?>"> 
                        <div class="topboxbg">  
							 <?php if(has_post_thumbnail() ) { ?>
                                <div class="thumbbx">
                                  <a href="<?php the_permalink(); ?>"><?php the_post_thumbnail(); ?></a>                                
                                </div>        
                             <?php } ?>
                                <h4><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></h4> 
                                <p><?php $excerpt = get_the_excerpt(); echo esc_html( home_guard_string_limit_words( $excerpt, esc_attr(get_theme_mod('home_guard_fix3pagecolumn_excerpt_length','0')))); ?></p> 
                               
                      </div>
                      </div>
                    <?php endwhile;
                    wp_reset_postdata();                                  
                } } ?>                                 
               <div class="clear"></div>  
         </div><!-- .box-equal-height-->       
      </div><!-- .container -->
    </section><!-- #PageSections-1 -->
  <?php } ?> 
<?php } ?>