window.addEvents({
	'domready': function() {
		initExternalLinks();
		componentPaginatorAlignment();
		f4_textResizing();
		f5_searchFieldFocus();
		f6_loadFlashPresentation();
		f10_slideShow();
		f10_slideTextLimiter(145);
		f14_mainNavDropDown();
		f15_departmentNav();
		f19_searchResultsAccordion();
		f20_searchResultsPerTypeFixes();
		f22_searchResultsLawyerFixes();
		f24_accordionList();
		f28_alsoseeListFixes();
		f31_ratingSelector();
		f33_columnsListFixes();
		f36_lightboxLoginToggle();
		f38_lightboxVideoPlayer();
		f39_lightboxVideoPlayer();
		f40_downloadLegalDocuments();
		f43_lightboxVideoPlayer();
		f45_downloadLegalDocuments();
		f46_advancedSearchResultsLawyerFixes();
		lightBoxSubmitPageRefresh();
		lightBoxDownloadPageRefresh();
		initFF2Fixes();
		jsBox();
		
		/* development domready functions */
		//catchFormSubmit();
		catchLogout();
	},
	'load': function() {
		distributeListAmongMultipleColumns($(document.body).getElement('.f43_videos_overview'));
		if (Browser.Engine.trident && $$('.f43_videos_overview').length != 0) $$('.f43_videos_overview')[0].setStyle('margin-left', 0);
		distributeListAmongMultipleColumns($(document.body).getElement('.f44_articles_overview'));
		distributeListAmongMultipleColumns($(document.body).getElement('.f45_documents_overview'));
		alignListRowHeight($(document.body).getElement('.f37_jurisdiction_nav'));
		alignByEqualHeight($$('.f37_jurisdiction_nav', '.f42_infobox'));
		Shadowbox.init();
	}
});



/**
 * initExternalLinks
 * Used in order for certain links to open in a new window without the direct target attribute (so it validates properly).
 * 
 * @author CSD (clientsidedevelopers[AT]efocus.nl)
 * @uses <a href="http://www.efocus.nl/" rel="external">eFocus site</a>
 */
function initExternalLinks() {
	if (!document.getElementsByTagName) return; 
	var arrAnchors = document.getElementsByTagName("a"); 
	for (var i=0; i<arrAnchors.length; i++) { 
		var elAnchor = arrAnchors[i]; 
		if (elAnchor.getAttribute("href") && elAnchor.getAttribute("rel") == "external") {
			elAnchor.target = "_blank";
		}
	}
}

/**
 * unescapeAmp
 * Unescapes escaped ampersands
 */
function unescapeAmp(url) {
	return url.replace(/&amp;/g, '&');
}

/**
 * replaceHeadFonts
 * replaces the font of some heads by a sIFR variant
 *
 * @author Ralph Meeuws (ralph.meeuws[AT]efocus.nl)
 * @return void
 */
function replaceHeadFonts() {
	var objSifrDaxCompact = {
		src: '/swf/sifr_dax_compact.swf'
		,ratios: [8,1.43,11,1.38,16,1.33,23,1.32,27,1.31,28,1.3,31,1.29,34,1.3,39,1.28,40,1.29,52,1.28,55,1.27,56,1.28,89,1.27,91,1.26,92,1.27,95,1.26,96,1.27,1.26]
	};
	
	sIFR.useStyleCheck = true;
	sIFR.fitExactly = true;
	sIFR.activate(objSifrDaxCompact);
	
	sIFR.replace(objSifrDaxCompact, {
		selector: 'label.searchbox_label'
		,css: {
			'.sIFR-root': { 'background-color': '#000000', 'font-size': '26px', 'color': '#ffffff' }
		}
		,wmode: 'transparent'
	});

	sIFR.replace(objSifrDaxCompact, {
		selector: 'h2.head_white'
		,css: {
			'.sIFR-root': { 'background-color': '#00ccff', 'color': '#ffffff' }
		}
		,wmode: 'transparent'
	});

	sIFR.replace(objSifrDaxCompact, {
		selector: '.f40_legal_documents h2, .f42_infobox h2, .f43_video_overview h2, .f44_subject_overview h2, .f45_legal_documents h2'
		,css: {
			'.sIFR-root': { 'background-color': '#ffffff', 'color': '#000000', 'font-size': '18px', 'width' : 'auto' }
		}
		,wmode: 'transparent'
	});
	
	sIFR.replace(objSifrDaxCompact, {
		selector: '.col_left h2, .col_middle h2, .col_right h2, .col_left_middle h2, .col_middle_right h2, h2.use_sifr, .f35_form legend'
		,css: {
			'.sIFR-root': { 'background-color': '#ffffff', 'color': '#000000', 'font-size': '21px', 'width' : 'auto' }
		}
		,wmode: 'transparent'
	});
	
	sIFR.replace(objSifrDaxCompact, {
		selector: '.f14_department_choice h2'
		,css: {
			'.sIFR-root': { 'background-color': '#ffffff', 'color': '#000000', 'font-size': '21px', 'width' : 'auto' }
		}
		,wmode: 'transparent'
	});
	
	if ($$('div.f14_department_choice h2')[0]) {
		$$('div.f14_department_choice h2')[0].setStyle('width', $$('div.f14_department_choice h2')[0].getSize().x);
	}
	
	sIFR.replace(objSifrDaxCompact, {
		selector: '.f19_searchresults_list h3, .f20_searchresults_per_type h3, .f22_searchresults_lawyers h3, .f46_advanced_searchresults_lawyers h3'
		,css: {
			'.sIFR-root': { 'background-color': '#ffffff', 'font-size': '21px', 'color': '#000000' }
		}
		,wmode: 'transparent'
	});

	sIFR.replace(objSifrDaxCompact, {
		selector: '.f10_current_subject h3 a'
		,css: {
			'.sIFR-root': { 'background-color': '#ffffff', 'font-size': '21px', 'color': '#000000' }
		}
		,wmode: 'transparent'
	});

	sIFR.replace(objSifrDaxCompact, {
		selector: '.f41_legal_professionals h2'
		,css: {
			'.sIFR-root': { 'background-color': '#ffffff', 'color': '#000000', 'text-align': 'right', 'font-size': '18px', 'width' : 'auto' }
		}
		,wmode: 'transparent'
	});
}



/**
 * componentPaginatorAlignment
 * Centers the paginator.
 *
 * @author Ralph Meeuws (ralph.meeuws[AT]efocus.nl)
 * @return void
 */
function componentPaginatorAlignment(){
	arrPaginator = $$('.component_paginator');
	if (arrPaginator.length == 0) return;
	
	// Don't center the paginator within these functional blocks:
	if ($$('.f10_current_subject').length != 0) {
		return;
	} else {
		// Center the paginator:
		elSrptPag = $$('.paginator')[0];
		elSrptPagWidth = elSrptPag.getSize().x;
		
		elSrptPag.setStyles({
			'position': 'relative',
			'left': '50%',
			'margin-left': -(elSrptPagWidth / 2)
		});
	}
}




/**
 * f3_breadcrumbWidth
 * Resizes the base font size when switching between the resize links.
 *
 * @author Ralph Meeuws (ralph.meeuws[AT]efocus.nl)
 * @return void
 */
function f3_breadcrumbWidth(){
	arrF3 = $$('.f3_breadcrumbpath');
	if (arrF3.length == 0) return;
	
	var elBreadcrumbList = arrF3[0];
	var arrBreadcrumbListitems = elBreadcrumbList.getElements('li');
	var strBreadcrumbWidth = 0;
	
	arrBreadcrumbListitems.each(function(elBreadcrumbListitem){
		strBreadcrumbWidth += (elBreadcrumbListitem.getSize().x + 1);
	});
	
	elBreadcrumbList.setStyle('width', strBreadcrumbWidth);
}



/**
 * f4_textResizing
 * Resizes the base font size when switching between the resize links.
 *
 * @author Ralph Meeuws (ralph.meeuws[AT]efocus.nl)
 * @return void
 */
function f4_textResizing() {
	arrF4 = $$('.f4_secondary_functions');
	if (arrF4.length == 0) return;

	// These three values define the zoom level of the text resizing:
	intTextSizePercentSmall = 100;
	intTextSizePercentMedium = 112.5;
	intTextSizePercentLarge = 125;

	elBody = $(document.body);
	strBodyBaseFontSize = '16px';
	intTextSizePercentageOld = intTextSizePercentSmall;
	
	arrTextResizeLinks = arrF4[0].getElements('li').getLast().getElements('a');
	
	if (Cookie.read('judex_textsize')) {
		intCustomTextSizePercent = Cookie.read('judex_textsize');
		elBody.setStyle('font-size', (strBodyBaseFontSize.toInt() * (intCustomTextSizePercent / 100)) + 'px');
		
		if (intCustomTextSizePercent == intTextSizePercentSmall) {
			intTextSizePercentageOld = intTextSizePercentSmall;
			selectResizeLink(arrTextResizeLinks[0]);
		} else if (intCustomTextSizePercent == intTextSizePercentMedium) {
			intTextSizePercentageOld = intTextSizePercentMedium;
			selectResizeLink(arrTextResizeLinks[1]);
		} else if (intCustomTextSizePercent == intTextSizePercentLarge) {
			intTextSizePercentageOld = intTextSizePercentLarge;
			selectResizeLink(arrTextResizeLinks[2]);
		}
	}

	arrTextResizeLinks.each(function(elTextResizeLink){
		if (elTextResizeLink.hasClass('textsize_small')) {
			elTextResizeLink.addEvent('click', function(){
				resizingText(intTextSizePercentageOld, intTextSizePercentSmall);
				selectResizeLink(elTextResizeLink);
				resizeAccordionPanelHeight(intTextSizePercentageOld, intTextSizePercentSmall);
			});
		} else if (elTextResizeLink.hasClass('textsize_medium')) {
			elTextResizeLink.addEvent('click', function(){
				resizingText(intTextSizePercentageOld, intTextSizePercentMedium);
				selectResizeLink(elTextResizeLink);
				resizeAccordionPanelHeight(intTextSizePercentageOld, intTextSizePercentMedium);
			});
		} else if (elTextResizeLink.hasClass('textsize_large')) {
			elTextResizeLink.addEvent('click', function(){
				resizingText(intTextSizePercentageOld, intTextSizePercentLarge);
				selectResizeLink(elTextResizeLink);
				resizeAccordionPanelHeight(intTextSizePercentageOld, intTextSizePercentLarge);
			});
		}
	});
	
	f3_breadcrumbWidth();
}

/**
 * resizingText
 * Resizes the font size animated from its current font size and saves it in a cookie.
 *
 * @author Ralph Meeuws (ralph.meeuws[AT]efocus.nl)
 * @param intTextSizePercentage
 * @return void
 */
function resizingText(thisIntTextSizePercentageOld, thisIntTextSizePercentageNew){
	elBody.get('tween').start('font-size', (strBodyBaseFontSize.toInt() * (thisIntTextSizePercentageOld / 100)) + 'px', (strBodyBaseFontSize.toInt() * (thisIntTextSizePercentageNew / 100)) + 'px').chain(function(){
		f14_mainNavDropDown();
		f3_breadcrumbWidth();
		alignListRowHeight($(document.body).getElement('.f37_jurisdiction_nav'));
		alignByEqualHeight($$('.f37_jurisdiction_nav', '.f42_infobox'));
	});

	var judexCookie = Cookie.write('judex_textsize', thisIntTextSizePercentageNew);
	intTextSizePercentageOld = thisIntTextSizePercentageNew;
}

/**
 * selectResizeLink
 * Selects the appropriate resize link.
 *
 * @author Ralph Meeuws (ralph.meeuws[AT]efocus.nl)
 * @param elTextResizeLink
 * @return void
 */
function selectResizeLink(elTextResizeLink){
	arrTextResizeLinks.each(function(thisElTextResizeLink){
		thisElTextResizeLink.removeClass('textsize_selected');
	});
	elTextResizeLink.addClass('textsize_selected');
}

/**
 * resizeAccordionPanelHeight
 * Adapts the height of an open accordion panel when resizing the text.
 *
 * @author Ralph Meeuws (ralph.meeuws[AT]efocus.nl)
 * @return void
 */
function resizeAccordionPanelHeight(thisIntTextSizePercentageOld, thisIntTextSizePercentageNew) {
	arrF24 = $$('.f24_accordion_list');
	if (arrF24.length == 0) return;
	
	arrAccordionPanels = arrF24[0].getElements('.panel');
	arrAccordionPanels.each(function(elAccordionPanel){
		if (elAccordionPanel.getHeight() != 0) elAccordionPanel.setStyle('height', (elAccordionPanel.getHeight() * (thisIntTextSizePercentageNew / 100)));
	});
}



/**
 * f5_searchFieldFocus
 * Highlites the custom value in the searchfield, or replaces the standard text.
 *
 * @author Ralph Meeuws (ralph.meeuws[AT]efocus.nl)
 * @return void
 */
function f5_searchFieldFocus() {
	arrF5 = $$('.f5_search_function');
	if (arrF5.length == 0) return;
	
	var arrSbFields = $$('.searchbox_field');

	arrSbFields.each(function(elSbField){
		var strSbFieldValue = elSbField.value;
		
		elSbField.addEvents({
			'focus': function() {
				if (elSbField.value == strSbFieldValue) {
					elSbField.value = '';
					elSbField.removeClass('inactive');
				}
			},
			'blur': function() {
				if ((elSbField.value == strSbFieldValue) || (elSbField.value == '')) {
					elSbField.value = strSbFieldValue;
					elSbField.addClass('inactive');
				}
			}
		});
	});

}



/**
 * f6_loadFlashPresentation
 * Loads the swf object used on the homepage replacing the HTML alternative.
 *
 * @author Mirjam <mirjam{AT}efocus.nl>
 * @editor Ralph Meeuws (ralph.meeuws[AT]efocus.nl)
 * @return void
 */
function f6_loadFlashPresentation() {
	if (!$('presentation_judex')) return;
	
	var headerSwiff = new Swiff('/swf/judex.swf', {
		id: 'judex',
		width: 756,
		height: 239,
		params: {
			wmode: 'transparent'
		}, 
		container: $('presentation_judex')
	});
	
} 



/**
 * f10_slideTextLimiter
 * Activates the mainnav dropdown menu when the mouseenter the dropdown button.
 *
 * @author Ralph Meeuws (ralph.meeuws[AT]efocus.nl)
 * @param maximum number of characters
 */
function f10_slideTextLimiter(intSlideTextMaxNumber) {
	arrF10 = $$('.f10_current_subject');
	if (arrF10.length == 0) return;
	
	var elMySs = arrF10[0].getElement('.slideshow');
	var arrMySlideTexts = elMySs.getElements('.text p');
	arrMySlideTexts.each(function(elMySlideText){
		elMySlideText.set('text', elMySlideText.get('text').substring(0, intSlideTextMaxNumber) + '...');
	});
}



/**
 * f14_mainNavDropDown
 * Activates the mainnav dropdown menu when the mouseenter the dropdown button.
 *
 * @author Ralph Meeuws (ralph.meeuws[AT]efocus.nl)
 * @return void
 */
function f14_mainNavDropDown() {
	
	if (!$('main_nav_dropdown_btn')) return;
	
	elDdBtn = $('main_nav_dropdown_btn');
	elDdVp = $('main_nav_dropdown_viewport');
	elDdLst = $('main_nav_dropdown_list');
	delayedDdClosing = null;
	
	elDdBtn.removeEvents('mouseenter', 'mouseleave'); //////////////// TEMP
	elDdLst.removeEvents('mouseenter', 'mouseleave'); //////////////// TEMP
	
	minWidth = elDdBtn.getStyle('width').toInt() - (elDdVp.getStyle('border-left-width').toInt() + elDdVp.getStyle('border-right-width').toInt());
	minHeight = 0;
	maxWidth = elDdLst.getSize().x;
	if (Browser.Engine.trident4) {
		arrDdLstItems = elDdLst.getElements('li');
		arrDdLstItems.each(function(elDdLstItem){
			elDdLstItem.setStyle('width', maxWidth);
		});
	}
	maxHeight = elDdLst.getSize().y;
	
	elDdVp.setStyle('visibility', 'visible');
	elDdVp.setStyle('width', minWidth);
	elDdVp.setStyle('height', minHeight);
	elDdVp.setStyle('opacity', 0);
	elDdLst.setStyle('opacity', 0);
	
	fxDdVpAniFade = new Fx.Morph(elDdVp, {duration: 100, transition: Fx.Transitions.Cubic.easeOut});
	fxDdVpAniVert = new Fx.Morph(elDdVp, {duration: 250, transition: Fx.Transitions.Back.easeOut});
	fxDdVpAniSlide = new Fx.Morph(elDdVp, {duration: 250, transition: Fx.Transitions.Back.easeInOut});
	fxDdLstFade = new Fx.Morph(elDdLst, {duration: 250, transition: Fx.Transitions.Quad.easeOut});
	
	elDdBtn.addEvents({
		'mouseenter': function(){
			clearTimeout(delayedDdClosing);
			openMainNavDropDown(elDdVp, elDdLst, fxDdVpAniFade, fxDdVpAniVert, fxDdVpAniSlide, fxDdLstFade, maxWidth, minWidth, maxHeight, minHeight);
		},
		'mouseleave': function(){
			delayedDdClosing = setTimeout("closeMainNavDropDown(elDdVp, elDdLst, fxDdVpAniFade, fxDdVpAniVert, fxDdVpAniSlide, fxDdLstFade, maxWidth, minWidth, maxHeight, minHeight)", 500);
		}
	});
	
	elDdLst.addEvents({
		'mouseenter': function(){
			clearTimeout(delayedDdClosing);
		},
		'mouseleave': function(){
			closeMainNavDropDown(elDdVp, elDdLst, fxDdVpAniFade, fxDdVpAniVert, fxDdVpAniSlide, fxDdLstFade, maxWidth, minWidth, maxHeight, minHeight);
		}
	});
	
}

/**
 * openMainNavDropDown
 * Opens the mainnav dropdown menu.
 *
 * @author Ralph Meeuws (ralph.meeuws[AT]efocus.nl)
 * @param elDdVp, elDdLst, fxDdVpAniFade, fxDdVpAniVert, fxDdVpAniSlide, fxDdLstFade, maxWidth, minWidth, maxHeight, minHeight
 * @return void
 */
function openMainNavDropDown(elDdVp, elDdLst, fxDdVpAniFade, fxDdVpAniVert, fxDdVpAniSlide, fxDdLstFade, maxWidth, minWidth, maxHeight, minHeight) {
	fxDdVpAniFade.cancel();
	fxDdVpAniVert.cancel();
	fxDdVpAniSlide.cancel();
	fxDdLstFade.cancel();
	
	fxDdVpAniFade.start({
		'opacity': [elDdVp.getStyle('opacity'), 1]
	}).chain(function(){
		fxDdVpAniVert.start({
			'height': [elDdVp.getStyle('height'), maxHeight]
		}).chain(function(){
			fxDdVpAniSlide.start({
				'width': [elDdVp.getStyle('width'), maxWidth]
			}).chain(function(){
				fxDdLstFade.start({
					'opacity': [elDdLst.getStyle('opacity'), 1]
				});
			});
		});
	});
}

/**
 * closeMainNavDropDown
 * Closes the mainnav dropdown menu.
 *
 * @author Ralph Meeuws (ralph.meeuws[AT]efocus.nl)
 * @param elDdVp, elDdLst, fxDdVpAniFade, fxDdVpAniVert, fxDdVpAniSlide, fxDdLstFade, maxWidth, minWidth, maxHeight, minHeight
 * @return void
 */
function closeMainNavDropDown(elDdVp, elDdLst, fxDdVpAniFade, fxDdVpAniVert, fxDdVpAniSlide, fxDdLstFade, maxWidth, minWidth, maxHeight, minHeight) {
	fxDdLstFade.cancel();
	fxDdVpAniSlide.cancel();
	fxDdVpAniVert.cancel();
	fxDdVpAniFade.cancel();
	
	fxDdLstFade.start({
		'opacity': [elDdLst.getStyle('opacity'), 0]
	}).chain(function(){
		fxDdVpAniSlide.start({
			'width': [elDdVp.getStyle('width'), minWidth]
		}).chain(function(){
			fxDdVpAniFade.start({
				'opacity': [elDdVp.getStyle('opacity'), 0]
			});			
		});
	});
}

/**
 * f15_departmentNav
 * Activates open/close on the mainmenu.
 *
 * @author Mirjam (mirjam[AT]efocus.nl)
 * @return void
 */
 
function f15_departmentNav() {
	
	var navItems = $$('div.f15_index_department ul li');
	if (navItems.length == 0) return;
	
	// main
	objSearchResultsAccordion = new Accordion($$('.togglernav'), $$('.panelnav'), {
			show: 0,
			alwaysHide: false,
			onActive: function(toggler){
				toggler.addClass('active');
			},
			onBackground: function(toggler){
				toggler.removeClass('active');
			}
	});
	
	$$('.togglernav').addEvent('mouseenter', function() { this.fireEvent('click'); });
	
	// next level	
	objSearchResultsAccordion = new Accordion($$('.togglersubnav'), $$('.panelsubnav'), {
			show: 0,
			alwaysHide: false,
			onActive: function(toggler){
				toggler.addClass('active');
			},
			onBackground: function(toggler){
				toggler.removeClass('active');
			}
	});
	
	$$('.togglersubnav').addEvent('mouseenter', function() { this.fireEvent('click'); });
	
}


/**
 * f19_searchResultsAccordion
 * Activates the accordion effect on the searchresults.
 *
 * @author Ralph Meeuws (ralph.meeuws[AT]efocus.nl)
 * @return void
 */
function f19_searchResultsAccordion() {
	arrF19 = $$('.f19_searchresults_list');
	if (arrF19.length == 0) return;

	objSearchResultsAccordion = new Accordion($$('.toggler'), $$('.panel'), {
		show: 0,
		alwaysHide: true,
		onActive: function(toggler){
			toggler.getElement('.accordion_indicator').addClass('open')
		},
		onBackground: function(toggler){
			toggler.getElement('.accordion_indicator').removeClass('open')
		}
	});
	
	// Rollover effect fix for IE6:
	if (Browser.Engine.trident4) {
		var arrSearchResultItems = $$('.panel li');
		arrSearchResultItems.each(function(elSearchResultItem){
			elSearchResultItem.addEvents({
				'mouseenter': function(){
					elSearchResultItem.addClass('hover');
				},
				'mouseleave': function(){
					elSearchResultItem.removeClass('hover');
				}
			});
		});
	}
}



/**
 * f20_searchResultsPerTypeFixes
 * Enables the rollover effects over list items in IE6.
 *
 * @author Ralph Meeuws (ralph.meeuws[AT]efocus.nl)
 * @return void
 */
function f20_searchResultsPerTypeFixes() {
	arrF20 = $$('.f20_searchresults_per_type');
	if (arrF20.length == 0) return;
	
	// Rollover effect fix for IE6:
	if (Browser.Engine.trident4) {
		var arrSearchResultItems = $$('.searchresults_per_type li');
		arrSearchResultItems.each(function(elSearchResultItem){
			elSearchResultItem.addEvents({
				'mouseenter': function(){
					elSearchResultItem.addClass('hover');
				},
				'mouseleave': function(){
					elSearchResultItem.removeClass('hover');
				}
			});
		});
	}
}



/**
 * f22_searchResultsLawyerFixes
 * Enables the rollover effects over list items in IE6.
 *
 * @author Ralph Meeuws (ralph.meeuws[AT]efocus.nl)
 * @return void
 */
function f22_searchResultsLawyerFixes() {
	arrF22 = $$('.f22_searchresults_lawyers');
	if (arrF22.length == 0) return;
	
	// Rollover effect fix for IE6:
	if (Browser.Engine.trident4) {
		var arrSearchResultItems = $$('.searchresults_lawyers li');
		arrSearchResultItems.each(function(elSearchResultItem){
			elSearchResultItem.addEvents({
				'mouseenter': function(){
					elSearchResultItem.addClass('hover');
				},
				'mouseleave': function(){
					elSearchResultItem.removeClass('hover');
				}
			});
		});
	}
}



/**
 * f24_accordionList
 * Activates the accordion effect on the general accordion list template (for FAQ, Tipx & Tricks, etc.).
 *
 * @author Ralph Meeuws (ralph.meeuws[AT]efocus.nl)
 * @return void
 */
function f24_accordionList() {
	arrF24 = $$('.f24_accordion_list');
	if (arrF24.length == 0) return;

	objSearchResultsAccordion = new Accordion($$('.toggler'), $$('.panel'), {
		show: 0,
		alwaysHide: true,
		onActive: function(toggler){
			toggler.getElement('.accordion_indicator').addClass('open')
		},
		onBackground: function(toggler){
			toggler.getElement('.accordion_indicator').removeClass('open')
		}
	});
	
	/* Depending on the address the following opens the accordion to a specific panel: i.e. use file.html#04 for the fourth item. */
	var strWebpageAddress = window.location.href;
	var arrAccordionLinks = arrF24[0].getElements('li');
	arrAccordionLinks.each(function(elAccordionLink, n){
		if (strWebpageAddress.contains('#' + n) || strWebpageAddress.contains('#' + '0' + n)) objSearchResultsAccordion.display(n-1);
	});
	
	// Rollover effect fix for IE6:
	/*
	if (Browser.Engine.trident4) {
		var arrSearchResultItems = $$('.panel li');
		arrSearchResultItems.each(function(elSearchResultItem){
			elSearchResultItem.addEvents({
				'mouseenter': function(){
					elSearchResultItem.addClass('hover');
				},
				'mouseleave': function(){
					elSearchResultItem.removeClass('hover');
				}
			});
		});
	}
	*/
}



/**
 * f28_alsoseeListFixes
 * Enables the rollover effects over list items in IE6.
 *
 * @author Ralph Meeuws (ralph.meeuws[AT]efocus.nl)
 * @return void
 */
function f28_alsoseeListFixes() {
	arrF28 = $$('.f28_alsosee_list');
	if (arrF28.length == 0) return;
	
	// Rollover effect fix for IE6:
	if (Browser.Engine.trident4) {
		var arrSearchResultItems = $$('.alsosee_list li');
		arrSearchResultItems.each(function(elSearchResultItem){
			elSearchResultItem.addEvents({
				'mouseenter': function(){
					elSearchResultItem.addClass('hover');
				},
				'mouseleave': function(){
					elSearchResultItem.removeClass('hover');
				}
			});
		});
	}
}



/**
 * f31_ratingSelector
 * Defines the interaction of the rating selector.
 *
 * @author Ralph Meeuws (ralph.meeuws[AT]efocus.nl)
 * @return void
 */
function f31_ratingSelector() {
	if (!$('rating_selector')) return;
	
	elRatingSelector = $('rating_selector');
	arrRatingSelectorLinks = elRatingSelector.getElements('a');
			
	arrRatingSelectorLinks.each(function(elRatingSelectorLink, n){
		elRatingSelectorLink.addEvent('mouseenter', function(){
			intRatingSelectorNumber = ((n) * 5);
			if (intRatingSelectorNumber == 0 || intRatingSelectorNumber == 5) intRatingSelectorNumber = '0' + intRatingSelectorNumber;
			elRatingSelector.className = 'rating' + intRatingSelectorNumber;
			// add rating to form
			if ($('rating_number')) {
				$('rating_number').value = elRatingSelector.className;
			}
		});
	});
}



/**
 * f33_columnsListFixes
 * Enables the rollover effects over list items in IE6.
 *
 * @author Ralph Meeuws (ralph.meeuws[AT]efocus.nl)
 * @return void
 */
function f33_columnsListFixes() {
	arrF33 = $$('.f33_columns_list');
	if (arrF33.length == 0) return;
	
	// Rollover effect fix for IE6:
	if (Browser.Engine.trident4) {
		var arrSearchResultItems = $$('.alsosee_list li');
		arrSearchResultItems.each(function(elSearchResultItem){
			elSearchResultItem.addEvents({
				'mouseenter': function(){
					elSearchResultItem.addClass('hover');
				},
				'mouseleave': function(){
					elSearchResultItem.removeClass('hover');
				}
			});
		});
	}
}



/**
 * f36_lightboxLoginToggle
 * Toggles between the login screen and password request screen within a lightbox.
 *
 * @author Ralph Meeuws (ralph.meeuws[AT]efocus.nl)
 * @return void
 */
function f36_lightboxLoginToggle() {
	if (!$('lb_login') || !$('lb_forgot_password')) return;
	
	elLbLogin = $('lb_login');
	elLbForgotPassword = $('lb_forgot_password');
	
	elLbLoginToggleBtn = $('login_link_to_password_request');
	elLbForgotPasswordToggleBtn = $('forgot_password_link_back_to_login');
	
	elLbLoginToggleBtn.addEvent('click', function(){
		elLbLogin.addClass('hidden');
		elLbForgotPassword.removeClass('hidden');
	});
	
	elLbForgotPasswordToggleBtn.addEvent('click', function(){
		elLbLogin.removeClass('hidden');
		elLbForgotPassword.addClass('hidden');
	});
}



/**
 * lightBoxSubmitPageRefresh
 * Activates a page-refresh when the close submitbutton within the rate lightbox is being clicked.
 *
 * @author Ralph Meeuws (ralph.meeuws[AT]efocus.nl)
 * @return void
 */
function lightBoxSubmitPageRefresh(){
	arrF36 = $$('.f36_lightbox');
	if (arrF36.length == 0) return;
	
	arrF36.each(function(elF36){
		elLightboxSubmitbutton = elF36.getElement('close_submitbutton');
		if (elLightboxSubmitbutton) {
			elLightboxSubmitbutton.addEvent('click', function(){
				parent.location.reload();
			});
		}
	});
}


/**
 * lightBoxDownloadPageRefresh
 * Activates a page-refresh when the download lightbox is closed,
 * so login status is updated in the header.
 *
 * @author Klaas Dieleman (klaas[AT]efocus.nl)
 * @return void
 */
function lightBoxDownloadPageRefresh(){
	var lightboxDlActive = false;
	Shadowbox.options.onFinish = function() {
		if(Shadowbox.content.obj.content.contains('bestand_downloaden')) lightboxDlActive = true;
	}
	Shadowbox.options.onClose = function() {
		if(lightboxDlActive) {
			parent.location.reload();
			lightboxDlActive = false;
		}
	}
}


/**
 * f38_lightboxVideoPlayer
 * Adds events to links which open a lightbox with a FLV videoplayer.
 *
 * @author Ralph Meeuws (ralph.meeuws[AT]efocus.nl)
 * @return void
 */
function f38_lightboxVideoPlayer() {
	var elF38 = $(document.body).getElement('.f38_judex_tv_homepage');
	if (!elF38) return false;
	
	arrVideoLinks = elF38.getElement('.video_list').getElements('a');
	arrVideoLinks.include(elF38.getElement('.video_visual'));
	arrVideoLinks.include(elF38.getElement('.video_visual_large'));
	
	Shadowbox.setup(arrVideoLinks, {width: 640, height: 360, flashVars: {'plugins': 'googlytics-1'} });
}



/**
 * f43_lightboxVideoPlayer
 * Adds events to links which open a lightbox with a FLV videoplayer.
 *
 * @author Ralph Meeuws (ralph.meeuws[AT]efocus.nl)
 * @author Richard van Yperen (richardvy[AT]efocus.nl)
 * @return void
 */
function f43_lightboxVideoPlayer() {
	var arrF43VideoLinks = $(document).getElements('.f43_videos_overview ul li a');
	if (arrF43VideoLinks.length == 0) return false;
	
	Shadowbox.setup(arrF43VideoLinks, {width: 640, height: 360, flashVars: {'plugins': 'googlytics-1'}});
}

/**
 * f39_lightboxVideoPlayer
 * Adds events to links which open a lightbox with a FLV videoplayer.
 *
 * @author Ralph Meeuws (ralph.meeuws[AT]efocus.nl)
 * @return void
 */
function f39_lightboxVideoPlayer() {
	var elF39 = $(document.body).getElement('.f39_judex_tv_jurisdiction');
	if (!elF39) return false;
	
	arrVideoLinks = elF39.getElement('.video_list').getElements('a');
	
	Shadowbox.setup(arrVideoLinks, {width: 640, height: 360, flashVars: {'plugins': 'googlytics-1'}});
}



/**
 * f40_downloadLegalDocuments
 * Adds events to open a lightbox for downloading a document.
 *
 * @author Ralph Meeuws (ralph.meeuws[AT]efocus.nl)
 * @return void
 */
function f40_downloadLegalDocuments() {
	var elF40 = $(document.body).getElement('.f40_legal_documents');
	if (!elF40) return false;
	
	var arrLegalDocsLinks = elF40.getElement('ul').getElements('a');
	
	Shadowbox.setup(arrLegalDocsLinks, {width: 400, height: 350, player: 'iframe'});
}


/**
 * f45_downloadLegalDocuments
 * Adds events to open a lightbox for downloading a document.
 *
 * @author Ralph Meeuws (ralph.meeuws[AT]efocus.nl)
 * @author Richard van Yperen (richardvy[AT]efocus.nl)
 * @author Klaas Dieleman (klaas[AT]efocus.nl)
 * @return void
 */
function f45_downloadLegalDocuments() {
	var elF45 = $(document.body).getElement('.f45_documents_overview');
	if (!elF45) return false;
	
	var arrLegalDocsLinks = elF45.getElements('a').filter(function(item) {
		if(elF45.getElements('h2 a').indexOf(item) < 0) return item
	});
	
	Shadowbox.setup(arrLegalDocsLinks, {width: 400, height: 350});
}


/**
 * EfxBaseSlideShow Class
 * Reusable slideshow class.
 *
 * @author Ralph Meeuws (ralph.meeuws[AT]efocus.nl)
 * @param arrSlides, intStartSlide, blnLoop, intInterval, blnAutoPlay, blnPlaying
 * @param strOutEffectProperty, intOutEffectStartValue, intOutEffectEndValue, intOutEffectDuration
 * @param strInEffectProperty, intInEffectStartValue, intInEffectEndValue, intInEffectDuration
 * @return EfxBaseSlideShow
 */
var EfxBaseSlideShow = new Class({
	Implements: [Options, Events, Chain],
	options: {
		arrSlides: [],
		intStartSlide: 0,
		blnLoop: true,
		intInterval: 2500,
		blnAutoPlay: true,
		blnPlaying: false,
		
		strOutEffectProperty: 'opacity',
		intOutEffectStartValue: 1,
		intOutEffectEndValue: 0,
		intOutEffectDuration: 'long',
		
		strInEffectProperty: 'opacity',
		intInEffectStartValue: 0,
		intInEffectEndValue: 1,
		intInEffectDuration: 'long'
	},
	initialize: function(options) {
		var that = this;
		this.setOptions(options);
		this.addSlides(this.options.arrSlides);
		this.options.arrSlides.each(function(slide){
			slide.setStyle(that.options.strInEffectProperty, that.options.intInEffectStartValue);
			slide.setStyle(that.options.strOutEffectProperty, that.options.intOutEffectEndValue);
//			slide.setStyle('visibility', 'hidden');
		});
		this.showSlide(this.options.intStartSlide);
		if (this.options.blnAutoPlay == true && this.options.blnPlaying == false) {
			this.playSlideShow();
		}
		this.intSlideCount = 0;
	},
	arrSlideCollection: [],
	addSlides: function(arrSlides){
		arrSlides.each(function(slide){
			this.arrSlideCollection.include(slide);
		}, this);
	},
	addSlide: function(slide){
		this.addSlides($splat(slide));
	},
	cycleForwards: function(){
		if ($chk(this.intCurrentSlideNumber) && this.intCurrentSlideNumber < this.arrSlideCollection.length-1) {
			this.showSlide(this.intCurrentSlideNumber+1);
		} else if ((this.intCurrentSlideNumber) && this.options.blnLoop) {
			this.showSlide(0);
		} else if (!defined(this.intCurrentSlideNumber)) {
			this.showSlide(this.options.intStartSlide);
		}
	},
	cycleBackwards: function(){
		if (this.intCurrentSlideNumber > 0) {
			this.showSlide(this.intCurrentSlideNumber-1);
		} else if (this.options.blnLoop) {
			this.showSlide(this.arrSlideCollection.length-1);
		}
	},
	showSlide: function(intSlideNumberToShow){
		if (this.arrSlideCollection[intSlideNumberToShow]) {
				
			var that = this;
			if (this.arrSlideCollection[this.intCurrentSlideNumber]) {
				var intPreviousSlideNumber = this.intCurrentSlideNumber;
				//this.arrSlideCollection[intSlideNumberToShow].setStyle(that.options.strOutEffectProperty, that.options.intOutEffectStartValue);
				this.arrSlideCollection[this.intCurrentSlideNumber].get('tween', {property: that.options.strOutEffectProperty, duration: that.options.intOutEffectDuration}).start(that.options.intOutEffectStartValue, that.options.intOutEffectEndValue).chain(function(){
					that.arrSlideCollection[intPreviousSlideNumber].setStyle(that.options.strInEffectProperty, that.options.intInEffectStartValue);
				});	
			}
			
			this.arrSlideCollection[intSlideNumberToShow].get('tween', {property: that.options.strInEffectProperty, duration: that.options.intInEffectDuration}).start(that.options.intInEffectStartValue, that.options.intInEffectEndValue);
			this.intCurrentSlideNumber = intSlideNumberToShow;
		}
		this.fireEvent('slideShown', this);
	},
	runSlideShow: function(){
		var that = this;
		
		if (that.intCurrentSlideNumber != this.intSlideCount) {
			this.intSlideCount = that.intCurrentSlideNumber;
		}
		this.intSlideCount++;
		if (this.intSlideCount >= that.arrSlideCollection.length) {
			this.intSlideCount = 0;
		}			
		this.showSlide(this.intSlideCount);
	},
	playSlideShow: function(){
		this.options.blnPlaying = true;
		this.slideShowTimer = this.runSlideShow.periodical(this.options.intInterval, this);
	},
	name: 'EfxBaseSlideShow'
});



/**
 * EfxNavSlideShow Class
 * Customized slideshow class.
 *
 * @author Ralph Meeuws (ralph.meeuws[AT]efocus.nl)
 * @param elNav, strLabelPrev, strLabelNext, strLabelFirst, strLabelLast, strLabelPlay, strLabelPause
 * @return EfxNavSlideShow
 */
var EfxNavSlideShow = new Class({
	Extends: EfxBaseSlideShow,
	options: {
		elNav: $('slideshow_nav'),
		strLabelPrev: 'Previous',
		strLabelNext: 'Next',
		strLabelFirst: 'First',
		strLabelLast: 'Last',
		strLabelPlay: 'Play',
		strLabelPause: 'Pause'
	},
	initialize: function(options){
		this.parent(options);
		if ($defined(this.options.elNav)) {
			this.arrNavLinkNumbers = [];
			this.populateNav();
			this.arrNavListItems = this.options.elNav.getElements('li');
			this.intNavLinksNotNumbers = 0;
			this.arrNavLinks = this.options.elNav.getElements('a');
			this.initNav();
			if (this.arrNavLinkNumbers.length != 0) {
				this.activateNavLink(this.arrNavLinkNumbers[this.options.intStartSlide]);
			}
			this.addEvent('slideShown', function(){
				if (this.arrNavLinkNumbers.length != 0) {
					this.activateNavLink(this.arrNavLinkNumbers[this.intCurrentSlideNumber]);
				}
			});
		}
	},
	populateNav: function(){
		var that = this;
		var elNavListItemNumber = null;
		this.options.elNav.getElements('li').each(function(elNavListItem, n){
			switch(elNavListItem.getElement('a').className){
				case 'prev': break;
				case 'next': break;
				case 'first': break;
				case 'last': break;
				case 'play': break;
				case 'pause': break;
				default: elNavListItemNumber = elNavListItem;
			};
		});
		
		if ($chk(elNavListItemNumber)) {
			this.arrSlideCollection.each(function(elSlide, n){
				elNavListItemNumberNew = elNavListItemNumber.clone();
				elNavListItemNumberNew.getElement('a').innerHTML = n+1;
				elNavListItemNumberNew.getElement('a').setProperty('title', n+1);
				elNavListItemNumberNew.injectBefore(elNavListItemNumber);
				that.arrNavLinkNumbers.include(elNavListItemNumberNew.getElement('a'));
			});
			elNavListItemNumber.dispose();
		}
	},
	initNav: function(){
		var that = this;
		this.arrNavLinks.each(function(elNavLink, n){
			switch(elNavLink.className){
				case 'pause':
					if (that.options.blnPlaying != true) {
						var strNavLinkLabel = that.options.strLabelPlay;
					} else {
						var strNavLinkLabel = that.options.strLabelPause;
					}
					elNavLink.innerHTML = strNavLinkLabel;
					elNavLink.setProperty('title', strNavLinkLabel);
					elNavLink.toggleClass('play');
					elNavLink.toggleClass('pause');
					
					elNavLink.addEvent('click', function(){
						if ($chk(that.slideShowTimer)) {
							var strNavLinkLabel = that.options.strLabelPlay;
							that.slideShowTimer = $clear(that.slideShowTimer);
						} else {
							var strNavLinkLabel = that.options.strLabelPause;
							that.playSlideShow();
						}
						elNavLink.innerHTML = strNavLinkLabel;
						elNavLink.setProperty('title', strNavLinkLabel);
						elNavLink.toggleClass('play');
						elNavLink.toggleClass('pause');
					});
					that.intNavLinksNotNumbers++;
					break;
				case 'play':
					if (that.options.blnPlaying != true) {
						var strNavLinkLabel = that.options.strLabelPlay;
					} else {
						var strNavLinkLabel = that.options.strLabelPause;
					}
					elNavLink.innerHTML = strNavLinkLabel;
					elNavLink.setProperty('title', strNavLinkLabel);
					elNavLink.toggleClass('play');
					elNavLink.toggleClass('pause');
					
					elNavLink.addEvent('click', function(){
						if ($chk(that.slideShowTimer)) {
							var strNavLinkLabel = that.options.strLabelPlay;
							that.slideShowTimer = $clear(that.slideShowTimer);
						} else {
							var strNavLinkLabel = that.options.strLabelPause;
							that.playSlideShow();
						}
						elNavLink.innerHTML = strNavLinkLabel;
						elNavLink.setProperty('title', strNavLinkLabel);
						elNavLink.toggleClass('play');
						elNavLink.toggleClass('pause');
					});
					that.intNavLinksNotNumbers++;
					break;
				case 'first': 
					if (!elNavLink.innerHTML) elNavLink.innerHTML = that.options.strLabelFirst;
					if (!elNavLink.getProperty('title')) elNavLink.setProperty('title', that.options.strLabelFirst);
					elNavLink.addEvent('click', function(){
						that.intSlideCount = 0;
						that.showSlide(that.intSlideCount);
					});
					that.intNavLinksNotNumbers++;
					break;
				case 'prev': 
					if (!elNavLink.innerHTML) elNavLink.innerHTML = that.options.strLabelPrev;
					if (!elNavLink.getProperty('title')) elNavLink.setProperty('title', that.options.strLabelPrev);
					elNavLink.addEvent('click', function(){
						that.cycleBackwards();
					});
					that.intNavLinksNotNumbers++;
					break;
				case 'next': 
					if (!elNavLink.innerHTML) elNavLink.innerHTML = that.options.strLabelNext;
					if (!elNavLink.getProperty('title')) elNavLink.setProperty('title', that.options.strLabelNext);
					elNavLink.addEvent('click', function(){
						that.cycleForwards();
					});
					that.intNavLinksNotNumbers++;
					break;
				case 'last': 
					if (!elNavLink.innerHTML) elNavLink.innerHTML = that.options.strLabelLast;
					if (!elNavLink.getProperty('title')) elNavLink.setProperty('title', that.options.strLabelLast);
					elNavLink.addEvent('click', function(){
						that.intSlideCount = that.arrSlideCollection.length-1;
						that.showSlide(that.intSlideCount);
					});
					that.intNavLinksNotNumbers++;
					break;
				default:
					var intNavLinksOffset = that.intNavLinksNotNumbers;
					elNavLink.addEvent('click', function(){
						that.intSlideCount = n-intNavLinksOffset;
						that.showSlide(that.intSlideCount);
						that.activateNavLink(elNavLink);
					});
			};
		});
	},
	activateNavLink: function(elNavLink){
		this.arrNavListItems.each(function(elNavListItem){
			elNavListItem.removeClass('active');
		});
		elNavLink.getParent().addClass('active');
	},
	name: 'EfxNavSlideShow'
});



/**
 * f10_slideShow
 * Animates the slideshow and defines the interaction.
 *
 * @author Ralph Meeuws (ralph.meeuws[AT]efocus.nl)
 * @param arrSlides, intStartSlide, blnLoop, intInterval, blnAutoPlay, blnPlaying
 * @param strOutEffectProperty, intOutEffectStartValue, intOutEffectEndValue, intOutEffectDuration
 * @param strInEffectProperty, intInEffectStartValue, intInEffectEndValue, intInEffectDuration
 * @param elNav, strLabelPrev, strLabelNext, strLabelFirst, strLabelLast, strLabelPlay, strLabelPause
 * @return EfxNavSlideShow Class instance
 */
function f10_slideShow(){
	arrF10 = $$('.f10_current_subject');
	if (arrF10.length == 0) return;
	
	var elMySs = arrF10[0].getElement('.slideshow');
	var arrMySlides = elMySs.getElements('.slide');
	var elMyNav = arrF10[0].getElement('.paginator');

	var objSlideShow = new EfxNavSlideShow({
		arrSlides: arrMySlides,
		elNav: elMyNav,
		intInterval: 12000,
		strOutEffectProperty: 'top',
		intOutEffectStartValue: 0,
		intOutEffectEndValue: 200,
		strInEffectProperty: 'top',
		intInEffectStartValue: -200,
		intInEffectEndValue: 0
	});
}



/**
 * f46_advancedSearchResultsLawyerFixes
 * Enables the rollover effects over list items in IE6.
 *
 * @author Ralph Meeuws (ralph.meeuws[AT]efocus.nl)
 * @return void
 */
function f46_advancedSearchResultsLawyerFixes() {
	arrF46 = $$('.f46_advanced_searchresults_lawyers');
	if (arrF46.length == 0) return;
	
	// Rollover effect fix for IE6:
	if (Browser.Engine.trident4) {
		var arrSearchResultItems = $$('.searchresults_lawyers li');
		arrSearchResultItems.each(function(elSearchResultItem){
			elSearchResultItem.addEvents({
				'mouseenter': function(){
					elSearchResultItem.addClass('hover');
				},
				'mouseleave': function(){
					elSearchResultItem.removeClass('hover');
				}
			});
		});
	}
}



/**
 * initFF2Fixes
 * Fixes the use of display inline-block for Firefox 2.
 *
 * @author Ralph Meeuws (ralph.meeuws[AT]efocus.nl)
 */
function initFF2Fixes() {
	if (!Browser.Engine.gecko || Browser.Engine.version != 18) return;
	
	function fixDisplayInlineBlock(el) {
		el.setStyle('display', '-moz-inline-box');
	}
	
	var arrCompRatings = $$('.component_rating');
	arrCompRatings.each(function(elCompRating){
		elCompRatingSpan = elCompRating.getElement('span');
		fixDisplayInlineBlock(elCompRatingSpan);
	});
	
	var arrF13Footers = $$('.f13_footer');
	arrF13Footers.each(function(elF13Footer){
		elF13FooterLinkRSS = elF13Footer.getElement('.link_rss');
		fixDisplayInlineBlock(elF13FooterLinkRSS);
	});
	
	var arrF21SearchLawyers = $$('.f21_search_lawyers');
	arrF21SearchLawyers.each(function(elF21SearchLawyer){
		arrF21SearchLawyerLabels = elF21SearchLawyer.getElements('label');
		arrF21SearchLawyerLabels.each(function(elF21SearchLawyerLabel){
			fixDisplayInlineBlock(elF21SearchLawyerLabel);
		});
	});
}



/**
 * jsBox
 * Javascript replacement for flashbox on the homepage
 * Same effect in javascript
 *
 * @author Erhan Karadeniz (erhan-karadeniz[AT]efocus.nl)
 */

function jsBox() {
	
	$$('#box_links a').each(function(boxlinks, index) {
		
		boxlinks.addEvent('click', function(boxevent) {
			
			$$('.box_content').each(function(boxjes){
				boxjes.setStyle('display', 'none');
			})
			
			$$('#box_links li').each(function(boxli){
				boxli.removeClass('selected');
			})
			
			var test = $$('#box_content' + index);
			
			test.setStyle('display', 'block');
			this.getParent('li').addClass('selected');
		})
	})  
}



/**
 * distributeListAmongMultipleColumns
 * Distributes a single list among multiple columns depending on the width of its parent.
 *
 * @author Ralph Meeuws <ralph.meeuws{AT}efocus.nl>
 * @return void
 */
function distributeListAmongMultipleColumns(elList) {
	if (checkIfElementExists(elList) == false) return;
	elList.setStyle('visibility', 'hidden');
	var strListClassName = elList.getProperty('class');
	var arrListItems = getChildrenOfElement(elList);
	
	arrListItems.each(function(elListItem){
		arrSubListItems = elListItem.getElements('li');
		if (arrSubListItems.length != 0) arrSubListItems[arrSubListItems.length-1].addClass('last');
	});
	
	resetColumnList = function() {
		intColumnHeight = 0;
		elColumnListEmpty = new Element('ul', {'class': strListClassName, 'style': 'visibility: hidden;'});
		elColumnList = elColumnListEmpty.clone();
	}
	
	if (arrListItems.length > 0) {
		elParent = elList.getParent();
		intParentWidth = elParent.getWidth();
		intListItemGutter = arrListItems[0].getStyle('margin-left').toInt() + arrListItems[0].getStyle('margin-right').toInt();
		intListItemFullWidth = arrListItems[0].getWidth() + intListItemGutter;
		intColumnsTotal = Math.floor((intParentWidth + intListItemGutter) / intListItemFullWidth);
		intAverageColumnHeight = Math.ceil(elList.getHeight() / intColumnsTotal);
		resetColumnList();
		
		arrListItems.each(function(elListItem, index){
			intColumnHeight = intColumnHeight + elListItem.getHeight() + (elListItem.getStyle('margin-top').toInt() + elListItem.getStyle('margin-bottom').toInt());
			
			elListItem.inject(elColumnList, 'bottom');
			
			var intListItemHeightNext = (index == arrListItems.length - 1) ? 0 : (arrListItems[index + 1].getHeight());
			
			if (intColumnHeight + (intListItemHeightNext / 3) > intAverageColumnHeight) {
				elColumnList.inject(elParent, 'bottom');
				resetColumnList();
			}
			
			if (elListItem == arrListItems[arrListItems.length - 1]) {
				elColumnList.inject(elParent, 'bottom');
			}
		});
		
		elList.dispose();
		
		$$('.'+strListClassName).setStyle('visibility', 'visible');
	}
}

function getChildrenOfElement(el) {
	var arrChildren = [];
	if (checkIfElementExists(el)) arrChildren = el.getChildren();
	return arrChildren;
}

function checkIfElementExists(el) {
	var blnElementExists = false;
	if (el) blnElementExists = true;
	return blnElementExists;
}


/**
 * alignListRowHeight
 * Vertically aligns all list items on each row of a list.
 *
 * @author Ralph Meeuws <ralph.meeuws{AT}efocus.nl>
 * @author Lee Boonstra <lee.boonstra{AT}efocus.nl>
 * @return void
 */
function alignListRowHeight(elList) {
	var arrChildren = getChildrenOfElement(elList);
	if (arrChildren.length > 0) {
		measureListItemHeights(arrChildren);
	}
}

/**
 * measureListItemHeights
 * Measures the height of all list items on a each row.
 *
 * @author Ralph Meeuws <ralph.meeuws{AT}efocus.nl>
 * @return void
 */
function measureListItemHeights(arrListItems) {
	var intListItemMaxHeight = 0;
	var intListItemPosX = 0;
	var intListItemsPerRow = Math.floor(arrListItems[0].getParent().getWidth() / arrListItems[0].getWidth());
	
	getHeightOnly = function(elElement, intHeight) {
		var intHeightOnly = intHeight - (elElement.getStyle('padding-top').toInt() + elElement.getStyle('padding-bottom').toInt());
		return intHeightOnly;
	};
	
	setHeight = function(intIndex, intLoopCount, arrElements, elElement, intHeight) {
		for (var i = 0; i < intLoopCount; i++) {
			arrElements[intIndex - i].setStyle('height', getHeightOnly(elElement, intHeight));
		}
		intListItemMaxHeight = 0;
	}
	
	arrListItems.each(function(elListItem, intIndex) {
		var elListItemHeight = elListItem.getStyle('padding-top').toInt() + elListItem.getStyle('padding-bottom').toInt() + elListItem.getElement('h3').getHeight() + 5 + elListItem.getElement('ul').getHeight() + elListItem.getElement('ul').getStyle('margin-bottom').toInt();
		if (elListItemHeight > intListItemMaxHeight) intListItemMaxHeight = elListItemHeight;
		
		if ((intIndex + 1) % intListItemsPerRow == 0) {
			setHeight(intIndex, intListItemsPerRow, arrListItems, elListItem, intListItemMaxHeight);
		} else if ((intIndex + 1) == arrListItems.length) {
			var intLastRowItemsCount = arrListItems.length - Math.floor(arrListItems.length / intListItemsPerRow) * intListItemsPerRow;
			setHeight(intIndex, intLastRowItemsCount, arrListItems, elListItem, intListItemMaxHeight);
		}
	});
}



/**
 * alignByEqualHeight
 * Aligns multiple items by giving them the same height.
 *
 * @author Ralph Meeuws <ralph.meeuws{AT}efocus.nl>
 * @return void
 */
function alignByEqualHeight(arrElements) {
	var intMaxHeight = 0;
	
	arrElements.each(function(el){
		checkIfElementExists(el);
		if (checkIfElementExists(el)) {
			// Reset a previously set height:
			el.setStyle('height', 'auto');
			// Calculate the real full height:
			intHeightFull = el.getSize().y;
			// If this height is larger than the maximum height, it becomes the new maximum:
			if (intHeightFull > intMaxHeight) intMaxHeight = intHeightFull;
		}
	});
	
	arrElements.each(function(el){
		checkIfElementExists(el);
		if (checkIfElementExists(el)) {
			// Set each element to the maximum height:
			el.setStyle('height', (intMaxHeight - (el.getStyle('padding-top').toInt() + el.getStyle('padding-bottom').toInt() + el.getStyle('border-bottom-width').toInt() + el.getStyle('border-bottom-width').toInt())));
		}
	});
}



/**
 * Functie om het contact opnemen formulier te posten en de afhandeling van dit form te doen.
 *
 * @author Stephan vande Haar <stephan.vande.haar@efocus.nl> 
 * @author Ralph Meeuws <ralph.meeuws{AT}efocus.nl>
 * @author Richard van Yperen <richardvy@efocus.nl> 
 * @since 1.1, 10 dec 2009
 * @param object form het formulier object 
 */    
function postContactOpnemenForm() {
	new Request.JSON({
	    url: '/',
	    onSuccess: function(responseJSON, responseText) {
	    	if (responseJSON.success == true) {
				window.location = $('redirect_url').value;
	    	} else {
				resetFormFieldErrors($('f49_form'));
				responseJSON.fields.each(function(responseField){
					var strFieldName = responseField.field;
					responseField.message.each(function(strFieldMessage){
						displayFormFieldError(strFieldName, strFieldMessage, 'f49_form');
					});
				});
	    	}
	    }
	}).post($('f49_form'));
}

/**
 * Functie om het contact formulier te posten en de afhandeling van dit form te doen.
 *
 * @author Ralph Meeuws <ralph.meeuws{AT}efocus.nl>
 * @author Richard van Yperen <richardvy@efocus.nl> 
 * @since 1.1, 10 dec 2009
 * @param object form het formulier object 
 */    
function postContactForm() {
	new Request.JSON({
	    url: '/',
	    onSuccess: function(responseJSON, responseText) {
	    	if (responseJSON.success == true) {
				window.location = $('redirect_url').value;
	    	} else {
				resetFormFieldErrors($('f35_form'));
				responseJSON.fields.each(function(responseField){
					var strFieldName = responseField.field;
					responseField.message.each(function(strFieldMessage){
						displayFormFieldError(strFieldName, strFieldMessage, 'f35_form');
					});
				});
	    	}
	    }
	}).post($('f35_form'));
}

/**
 * Functie om het contact formulier te posten en de afhandeling van dit form te doen.
 *
 * @author Ralph Meeuws <ralph.meeuws{AT}efocus.nl>
 * @author Richard van Yperen <richardvy@efocus.nl> 
 * @since 1.1, 10 dec 2009
 * @param object form het formulier object 
 */    
function postRegistrationForm() {
	new Request.JSON({
	    url: '/',
	    onSuccess: function(responseJSON, responseText) {
	    	if (responseJSON.success == true) {
				window.location = $('redirect_url').value;
	    	} else {
				resetFormFieldErrors($('f35_form'));
				responseJSON.fields.each(function(responseField){
					var strFieldName = responseField.field;
					responseField.message.each(function(strFieldMessage){
						displayFormFieldError(strFieldName, strFieldMessage, 'f35_form');
					});
				});
	    	}
	    }
	}).post($('f35_form'));
}

/**
 * Functie om het mail a friendformulier te posten en de afhandeling van dit form te doen.
 *
 * @author Ralph Meeuws <ralph.meeuws{AT}efocus.nl>
 * @author Richard van Yperen <richardvy@efocus.nl> 
 * @since 1.1, 10 dec 2009
 * @param object form het formulier object 
 */    
function postMailAFriendForm() {
	new Request.JSON({
	    url: '/',
	    onSuccess: function(responseJSON, responseText) {
	    	if (responseJSON.success == true) {
				window.location = $('redirect_url').value;
	    	} else {
				resetFormFieldErrors($('f36_form'));
				responseJSON.fields.each(function(responseField){
					var strFieldName = responseField.field;
					responseField.message.each(function(strFieldMessage){
						displayFormFieldError(strFieldName, strFieldMessage, 'f36_form');
					});
				});
	    	}
	    }
	}).post($('f36_form'));
}


/**
 * displayFormFieldError
 * Displays form field errors.
 *
 * @author Ralph Meeuws <ralph.meeuws{AT}efocus.nl>
 */
function displayFormFieldError(strFieldName, strFieldMessage, form) {
	var elErrorMessageBase = new Element('span', {'class': 'error_message'});
	
	$(form).getElements('input').combine($(form).getElements('textarea')).each(function(elFormInput){
		if (elFormInput.getProperty('name') == strFieldName) {
			var elErrorMessage = elErrorMessageBase.clone();
			if (elFormInput.getParent('.inputgroup')) {
				if (elFormInput.getParent('.inputgroup').getElements('.error_message') == 0) {
					elErrorMessage.inject(elFormInput.getParent('.inputgroup'), 'bottom');
					elErrorMessage.set('text', 'Geen keuze gemaakt');
				}
			} else if (elFormInput.getParent('.form_cols')) {
				elFormInput.addClass('error');
				if (elFormInput.getParent('.form_cols').getElements('.error_message') == 0) {
					elErrorMessage.inject(elFormInput.getParent('.form_cols'), 'bottom');
					elErrorMessage.set('text', 'Veld niet ingevuld');
				} else {
					elFormInput.getParent('.form_cols').getElement('.error_message').set('text', 'Velden niet ingevuld');
					if (strFieldMessage == 'NO_VALID_ZIPCODE') {
						elFormInput.getParent('.form_cols').getElement('.error_message').set('text', 'Geen geldige postcode');
					}
				}
			} else {
				elFormInput.addClass('error');
				if (strFieldMessage == 'NO_VALID_EMAIL_ADDRESS') {
					elErrorMessage.inject(elFormInput, 'after');
					elErrorMessage.set('text', 'Geen geldig emailadres');
				} else if (strFieldMessage == 'EMPTY') {
					elErrorMessage.inject(elFormInput, 'after');
					elErrorMessage.set('text', 'Veld niet ingevuld');
				}
			}
		}
	});
}


/**
 * resetFormFieldErrors
 * Resets form field errors.
 *
 * @author Ralph Meeuws <ralph.meeuws{AT}efocus.nl>
 */
function resetFormFieldErrors(elForm) {
	elForm.getElements('input').combine(elForm.getElements('textarea')).removeClass('error');
	elForm.getElements('.error_message').dispose();
}

