<?php 

/**
 * Foundation Setup
 */
if ( ! function_exists( 'culinary_enqueue_foundation' ) ) :

	function culinary_enqueue_foundation() {
		
		wp_enqueue_script( 'culinary-foundation', get_template_directory_uri() . '/js/foundation/foundation.min.js', array( 'jquery' ), '6.2.2', true );		
		wp_enqueue_script( 'culinary-init', get_template_directory_uri() . '/js/scripts.js', array( 'jquery', 'culinary-foundation' ), '1.0', true );

	}

endif; // culinary_enqueue_foundation
add_action( 'wp_enqueue_scripts', 'culinary_enqueue_foundation', 10 );

/**
 * Foundation Main Navigation
 *
 */
class Culinary_Main_Topbar_Menu_Walker extends Walker_Nav_Menu {   
    /*
     * Add vertical menu class and submenu data attribute to sub menus
     */
     
     function display_element($element, &$children_elements, $max_depth, $depth=0, $args, &$output) {
        $element->has_children = !empty($children_elements[$element->ID]);
        $element->classes[] = ($element->current || $element->current_item_ancestor) ? 'active' : '';
        $element->classes[] = ($element->has_children) ? 'has-dropdown' : '';
 
        parent::display_element($element, $children_elements, $max_depth, $depth, $args, $output);
    }


    function start_lvl( &$output, $depth = 0, $args = array() ) {
        $indent = str_repeat("\t", $depth);
        $output .= "\n$indent<ul class=\"dropdown vertical menu submenu\" >\n";
    }
}

