function onBrandboxComplete(bbinstance, item, nr) {
	var 	item_title = item.getElement('figcaption').get('html'),
		item_descr = item.getElement('.figdescription').get('html'),
		injectarea = bbinstance.getElement('.overlay .injectarea'),
		injectarea_pagenr = injectarea.getElement('.pagenr'), 
		injectarea_title  = injectarea.getElement('h1'),
		injectarea_descr  = injectarea.getElement('.descr');
	
	injectarea_pagenr.set('html', '0'+nr);
	injectarea_title.set('html', item_title);
	injectarea_descr.set('html', item_descr);
}


window.addEvent('domready', function() {
	new Fx.SmoothScroll({
		offset: { x:0, y:-50},
		transition: 'sine:out'
	});

	
	new Fx.Accordion($$('.faq_question'), $$('.faq_answer'), { display: -1 });


	/* Brandbox */
	$$('.block-brandbox').each(function(brandbox) {
		var gallery = brandbox.getElement('ul.gallery');

		var current_to = 0;
		new Fx.Animate.Fade(gallery, 'li', {
			'interval': 7000,
			'onNavigate': function(from, to){
				current_to = to;
				onBrandboxComplete(brandbox, this.getElement(to), to + 1);
			},
			'onComplete': function() {
				brandbox.getElements('.paging a').removeClass('active');
				brandbox.getElement('.page_'+current_to ).addClass('active');				
			}
		});
	});

	/* gallery_customers */
	var gallery_customers = document.id('gallery_customers');
	if(gallery_customers) {
		gallery_customers = gallery_customers.getElement('ul');
		new Fx.Animate.Scroll(gallery_customers, 'li', { 
			direction: 'top'
		});
	}
	 
	/* gallery_testimonials */
	var gallery_testimonials = document.id('gallery_testimonials');
	if(gallery_testimonials) {
		gallery_testimonials = gallery_testimonials.getElement('ul');
		new Fx.Animate.Scroll(gallery_testimonials, 'li', { 
			direction: 'top'
		});
	}

	/* Active maken van menuitems met een hash */

	var menuHashAnchors = $$('a[href*="#"]');
	menuHashAnchors.each(function(e) {
		if(e.get('href').indexOf($(window).location.hash, 0) > -1 && $(window).location.hash != '') e.addClass('active');
	});
	menuHashAnchors.addEvent('click', function(e){
		menuHashAnchors.removeClass('active');
		this.addClass('active');
	});
});
