$(document).ready(function(){
		
		Cufon.replace('h1, h2, #route a');
		
		
		Cufon.replace('ul.images .naam h2', {
				textShadow: '#000 1px 1px'
			});
			
		$("a.fancy").fancybox();
		
		$("ul.navigation > li.active > ul").show();

		if($("ul.navigation > li > ul > li.active").hasClass('active'))
		{
			$("ul.navigation > li > ul > li.active").closest('ul').show();
			$("ul.navigation > li > ul > li.active").parent().parent().addClass('active current');
		}
		
		$("ul.navigation > li").hover(function(){
				var li = $(this);
				var parent = $(this).parent();
				var position = $(this).position();
			
				$(li).addClass('active');
				
				$(parent).animate({ 
					backgroundPosition: (position.left - 60) + 'px 29px' 
				}, { 
					queue: true, duration: 500, complete: function(){ 

					}
					});		
		}, function(){
			if($(this).hasClass('current') == false){
				$(this).removeClass('active');
			}else{
			
			}
		});
		
		$("ul.navigation > li:has(ul:hidden)").hover(function(){
				var li = $(this);
				var parent = $(this).parent();
				var position = $(this).position();
				
				$(parent).find('ul').hide();
				$(li).find('ul').animate({ height: 'toggle' },{queue:true, duration:200 });
		}, function(){
			//alert($("ul.navigation li.active").length);
			$('ul.navigation li').not('.current').find('ul').hide(function(){
				if($("ul.navigation > li.active").length == 1){
					$("ul.navigation > li.current > ul").show();
				}
			});
		});
		
		
				
});

$(window).load(function() {
	var total = $('#nivo img').length;
	var rand = Math.floor(Math.random()*total);

	$('#nivo').nivoSlider({
		directionNav:false,
		controlNav:false,
		startSlide:rand,
		effect: 'fade',
		customChange: function(){
			Cufon.replace('.nivo-caption', {
				textShadow: '#000 1px 1px'
			});
        }
	});
	
	
	
	stretch();
	
	$(window).resize(function() {
		stretch();
	});
	
});

function stretch()
{
	
/*
	var window_height = $(window).height(); 
	var container_height = $("#container").height();
	var fill = window_height - container_height;
	
	$("#container").css('min-height', container_height + fill);		
*/
}
