$(document).ready(function(){
			$(".cpb_content.laatste:empty").hide().prev().addClass("breed");
			$(".cpb_content.eerste:empty").hide().next().addClass("breed");
			$(".cpb_content ul li:odd").addClass("geen_achtergrondkleur");
			$("#publicaties ul li:odd").addClass("geen_achtergrondkleur");
			$("#container:has('#CCIPlaceHolder_Rechterkant:empty')").addClass("geen_rechterkant");
			$(".onderschrift:empty").parent().addClass("geen_onderschrift");
			$(".onderschrift:empty").remove();
			$(".tekst:empty").remove();
			$("#gekleurd_vlak h3:empty").remove();
			$("#gekleurd_vlak .tekst:empty").remove();
			$("#gekleurd_vlak:empty").parent().parent().parent().parent().removeClass("gekleurd_vlak");
			$("#gekleurd_vlak:empty").prev().removeClass("linkerkant");
			$(".rij .blokje h3:empty").remove();
			$(".rij .blokje .content:empty").remove();
			$(".rij .blokje:empty").css("border", "none");
			$("#gekleurd_vlak:empty").remove();
			$(".formbuilder_formpanel input:radio").addClass("noBorder");
			$(".formbuilder_formpanel input:checkbox").addClass("noBorder");
			$(".formbuilder_errormessagepanel, .formbuilder_errormessagemarker").css("color", "#5B5B5B");
			$(".afbeelding:empty").remove();
			$(".tekst:empty").remove();
});

$(function()
{

	if (document.body.id == 'homepage')
	{
		initShowCase();
		setShowFadeEventHandlers("#showCase");
	}
	
	/* Zoekformulier */
$('.zoekknop').click(function() {
	searchSubmit($(this));
	return false;
});
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 > 1) {
		$("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;
				}
			}
		);
	$(this).focus(
			function() {
				this.value = '';
				//				this.className = 'zoekveld';
			}
		);
	$(this).blur(
			function() {
				if (this.value == '') {
					this.value = 'doorzoek de website'; /* zorgt ervoor dat wanneer iemand uit het zoekveld gaat, de waarde weer terug komt */
					//					this.className = 'zoekveld';
				}
			}
		)
}
	)
});

var initShowCase = function()
{
	var current = $("#showCase .case:first");
	current.find(".item").css("opacity","1")
	$("#showCase .case").each(
		function()
		{
			$(this).hover(
				function()
				{
					current.removeClass("aktief");
					current = $(this);
					$(this).addClass("aktief");
				},
				function() { }
			)
			$(this).click(
				function()
				{
					window.location = $(this).find("a")[0].href;
					return false;
				}
			);
		}
	);
}

function setShowFadeEventHandlers(containerExpression)
{
	// Fade alle contentgebieden instant uit en verwijder alle active classes
	$(containerExpression+" .item").fadeOut(0);
	$(containerExpression+" .item").removeClass("active");
	$(containerExpression+" .case").removeClass("active");
	
	// Fade content 1 in en voeg een class active toe
	$(containerExpression+" .item:eq(0)").fadeIn(0);
	$(containerExpression+" .item:eq(0)").addClass("active");
	$(containerExpression+" .case:eq(0)").addClass("active");
	
	// Voeg hover event handlers toe aan de navigaties
	$(containerExpression+" .case").each(function()
	{
		$(this).hover(function()
		{
			// Controleer of de betreffende content al is ingefade, zo niet ga verder
			if (!$(this).next(".item:eq(0)").hasClass("active"))
			{
				// Breng alle lopende animaties op de content elementen instant naar hun eindpositie
				$(containerExpression+" .item").stop(true,true);
				
				// Fade alle contentgebieden uit en verwijder alle active classes
				$(containerExpression+" .item").fadeOut(0);
				$(containerExpression+" .item").removeClass("active");
				$(containerExpression+" .case").removeClass("active");
				
				// Fade de betreffende content in en voeg een class active toe
				$(this).next(".item:eq(0)").fadeIn(0);
				$(this).next(".item:eq(0)").addClass("active");
				$(this).addClass("active");
			}
		});
	});
}


var addEvent = function(obj, type, fn) {
	if (obj.addEventListener)
		obj.addEventListener(type, fn, false);
	else if (obj.attachEvent)
		obj.attachEvent('on' + type, function() { return fn.apply(obj, new Array(window.event)); });
}

var website = function() {
	{	// Private functions
		var initOnLoad;

		showGotoMyProfile = function(id) {
			if (!document.getElementById(id))
				return;
			var el = document.getElementById(id);
			el.innerHTML = '<a id="text_loggedin_vervanging" href="\/cms\/showpage.aspx?id=102">Naar het ledennet</a>';
			el.style.visibility = "visible";
		}

		initOnLoad = function() {
			showGotoMyProfile('text_loggedin');
		}
	}
	{	// Public functions
		return ({
			onLoad: function() {
				addEvent(window, "load", initOnLoad);
			}
			,
			submitFormToSendmail: function(fn) {
				var submitFormHasErrors = false;
				if (typeof fn == 'function') {
					submitFormHasErrors = fn();
				}
				if (submitFormHasErrors == false) {
				}
			}
		});
	}
} ();
website.onLoad();