 jQuery(function(){
	var body = $('body'),
		menuTrigger = $('.menu-trigger'),
		subnavs = $('.sub-nav-wrap');

	menuTrigger.on('click', function(e) {
		e.preventDefault();
		body.toggleClass('menu-open');
	});

	subnavs.each(function() {
		var trigger = $(this).find('.sub-nav-trigger'),
			subnav = $(this).find('.sub-nav');
		trigger.on('click', function() {
			$('.sub-nav-wrap .sub-nav').not(subnav).slideUp('fast');
			subnav.slideToggle('fast');
		});

		$(document).bind('click', function (e) {
			if (!$('.main-nav').is(e.target) && $('.main-nav').has(e.target).length === 0) {
				subnav.slideUp('fast');
			}
		});
	});

	/* lng switch */
	$('.lang').on('click', function(e) {
		e.preventDefault();
		var langsList = $('#langs');
		if(langsList.length > 0) {
			langsList.toggleClass('langs-open');

			$(document).bind('click', function (e) {
				if (!$('.lang-switch').is(e.target) && $('.lang-switch').has(e.target).length === 0) {
					langsList.removeClass('langs-open');
				}
			});
		}
	});
 });