$(document).ready(function(){
	
	var uls = $('#rightcol .block-menu_block ul a');
	if(uls.length > 1){
		uls.not('.belgomenu-item').each(function(){ 
				$(this).click(function(){
					window.location=menu_block_parent_link;
				});		
			if($(this).attr('href') == null){
				//$(this).attr('href', menu_block_parent_link);//'/content/' + $(this).attr('class').replace('belgopocket ', ''));
			}
		});
	}
	
	if($('#rightcol .belgomenu-item.children').length > 3){
		$('#rightcol .block-block').remove();
		$('#rightcol .block-menu_block').addClass('block-block');
	}
	
	// fix conflict longdropdown
	/*
	var z = 0;
	$('.nice-menu-down ul').each(function(){
		var l = $(this).children().length,
			w = 250* (( l > 8 ) ? 3 : (l > 4 ? 2 : 1));
		$(this).css('width', w);
		
	});
	*/
	$('.nice-menu-down ul').bind('mousemove mouseover hover', function(e){
		var offset = $(this).offset(),
			width = $(this).width(),
			height = $(this).height(),
			num = $(this).children().length,
			pos = parseInt($(this).children(':first').css('top')),
			pos_last = $(this).children(':last').offset(),
			add = 0;
		
		if(pos*1 != pos){
			pos = 0;
		}
		
		if(e.pageY > offset.top && e.pageY < (offset.top + height)){
			add = e.pageY - offset.top - (height/2);
			if(((pos + add) <= 0 && add < 0) || (pos_last.top >= (height + offset.top - 30) && add > 0)){
				t = pos + add * -0.2;
				if(t > 0){
					t = 0;
				}
				
				$(this).children('li').css({
					top: t
					});
			}
		}
	});
	
	// breadcrumb Accueil moet naar taalpagina home
	$('.breadcrumb a:first').attr('href', home_link);
	// failsafe vertical align homepage
	var $home = $('.node-398 table');
	if($home){
		$home.css({
			position: 'relative',
			top: ($(window).height()-80-$home.height())/2
		});
	}
	
	// adresses utiles toevoegen aan dropdownmenu - enkel homepage
	if($home){
		var href_adress = $('#navlist li.last a').attr('href');
		if(href_adress){
			c = href_adress.replace('/content/', '').replace(/[^a-z]/g, '');
			$('#nice-menu-1, #nice-menu-2, #nice-menu-3').append('<li class="menuparent"><a class="belgopocket ' + c + '" href="' + href_adress + '">Adress</a></li>');
		}	
	}
	
	/*IE z-index BUG*/
	var zIndexNumber = 1000;
	$('ul, li').each(function() {
		$(this).css('z-index', zIndexNumber);
		zIndexNumber -= 10;
	});
	
	
});
