(function( win, $, undefined){
	
	var breakpoint 	  = 470,
		smallSize     = false,
		mainNav       = $('#main-nav > .nav'),
		headerNav     = $('#header .nav');
		
		function adapt()
		{
			if ( $(win).width() < breakpoint && ! smallSize ) {

				smallSize = true;

				mainNav.append(headerNav.find('li:not(:first)').clone().each(function(){
					$(this).addClass('cloned');
				}));

				headerNav.hide();

			} else if ( $(win).width() > breakpoint && smallSize ) {

				smallSize = false;

				mainNav.find('.cloned').remove();
				headerNav.show();
			}
		}
		
		$(win).resize(adapt);
		
		adapt();
		
		mainNav.mobileMenu({
			switchWidth: breakpoint,
			topOptionText: 'Jump to section:'
		});
	
})( this, jQuery );
