var CND = {

	slug2item: {
		'cursus_details': 'opleidingen',
		'product_details': 'producten',
		'stijl_details': 'style'
	},
	
	init: function () {
		$('#directProduct').css('display', 'block');
		$('#directProduct').change(function (){
			window.location.href = $('#directProduct').val();
		});
		$('a.blank').attr('target', 'blank');
		CND.pathVars();
		CND.menu();
	},
	
	menu: function () {
		var slug = CND.pathVars()[1];
		var rootitem = '#a-random-tekst';
		if (CND.slug2item[slug]){
			rootitem = '#menu-' + CND.slug2item[slug];
		}
		$('.nav-level2').each(function (i) {
			if ($('.current', this).length < 1 && $(rootitem, this.parentNode).length < 1) {
				$(this).css('display', 'none');
			}
		});
		$('.nav-level3').each(function (i) {
			if ($('.current', this.parentNode).length < 1 && $(rootitem, this.parentNode).length < 1) {
				$(this).css('display', 'none');
			}
		});
		$('.level1').each(function (i) {
			var ul = $('.nav-level2', this).eq(0)
			$('a', this).eq(0).click(function () {
				$('.openLevel1').slideUp('normal');
				if (ul.css('display') == 'none') {
					ul.addClass('openLevel1');
					ul.slideDown('normal');
				}
				return false;
			});
		});
	},
	
	pathVars: function () {
		var vars = location.pathname.split('/');
		vars[0] = location.pathname;
		return vars;
	}
	
}

$(CND.init);
