/////////////////////////////////////////// BASIC FUNCTIONS, DON'T EDIT ///////////////////////////////////////////

/**
 * Starts executing the initializing functions when either the DOM structure of the page has been loaded ('domready'), or the entire page ('load').
 * 
 * @author CSD (clientsidedevelop0ers[AT]efocus.nl)
 * @uses Mootools 1.2.2 JavaScript Library
 */
window.addEvents({
	'domready': function() {
		initExternalLinks();
		initFAQ();
	},
	'load': function() {
		fixColumnHeights();
		initHomeSlideShow();
	}
});



/**
 * initExternalLinks
 * Opens external links valid in a new window without the target attribute.
 * 
 * @author Ralph Meeuws (ralph.meeuws[AT]efocus.nl)
 * @uses <a href="http://www.efocus.nl/" class="external">eFocus</a>
 */
function initExternalLinks() {
	var arrExternalLinks = $$('a.external');
	if (arrExternalLinks.length == 0) return false;
	
	arrExternalLinks.each(function(elExternalLink) {
		elExternalLink.addEvent('click', function(event) {
			event.stop();
			window.open(this.get('href'));   
		});
	});
}



/**
 * initFAQ
 * Adds an accordion effect to the FAQ lists.
 * 
 * @author Ralph Meeuws (ralph.meeuws[AT]efocus.nl)
 * @return void
 */
function initFAQ() {
	var arrFaqLists = $$('ul.faq');
	if (arrFaqLists.length == 0) return false;
	
	arrFaqLists.each(function(elFaqList) {
		objFaqAccordion = new Accordion(elFaqList.getElements('.question'), elFaqList.getElements('.answer'), {
			display: 0
		});
	});
}



/**
 * fixColumnHeights
 * Makes the height of both columns equal for the vertical line.
 * 
 * @author Ralph Meeuws (ralph.meeuws[AT]efocus.nl)
 * @return void
 */
function fixColumnHeights() {
	if (!$(document.body).getElement('.col_small') || !$(document.body).getElement('.col_medium')) return false;
	
	var arrColumns = [$(document.body).getElement('.col_small'), $(document.body).getElement('.col_medium')];
	var intColumnHeightMax = 0;
	
	arrColumns.each(function(elColumn){
		var intColumnHeight = elColumn.getHeight();
		if (intColumnHeight > intColumnHeightMax) intColumnHeightMax = intColumnHeight;
	});

	arrColumns[0].setStyle('height', intColumnHeightMax);
	arrColumns[1].setStyle('height', 'auto');
}



/**
 * initHomeSlideShow
 * Adds a slideshow to the homepage.
 * 
 * @author Ralph Meeuws (ralph.meeuws[AT]efocus.nl)
 * @return void
 */
function initHomeSlideShow() {
	if (!$(document.body).getElement('.home_slideshow')) return false;
	
	var elHomeSlideShow = $(document.body).getElement('.home_slideshow');
	
	objHomeSlideShow = new EfxBaseSlideShow({
		arrSlides: elHomeSlideShow.getElements('li'),
		intInterval: 4000
	});
}
