<?php
if ($fixTo) {
    ?>
    <script type="text/javascript">
        nextend.ready(
            function ($) {
                var topOffset = $('#wpadminbar:visible, .navbar-fixed-top:visible').height(),
                    topOffsetLightbox = 0;
                $('.<?php echo $snapClass; ?>').each(function () {
                    var bar = $(this);
                    bar.fixTo(bar.parent(), {
                        top: (bar.closest('.n2-lightbox').length > 0 ? topOffsetLightbox : topOffset)
                    });
                });
            }
        );
    </script>
    <?php
}
?>

<div class="n2-top-bar n2-sidebar-list-bg <?php echo $snapClass; ?>">
    <?php
    if ($back):
        ?>
        <div class="n2-back n2-top-bar-menu">
            <?php echo $back; ?>
        </div>
    <?php endif; ?>

    <?php
    if (!empty($menu)):
        ?>
        <div class="n2-top-bar-menu">
            <?php
            foreach ($menu AS $m):
                echo $m;
            endforeach;
            ?>
        </div>
        <?php
    endif;
    ?>

    <?php
    if (!empty($middle)):
        ?>
        <div class="n2-top-bar-middle"><?php echo $middle; ?></div>
        <?php
    endif;
    ?>

    <?php

    if ($notification) {
        array_unshift($actions, N2Html::tag('a', array(
            'class' => 'n2-button n2-button-icon n2-button-grey n2-button-blue-active n2-button-l n2-h3 n2-notification-button n2-radius-s n2-h32',
            'href'  => '#'
        ), N2Html::tag('i', array('class' => 'n2-i n2-it n2-i-32 n2-i-notification'))));
    }

    if ($expert) {
        array_unshift($actions, N2Html::tag('a', array(
            'class' => 'n2-expert-switch',
            'href'  => '#'
        ), N2Html::tag('span', array(
                'class' => 'n2-expert-expert n2-uc n2-h5'
            ), n2_('Expert')) . '<br>' . N2Html::tag('span', array(
                'class' => 'n2-expert-simple n2-uc n2-h5'
            ), n2_('Simple')) . N2Html::tag('div', array(
                'class' => 'n2-expert-bar'
            ), N2Html::tag('div', array(
                'class' => 'n2-expert-dot'
            ), ''))));
    }


    if (count($actions)):
        ?>
        <div class="n2-top-bar-actions">
            <?php
            foreach ($actions AS $action):
                echo $action;
            endforeach;
            ?>
        </div>
        <?php
    endif;
    ?>
</div>