// form-value
	jQuery.fn.toggleVal = function(focusClass) {
		this.each(function() {
			$(this).focus(function() {
				// clear value if current value is the default
				if($(this).val() == this.defaultValue) { $(this).val(""); }
				
				// if focusClass is set, add the class
				if(focusClass) { $(this).addClass(focusClass); }
			}).blur(function() {
				// restore to the default value if current value is empty
				if($(this).val() == "") { $(this).val(this.defaultValue); }
				
				// if focusClass is set, remove class
				if(focusClass) { $(this).removeClass(focusClass); }
			});
		});
	}
// center align image in maskdiv
	$.fn.centerAlignMask = function() {
		return this.each(function() {
			var maskedH = $(this).children().height(),
				maskedW = $(this).children().width(),
				maskH = $(this).height(),
				maskW = $(this).width(),
				marginT = Math.floor((maskH-maskedH)/2),
				marginL = Math.floor((maskW-maskedW)/2);

			$(this).children().css({'margin-top':marginT, 'margin-left':marginL});

			return false;
		});
	};

	$(document).ready(function(){
// png voor IE ------------------------------------------------------------------------------------------
		$('body').pngFix();
// dotted linkline ---------------------------------------------------------------------------------------
		$('a').focus(function() {this.blur();});
// formval joe! ------------------------------------------------------------------------------------------
		$('#we_subscribe_email__').toggleVal();
		$('#email,#firstname,#lastname').toggleVal();
// tooltip ------------------------------------------------------------------------------------------
		$('.bg-image-wrap,#logo,#navigation_left a,#navigation_right a').tooltip({opacity: 1, track: true, delay: 0, showURL: false, fade: 150});
// Afmelden verbergen ---------------------------------------------------------------------------------
		$('.alle li a[href~="/bureau/Afmelden.php"]').parent('li').css({'display':'none'});
		$('.alle li a[href~="/bureau/Afmelden.php?english"]').parent('li').css({'display':'none'});
		$('.alle li a[href~="/bureau/Afmelden_EN.php"]').parent('li').css({'display':'none'});
		$('.alle li a[href~="/bureau/Afmelden_EN.php?english"]').parent('li').css({'display':'none'});
		$('.alle li a[href~="/bureau/Afmelden_pers.php"]').parent('li').css({'display':'none'});
		$('.alle li a[href~="/bureau/Afmelden_pers.php?english"]').parent('li').css({'display':'none'});
		$('.alle li a[href~="/bureau/Afmelden_pers_EN.php"]').parent('li').css({'display':'none'});
		$('.alle li a[href~="/bureau/Afmelden_pers_EN.php?english"]').parent('li').css({'display':'none'});
		//$('.alle li a').attr('href','33')
// zoek --------------------------------------------------------------------------------------------------
		$('input[type="text"]').addClass("idleField");
		$('input[type="text"]').focus(function() {
			$(this).removeClass("idleField").addClass("focusField");
		});
		$('input[type="text"]').blur(function() {
			$(this).removeClass("focusField").addClass("idleField");
		});
// external links
		$('a[href^=http], a[href*=.jpg], a[href*=.pdf]').attr('target', '_blank');

// menulisthover -------------------------------------------------------------------------------------------
		$('#nav ul ul li:not(.cat_title)').hover(function(){
			$(this).find('span:eq(0)').not('.afbeelding_thumb').stop().animate({'marginLeft':15},100);
			$(this).find('span:eq(1)').stop().animate({'marginLeft':15},200);
			$(this).find('span:eq(2)').stop().animate({'marginLeft':15},300);
			$(this).find('span:eq(3)').stop().animate({'marginLeft':15},400);
		}, function(){
			$(this).find('span:eq(0)').not('.afbeelding_thumb').stop().animate({'marginLeft':10},100);
			$(this).find('span:eq(1)').stop().animate({'marginLeft':10},200);
			$(this).find('span:eq(2)').stop().animate({'marginLeft':10},300);
			$(this).find('span:eq(3)').stop().animate({'marginLeft':10},400);
		});
		$('#nav ul ul li').hover(function(){
			$(this).children('span').stop().animate({'padding-left':5},200);
		}, function(){
			$(this).children('span').stop().animate({'padding-left':0},200);
		});
// center align thumbs -------------------------------------------------------------------------------
$('.afbeelding_thumb').centerAlignMask();
// scroll init -------------------------------------------------------------------------------------------
		var liL = $('ul.alle li').length;
		$('.alle').css({'height':$(this).height(), 'width':425});

		var boxH = $(window).height()-200;
		var titelHeight = 18;
		var titelHeight = parseInt(($('strong.titel').height())/3)+10;
		var titelNetto = titelHeight - 18;
		var dezeHeight = parseInt($('.deze').outerHeight());
		if(($('.cat_title').size() != 0 )){
			$('#nav ul ul li.cat_title').each(function(){
				var catitems = parseInt($(this).children('ul').children('li').size());
				if(catitems != 0){
					$(this).css('cursor', 'pointer').children('ul').css({'height':0, 'overflow':'hidden'});;
				}
			});
		}
			$('.alle, .deze').delay(180).jScrollPane();
			$('.afbeelding_thumb').centerAlignMask();
			
			$('.jScrollPaneContainer').delay(200).css({'height':boxH-33-titelNetto,'display':'none', 'width':425});


// cattitle_list click -------------------------------------------------------------------------------------------

		$('#nav ul ul li.cat_title span').live('click', function(){
			var catitems = parseInt($(this).parent('.cat_title').children('ul').children('li').size());
			var catLi = parseInt($(this).parent('.cat_title').children('ul').height());
			var cattext = $(this).html();
			if((catitems != 0)&&(catLi == 0)){
				$('.jScrollPaneContainer').css({'height':(boxH-33)});
				$('.alle').animate({'height':catitems*54},300,function(){
					$('.alle').jScrollPane();
					$('.afbeelding_thumb').centerAlignMask();
				});
				$(this).parent('.cat_title').addClass('cat_open').children('ul').animate({'height':catitems*54},200);
			}
			if((catitems != 0)&&(catLi != 0)){
				$('.jScrollPaneContainer').css({'height':(boxH-33)});
				$('.alle').animate({'height':boxH-33},300,function(){
					$('.alle').jScrollPane();
					$('.afbeelding_thumb').centerAlignMask();
				});
				$(this).parent('.cat_title').removeClass('cat_open').children('ul').animate({'height':0},200);
			}
		});

// openblijven? -------------------------------------------------------------------------------------------
			if($('#nav').find('li.openblijven').size() != 0){
				$('.deze').parent().css({'display':'block'});
				$('.titel, .greater,.leesminder').show();
				$('.leesmeer').hide();
				$('li.third').animate({'height':boxH, 'top':'-'+(boxH-18)+'px'}, 250);
				$('li.third > a').addClass('menuclosed');
				$('li.third > a').removeClass('menuopen');
			}

// li.third click
		$('.menuclosed').click(function(){
			if($('li.third').width() < 84){
				$('#nav > ul').stop().animate({'width':870}, 250);
				$('li.third > a').css({'float':'left'});
				$('#nav li.fourth').stop().animate({'left':661}, 250);
				$('#nav li.fifth').stop().animate({'left':764}, 250);
				$('li.third').animate({'width':415}, 250, function(){
					if($('li.third').height() < boxH){
						$('.alle').parent().css({'display':'block'});
					$('.afbeelding_thumb').centerAlignMask();
						$('.leesmeer').hide();
						$('.leesminder').show();
						$('li.third').animate({'height':boxH, 'top':'-'+(boxH-18)+'px'}, 250);
						$(this).find('a:first').addClass('menuopen');
						$(this).find('a:first').removeClass('menuclosed');
					}else{
						if($('.deze').parent().is(':visible')){
							$('.alle').parent().css({'display':'block'});
					$('.afbeelding_thumb').centerAlignMask();
							$('.deze').parent().css({'display':'none'});
							$('.video').css({'display':'none'});
							$('.titel, .greater').hide();
							$(this).addClass('menuopen');
							$(this).removeClass('menuclosed');
						} else {
							$('li.third').animate({'height':18, 'top':0}, 250,
								function(){
									$('.alle').parent().css({'display':'none'});
									$('.titel, .greater, .leesmeer').show();
									$('.leesminder').hide();
								});
							$(this).addClass('menuclosed');
							$(this).removeClass('menuopen');
						}
					}
				});
			} else {
				if($('li.third').height() < boxH){
					$('.alle').parent().css({'display':'block'});
					$('.afbeelding_thumb').centerAlignMask();
					$('.titel, .greater, .leesmeer').hide();
					$('.leesminder').show();
					$('li.third').animate({'height':boxH, 'top':'-'+(boxH-18)+'px'}, 250);
					$(this).addClass('menuopen');
					$(this).removeClass('menuclosed');
				}else {
					if($('.deze').parent().is(':visible')){
						$('.alle').parent().css({'display':'block'});
					$('.afbeelding_thumb').centerAlignMask();
						$('.deze').parent().css({'display':'none'});
						$('.video').css({'display':'none'});
						$('.titel, .greater').hide();
						$(this).addClass('menuopen');
						$(this).removeClass('menuclosed');
					} else {
						$('li.third').animate({'height':18, 'top':0}, 250,
							function(){
								$('.alle').parent().css({'display':'none'});
								$('.titel, .greater, .leesmeer').show();
								$('.leesminder').hide();
						if($('#nav ul').find('li.thispage').size() == 0){
							$('li.third > a').css({'float':'none'});
							$('li.third').animate({width:83},250);
							$('#nav > ul').stop().animate({'width':515}, 250);
							$('#nav li.fourth').stop().animate({'left':309}, 250);
							$('#nav li.fifth').stop().animate({'left':412}, 250);
						}
							});
						$(this).addClass('menuclosed');
						$(this).removeClass('menuopen');
					}
				};
			}
			return false;
		});

// li third li a click
		$('.third li a').each(function(){
			var deLink = $(this).attr('href');
			$(this).attr({'rel': deLink, 'href': '#'});
		});
		$('.third li a').click(function(){
			var nuLink = $(this).attr('rel');
			$('li.third').animate({'height':18, 'top':0}, 250,
				function(){
					window.location=nuLink;
				});
			return false;
		});

// andere #nav li click
		$('li.first > a, li.second > a, li.fourth > a, li.fifth > a').each(function(){
			var menuLink = $(this).attr('href');
			$(this).attr({'rel': menuLink, 'href': '#'});
		});
		$('li.first > a, li.second > a, li.fourth > a, li.fifth > a').click(function(){
			var nuLink = $(this).attr('rel');
			$('.leesminder, .leesmeer').css('display','none');
			$('li.third').animate({'height':18, 'top':0}, 250,
				function(){
				$('li.third > a').css({'float':'none'});
				$('li.third').animate({width:63}, { duration: 250});
				$('#nav > ul').stop().animate({'width':515}, 250);
				$('#nav li.fourth').stop().animate({'left':309}, 250);
				$('#nav li.fifth').stop().animate({'left':412}, 250,
					function(){
						window.location=nuLink;
					
					});
				});
			return false;
		});

// leesmeer click
		$('.leesmeer').click(function(){
			$('.deze').parent().css({'display':'block'});
			if($('.deze').size() == 0){
				$('.alle').parent().css({'display':'block'});
				$('li.third > a').addClass('menuopen');
				$('li.third > a').removeClass('menuclosed');
			}
			$('li.third').animate({'height':boxH, 'top':'-'+(boxH-18)+'px'}, 250,
				function(){
					$('.deze').css({'width':425});
				});
			$('.leesminder').show();
			$('.leesmeer').hide();
			return false;
		});

// lees minder "X"click
		$('.leesminder').click(function(){
			$('li.third').animate({'height':18, 'top':0}, 250,
				function(){
					$('.deze, .alle').parent().css({'display':'none'});
					$('.titel, .greater, .leesmeer').show();
					$('.leesminder').hide();
					$('li.third > a').addClass('menuclosed');
					$('li.third > a').removeClass('menuopen');
				});
			return false;
		});

		if($('.bg-image-wrap').find('img').size() < 2){
			$('#navigation_left, #navigation_right').css('display', 'none');
		};

if($("embed").size() == 1){
var $vidPlayer = $("embed");
} else {
var $vidPlayer = $("object");
}
var playerWidth = $(".video").width();

$vidPlayer.each(function(){
    var $this = $(this);
    var aspect = $this.attr("height") / $this.attr("width");

    $(window).resize(function() {
          $this.width(playerWidth).height(playerWidth * aspect);
          $("object").width(playerWidth).height(playerWidth * aspect);
    }).trigger("resize");
});

	});

