<?php
    Mage::helper('custommenu')->saveCurrentCategoryIdToSession();
    $menuData = Mage::helper('custommenu')->getMenuData();
    extract($menuData);
    // ---
    $txtLoading = '';
    $txtMenu = $this->__('Menu');
    $xRtl = $_rtl ? ' rtl' : '';
    $wpInitContent = <<<HTML
    <div id="custommenu-loading" class="$xRtl">
        <div class="menu">
            <div class="parentMenu menu0">
                <a href="javascript:;">
                    <span>$txtLoading</span>
                </a>
            </div>
        </div>
        <div class="clearBoth"></div>
    </div>
    <div id="custommenu" class="$xRtl" style="display:none;">
        <div class="menu">
            <div class="parentMenu menu0">
                <a href="javascript:;">
                    <span>$txtLoading</span>
                </a>
            </div>
        </div>
        <div class="clearBoth"></div>
    </div>
    <div id="custommenu-mobile" class="$xRtl" style="display:none;">
        <div id="menu-button" onclick="wpMenuButtonToggle()">
            <a href="javascript:void(0);">
                <span>$txtMenu</span>
            </a>
        </div>
        <div id="menu-content" style="display:none;">
            <div id="menu-mobile-loading" class="menu-mobile level0">
                <div class="parentMenu">
                    <a href="javascript:;">
                        <span>$txtLoading</span>
                    </a>
                </div>
            </div>
            <div class="clearBoth"></div>
        </div>
    </div>
HTML;
?>
<div class="nav-container" id="wp-nav-container"></div>
<script type="text/javascript">
//<![CDATA[
var CUSTOMMENU_POPUP_WIDTH = <?php echo $_popupWidth; ?>;
var CUSTOMMENU_POPUP_TOP_OFFSET = <?php echo $_popupTopOffset; ?>;
var CUSTOMMENU_POPUP_DELAY_BEFORE_DISPLAYING = <?php echo $_popupDelayBeforeDisplaying; ?>;
var CUSTOMMENU_POPUP_DELAY_BEFORE_HIDING = <?php echo $_popupDelayBeforeHiding; ?>;
var CUSTOMMENU_RTL_MODE = <?php echo $_rtl; ?>;
var CUSTOMMENU_MOBILE_MENU_WIDTH_INIT = <?php echo $_mobileMenuWidthInit; ?>;
var wpCustommenuTimerShow = {};
var wpCustommenuTimerHide = {};
var wpActiveMenu = null;
var wpMobileMenuEnabled = <?php echo $_mobileMenuEnabled; ?>;
var wpMenuAjaxUrl = '<?php echo $_menuAjaxUrl; ?>';
var wpMoblieMenuAjaxUrl = '<?php echo $_moblieMenuAjaxUrl; ?>';
var wpPopupMenuContent = '';
var wpMobileMenuContent = '';
if ($('wp-nav-container') != undefined) {
    $('wp-nav-container').update(<?php echo Mage::helper('core')->jsonEncode($wpInitContent); ?>);
}
<?php if (Mage::getStoreConfig('custom_menu/general/ajax_load_content')) : ?>
wpCustomMenuMobileToggle();
Event.observe(window, 'resize', function() {
    wpCustomMenuMobileToggle();
});
<?php endif; ?>
//]]>
</script>

<script type="text/javascript">
//<![CDATA[
Event.observe(document, 'dom:loaded', function(){
    $$('.skip-nav').each(function(element) {
        element.observe('click', function(event) {
            wpMenuButtonToggle();
        });
    });
});
//]]>
</script>
