    <?php
/**
 * The Header template for our theme
 */
$legal_options = get_option('legal_theme_options'); ?>
<!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">
        <link rel="pingback" href="<?php bloginfo( 'pingback_url' ); ?>">        
        <?php wp_head(); ?>
    </head>
    <body <?php body_class(); ?>>
        <?php if ( function_exists( 'wp_body_open' ) ) { wp_body_open();   }  ?>
        <header>
            <?php $TopHeaderSocialIconDefault = array(
                  array('url'=>isset($legal_options['facebook'])?$legal_options['facebook']:'#','icon'=>'fa-facebook'),
                  array('url'=>isset($legal_options['twitter'])?$legal_options['twitter']:'#','icon'=>'fa-twitter'),
                  array('url'=>isset($legal_options['pinterest'])?$legal_options['pinterest']:'#','icon'=>'fa-pinterest'),  
                  array('url'=>isset($legal_options['gplus'])?$legal_options['gplus']:'#','icon'=>'fa-google-plus'),
                );
            $social_links_flag=false; 
            for($i=1; $i<=4; $i++) : 
                if(get_theme_mod('TopHeaderSocialIconLink'.$i,$TopHeaderSocialIconDefault[$i-1]['url'])!='' && get_theme_mod('TopHeaderSocialIcon'.$i,$TopHeaderSocialIconDefault[$i-1]['icon'])!=''):
                 $social_links_flag=true; 
                endif;
            endfor;
                if (get_theme_mod('theme_email_id',isset($legal_options['email'])?$legal_options['email']:'')!='' || get_theme_mod('theme_contact_title',isset($legal_options['number-title'])?$legal_options['number-title']:'')!='' || get_theme_mod('theme_phone_number',isset($legal_options['number'])?$legal_options['number']:'')!='' || $social_links_flag) { ?>
                <div class="top-header">
                    <div class="container theme-container"> 
                        <div class="row">
                            <div class="col-md-6 col-sm-7 col-xs-12 social-part">
                                <?php if (get_theme_mod('theme_email_id',isset($legal_options['email'])?$legal_options['email']:'')!='') { ?>
                                    <p class="top-header-email">
                                        <i class="fa fa-envelope"></i><a href="mailto:<?php echo esc_attr(get_theme_mod('theme_email_id',isset($legal_options['email'])?$legal_options['email']:'')); ?>"><?php echo esc_html(get_theme_mod('theme_email_id',isset($legal_options['email'])?$legal_options['email']:'')); ?></a>
                                    </p> <?php } ?>
                                <ul>
                                <?php if($social_links_flag):
                                        for($i=1; $i<=4; $i++) : 
                                            if(get_theme_mod('TopHeaderSocialIconLink'.$i,$TopHeaderSocialIconDefault[$i-1]['url'])!='' && get_theme_mod('TopHeaderSocialIcon'.$i,$TopHeaderSocialIconDefault[$i-1]['icon'])!=''): ?>
                                           <li><a href="<?php echo esc_url(get_theme_mod('TopHeaderSocialIconLink'.$i,$TopHeaderSocialIconDefault[$i-1]['url'])); ?>" class="icon" title="" target="_blank">
                                                <i class="fa <?php echo esc_attr(get_theme_mod('TopHeaderSocialIcon'.$i,$TopHeaderSocialIconDefault[$i-1]['icon'])); ?>"></i>
                                            </a></li>
                                    <?php endif; endfor; endif;?> 
                                </ul>                               
                            </div>
                            <div class="col-md-6 col-sm-5 col-xs-12 callus-part">
                                <p>
                                    <?php if (get_theme_mod('theme_contact_title',isset($legal_options['number-title'])?$legal_options['number-title']:'')!='' ) { ?><span><?php echo esc_html(get_theme_mod('theme_contact_title',isset($legal_options['number-title'])?$legal_options['number-title']:'')); ?> :</span> <?php } ?>
                                    <?php if (get_theme_mod('theme_phone_number',isset($legal_options['number'])?$legal_options['number']:'')!='') {
                                            echo esc_html(get_theme_mod('theme_phone_number',isset($legal_options['number'])?$legal_options['number']:''));
                                        } ?>
                                </p>
                            </div>
                        </div>
                    </div>
                </div>
            <?php } ?>

            <!-- Fixed navbar -->
            <nav id="header" class=" main-nav bottom-header">
            <div id="header-container" class="container header-wrap ">
                    <div class="row">
                        <div class="col-md-12 col-sm-12 col-xs-12">
                            <div class="navbar-header-logo main-logo theme-logo"> 
                                <?php 
                                if(has_custom_logo()){
                                    the_custom_logo();
                                } ?>
                                <?php if(display_header_text()): ?>
                                <a href="<?php echo esc_url(home_url('/')); ?>" rel="home" id='brand' class="custom-logo-link"><h2 class="site-title"><?php echo esc_html( get_bloginfo( 'name' ) ); ?></h2><p class="site-description"><?php echo esc_html( get_bloginfo( 'description' ) ); ?></p></a>   
                                <?php endif; ?>
                            </div>
                            <div id="mainmenu" >
                                <?php wp_nav_menu(array(
                                        'theme_location'  => 'top-header-menu',                              
                                        'echo' => true, 
                                        'container'       => 'ul', 
                                        'menu_class'      => 'navbar-nav',
                                        'depth'           => 0,
                                    ));
                                 ?>
                            </div><!-- /.nav-collapse -->
                        </div>
                    </div>
                </div><!-- /.container -->
            </nav><!-- /.navbar -->

        </header>
        <?php if (get_header_image()) { ?>
                <div class="custom-header-img">
                    <a href="<?php echo esc_url(home_url('/')); ?>" rel="home">
                        <img src="<?php header_image(); ?>" width="<?php echo esc_attr(get_custom_header()->width); ?>" height="<?php echo esc_attr(get_custom_header()->height); ?>" alt="<?php the_title_attribute(); ?>">
                    </a>
                </div>
        <?php } ?>