/**
 * Simple script to merge two menus
 */
jQuery(document).ready(function($) {
	/** Combine menus */
	setupMenus();
	$( window ).resize( function() {
		setupMenus();
	});
	function setupMenus () {
		if ( window.innerWidth <= 768 ) {
			$( 'ul#topnav-menu > li' ).addClass('moved-item'); //tag moved items so we can move them back
			$( 'ul#topnav-menu > li' ).appendTo( 'ul#menu-main,ul#menu-main-menu' );
			$( '#topheader' ).hide();
		}
		if ( window.innerWidth > 768 ) {
			$( '.main-navigation ul#menu-main,.main-navigation ul#menu-main-menu, nav .sub-menu' ).removeAttr( 'style' );
			$( '.nav-menu > .menu-item' ).removeClass( 'menu-open' );
			$( '#topheader' ).show();
			$( 'ul#menu-main > li.moved-item,ul#menu-main-menu > li.moved-item' ).appendTo( 'ul#topnav-menu' );
		}
	}
});