<?php global $smof_data, $header_setings, $post;
    $c_pageID = null;
    if($post){
        $c_pageID = $post->ID;
    }
    /* object menu */
    $menus = wp_get_nav_menus();
    /* array menu id */
    $menus_id = array();
    if(!empty($menus)){
        foreach ($menus as $menu){
            $menus_id[] = $menu->term_id;
        }
    }
    /* menu location */
    $menu_locations = get_nav_menu_locations();
    $main_navigation = null;
    if(!empty($menu_locations['main_navigation'])){
        $main_navigation = $menu_locations['main_navigation'];
    }
    /** menu siderbar */
    $logo_col = 'col-xs-12 col-sm-12 col-md-3 col-lg-3';
    $sidebar_col = '';
    if (is_active_sidebar( 'cshero-menu-sidebar' )){
        $logo_col = 'col-xs-12 col-sm-12 col-md-2 col-lg-2';
        $sidebar_col = 'col-xs-12 col-sm-1 col-md-1 col-lg-1';
    }
?>

<div class="header header-v1<?php if($smof_data['logo_alignment'] == 'left'){echo ' cshero-logo-left';}?> <?php if($smof_data['logo_alignment'] == 'right'){echo ' cshero-logo-right';}?>">
    <?php echo do_shortcode('[rev_slider alias="'.$smof_data['cs-header-revsliders'].'"]');?>
    <header id="cshero-header" class="<?php if($header_setings->header_fixed == '1'){ echo ' transparentFixed';} ?>" <?php echo $header_setings->styles; ?>>
        <div class="container">
            <div class="row">
                <div class="logo <?php echo $logo_col; ?>">
                    <a href="<?php echo esc_url(home_url()); ?>" style="margin:<?php echo esc_attr($smof_data['margin_logo']); ?>;">
                        <img src="<?php echo esc_url($smof_data['logo']); ?>" alt="<?php esc_attr(bloginfo('name')); ?>" class="normal-logo logo-v1"/>
                    </a>
                </div>
                <div id="menu" class="cs_mega_menu main-menu col-xs-9 col-sm-9 col-md-9 col-lg-9 cs_menu_position_<?php echo $smof_data["menu_position"]; ?>">
                    <div class="main-menu-content cshero-menu-dropdown clearfix nav-menu cshero-mobile">
                    <?php
                        $custom_main_navigation = get_post_meta($c_pageID, 'cs_main_navigation', true);
                        if (in_array($main_navigation, $menus_id) || in_array($custom_main_navigation, $menus_id)) {
                            echo '<ul class="cshero-dropdown main-menu">';
                            wp_nav_menu(array('theme_location' => 'main_navigation','menu'=>$custom_main_navigation, 'depth' => 5, 'container' => false, 'menu_id' => 'nav', 'items_wrap' => '%3$s', 'walker'=>new HeroMenuWalker()));
                            if(isset($smof_data['enable_hidden_sidebar']) && $smof_data['enable_hidden_sidebar']){
                            ?>
                                <li class="menu-item menu-item-open hidden-xs hidden-sm">
                                    <a href="#"><i class="fa fa-navicon cs_open"></i></a>
                                </li>
                            <?php
                            }
                            echo '</ul>';
                        } elseif (empty($menus_id)) {
                             echo '<div class="menu-pages">';
                             wp_nav_menu(array('depth' => 5, 'container' => false, 'menu_id' => 'nav', 'items_wrap' => '%3$s'));
                             echo '</div>';
                        } else {
                             echo '<ul class="cshero-dropdown main-menu">';
                             wp_nav_menu(array('depth' => 5, 'container' => false, 'menu_id' => 'nav', 'items_wrap' => '%3$s', 'walker'=>new HeroMenuWalker()));
                             echo '</ul>';
                        }
                    ?>
                    </div>
                </div>
                <?php if (is_active_sidebar( 'cshero-menu-sidebar' )): ?>
                <div class='menu-widget <?php echo $sidebar_col; ?>'>
                    <?php  dynamic_sidebar("Menu Sidebar"); ?>
                </div>
                <?php endif; ?>
                <button type="button" class="btn-navbar navbar-toggle" data-toggle="collapse" data-target="#cshero-main-menu-mobile"><i class="fa fa-align-justify"></i></button>
                <div id="cshero-main-menu-mobile" class="collapse navbar-collapse cshero-mmenu"></div>
            </div>
        </div>
    </header>
</div>
<?php get_template_part('framework/headers/sticky-header'); ?>