<?php
$menu_style=get_post_meta(get_the_ID(), '_cmb_menu_style', true);
if($menu_style == 'default'){
    $menu_style=th_theme_data('theme_menu_style');
}
if(!$menu_style)
{
    $menu_style = 'top';
}
$init_pt = 25;
$init_pl = 25;
$initial_header_padding = th_theme_data('initial_header_padding');
if($initial_header_padding and isset($initial_header_padding['padding-top']) and $initial_header_padding['padding-left'] ) {
    $init_pt = $initial_header_padding['padding-top'];
    $init_pl = $initial_header_padding['padding-left'];
}
if( !is_404()){
    if( $menu_style == 'top' ){
        ?>
        <nav class="navbar navbar-default navbar-fixed-top header-nav" role="navigation">
            <div class="container">
                <!-- Brand and toggle get grouped for better mobile display -->
                <div class="navbar-header">
                    <button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#bs-example-navbar-collapse-1">
                        <span class="sr-only">Toggle navigation</span>
                        <span class="icon-bar"></span>
                        <span class="icon-bar"></span>
                        <span class="icon-bar"></span>
                    </button>
                    <!-- Logo -->
                    <a style="padding-top:<?php echo absint($init_pt); ?>px; padding-left:<?php echo absint($init_pl); ?>px;" class="navbar-brand" href="<?php echo home_url(); ?>" title="<?php bloginfo( 'name' ); ?>" rel="home">
                        <?php
                        $logo=th_theme_data('logo');
                        if($logo and isset($logo['url']) and $logo['url'] ){ ?>
                            <img src="<?php echo $logo['url'] ?>" alt="<?php bloginfo('name'); ?>">
                        <?php
                        }else {
                            echo get_bloginfo('name');
                        }?>
                    </a>
                </div>
                <!-- Collect the nav links, forms, and other content for toggling -->
                <?php
                if(has_nav_menu('main-menu'))
                {
                    wp_nav_menu(array(
                        'theme_location'=>'main-menu',
                        'walker'=>new wp_bootstrap_navwalker(),
                        'container_class'=>'collapse navbar-collapse',
                        'container_id'=>'bs-example-navbar-collapse-1',
                        'menu_class'=>'nav navbar-nav navbar-right'));
                }else{ ?>
                    <p class="navbar-right"><b>
						<?php echo esc_html_e('Make your menu at Appearance => Menus ','larx'); ?>
                    </b></p>
                <?php } ?>
            </div><!-- /.container-fluid -->
        </nav>
    <?php
    }
    if( $menu_style == 'canvas' ){
        if(has_nav_menu('main-menu')) {
            ?>
            <div class="offcanvas-nav">
                <div class="container">
                    <div class="row">
                        <!-- Navbar -->
                        <div class="col-md-4 col-xs-6">
                            <div class="topBar">
                                <a href="#menu"><i class="fa fa-bars fa-2x"></i></a>
                            </div>
                        </div>
                        <!-- Logo -->
                        <div class="col-md-4 col-xs-6 text-center">
                            <div class="nav-logo">
                                <a style="padding-top:<?php echo absint($init_pt); ?>px; padding-left:<?php echo absint($init_pl); ?>px;" href="<?php echo home_url(); ?>" title="<?php bloginfo( 'name' ); ?>" rel="home">
                                    <?php
                                    $logo=th_theme_data('logo');
                                    if($logo and isset($logo['url']) and $logo['url'] ){ ?>
                                        <img src="<?php echo $logo['url'] ?>" alt="<?php bloginfo('name'); ?>">
                                    <?php
                                    }else {
                                        echo get_bloginfo('name');
                                    }?>
                                </a>
                            </div>
                        </div>
                        <?php $switch_social=th_theme_data('switch_social');
                        if ($switch_social == 1 ): ?>
                            <!-- Social -->
                            <div class="col-md-4 hidden-sm hidden-xs">
                                <ul class="canvas-nav-social">
                                    <?php if(th_theme_data('facebook_url')): ?>
                                        <li><a href="<?php echo esc_url(th_theme_data('facebook_url')); ?>"><span class="fa-stack fa-lg"><i class="fa fa-circle fa-stack-2x"></i><i class="fa fa-facebook fa-stack-1x fa-inverse"></i></span></a></li>
                                    <?php endif;?>
                                    <?php if(th_theme_data('twitter_url')): ?>
                                        <li><a href="<?php echo esc_url(th_theme_data('twitter_url')); ?>"><span class="fa-stack fa-lg"><i class="fa fa-circle fa-stack-2x"></i><i class="fa fa-twitter fa-stack-1x fa-inverse"></i></span></a></li>
                                    <?php endif;?>
                                     <?php if(th_theme_data('skype_url')): ?>
                                        <li><a href="<?php echo esc_url(th_theme_data('skype_url')); ?>"><span class="fa-stack fa-lg"><i class="fa fa-circle fa-stack-2x"></i><i class="fa fa-skype fa-stack-1x fa-inverse"></i></span></a></li>
                                    <?php endif;?>
                                    <?php if(th_theme_data('pinterest_url')): ?>
                                        <li><a href="<?php echo esc_url(th_theme_data('pinterest_url')) ?>"><span class="fa-stack fa-lg"><i class="fa fa-circle fa-stack-2x"></i><i class="fa fa-pinterest fa-stack-1x fa-inverse"></i></span></a></li>
                                    <?php endif;?>
                                    <?php echo wp_kses_post(th_theme_data('custom_social')); ?>
                                </ul>
                            </div>
                        <?php endif;?>
                    </div>
                </div>
            </div>
            <nav id="menu">
                <!-- Navigation Links -->
                <?php
                    wp_nav_menu(array(
                        'theme_location'=>'main-menu',
                        'menu_class'=>'canvas-nav'));
        }else{ ?>
            <nav class="navbar navbar-default navbar-static header-nav" role="navigation">
                <div class="container">
                    <a class="navbar-brand" href="<?php echo home_url(); ?>"><?php echo get_bloginfo('name'); ?></a>
                    <p class="navbar-right">
                        <b><?php echo esc_html_e('Make your menu at Appearance => Menus ','larx'); ?></b>
                    </p>
                </div>
            </nav>
        <?php
        }
            ?>
            </nav>
    <?php
    }
    if( $menu_style == 'bottom' ) {
        ?>
        <div id="header" class="header">
            <nav class="navbar navbar-default navbar-static header-nav" role="navigation">
                <div class="container">
                    <!-- Brand and toggle get grouped for better mobile display -->
                    <div class="navbar-header">
                        <button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#bs-example-navbar-collapse-1">
                            <span class="sr-only">Toggle navigation</span>
                            <span class="icon-bar"></span>
                            <span class="icon-bar"></span>
                            <span class="icon-bar"></span>
                        </button>
                        <!-- Logo -->
                        <a style="padding-top:<?php echo absint($init_pt); ?>px; padding-left:<?php echo absint($init_pl); ?>px;" class="navbar-brand" href="<?php echo home_url(); ?>" title="<?php bloginfo( 'name' ); ?>" rel="home">
                            <?php
                            $logo=th_theme_data('logo');
                            if($logo and isset($logo['url']) and $logo['url'] ){ ?>
                                <img src="<?php echo $logo['url'] ?>" alt="<?php bloginfo('name'); ?>">
                            <?php
                            }else {
                                echo get_bloginfo('name');
                            }?>
                        </a>
                    </div>
                    <!-- Collect the nav links, forms, and other content for toggling -->
						<?php
						if(has_nav_menu('main-menu')){
							wp_nav_menu(array(
								'theme_location'=>'main-menu',
								'walker'=>new wp_bootstrap_navwalker(),
								'container_class'=>'collapse navbar-collapse',
								'container_id'=>'bs-example-navbar-collapse-1',
								'menu_class'=>'nav navbar-nav navbar-right'));
						}else{ ?>
							<p class="navbar-right"><b>
								<?php echo esc_html_e('Make your menu at Appearance => Menus ','larx'); ?>
							</b></p>
						<?php } ?>
                </div><!-- /.container-fluid -->
            </nav>
        </div>
    <?php
    }
}
?>