$(function()
{
	if (window.initGallery) { initGallery() }
	
	$('.zoekknop').click(function() {
		searchSubmit($(this));
		return false;
	});
	$(".themaBlok span:empty").remove();
	$(".themaBlok:empty").remove();
	
	$(".afbeeldingKolom span:empty").remove();
	$(".afbeeldingKolom .afb:empty").remove();
	$(".afbeeldingKolom:empty").parent().parent().addClass("smal");
	$(".afbeeldingKolom:empty").remove();
	
	

	var searchSubmit = function(sNode) {
		var theForm = $(sNode).parent();

		var searchInputText = $(theForm).find('input:text');
		
		var searchInputHidden = $(theForm).find('input:hidden');
		searchTerm = encodeURIComponent(searchInputText.val());
		
		if (searchTerm.length > 2) {
			$("form").submit(function() { return false });
			var searchUrl = searchInputHidden.val();
			searchUrl += searchTerm;
			window.location = searchUrl;
		} else {
			alert('Vul minstens twee tekens in om te zoeken.');
			return false;
		}
	}

	$(".zoek input:text").each(function() {
		$(this).keydown(
			function(e) {
				if (e.keyCode == 13) {
					searchSubmit($(this));
					return false;
				}
			}
		);
	});

	$("form").addClass(	$("#subnavigatie > li.aktief").attr("class")).removeClass("aktief");
	$(".afbeeldingKolom .afb").each(
		function()
		{
			if ($(this).find("img").length == 0) {
				$(this).css("display","none");
			
			}
		}
	
	);

	$(".expand").click(function()
	{
		$(this).parent().parent().parent().find(".content").slideDown();
		return false;
	});
	$(".contract").click(function()
	{
		$(this).parent().parent().parent().find(".content").slideUp();
		return false;
	});
});
