/**
 * Functions.js - Bootstrap for all Javascript functionality
 * 
 * @author  Webstores <info at webstores dot nl>
 *           Copyright (c) Webstores internet totaalbureau <http://www.webstores.nl/>
 */

addEvent(window, 'load', function() {
	if($('fontsizer')) {
		FontSizer.initialize(['middle']);
	}
	if($('story-scroller')) {
		var carousel = new Carousel($('story-scroller'), $$('.slide'), $$('a.carousel-control'), {
			auto: true,
			frequency: 8
		});
	}
	if($('accordion')) {
		var acc = new accordion('accordion');
		acc.activate($$('.accordion_toggle')[0]);
	}
	if($('accordion_closed')) {
		var acc = new accordion('accordion_closed');
		acc.activate($$('.accordion_toggle')[0]);
	}
	if($('uitvaartwaardemeter')){
		addEvent($('uitvaartwaardemeter'), 'click', function(e) {
			stopEvent(e);
			myLightWindow.activateWindow({
				href: 'http://www.uitvaartlabel.nl/meter/', 
				title: 'Uitvaartwaardemeter', 
				width: 940,
				height: 430
			});
		});
	}
	if($('vacatures-lightwindow')){
		addEvent($('vacatures-lightwindow'), 'click', function(e) {
			stopEvent(e);
			myLightWindow.activateWindow({
				href: 'http://www.asrnederland.nl/category/18/vacatures/', 
				title: 'Vacatures Ardanta', 
				width: 1000,
				height: 430
			});
		});
	}
	if($('zip-button')){
		addEvent($('zip-button'), 'click', function(e) {
			stopEvent(e);
			$('zip-check-form').submit();
		});
	}
	if($('zip-num')){
		addEvent($('zip-num'), 'keyup', function(e) {
			if($('zip-num').value.length == 4 && $('zip-char')){
				$('zip-char').focus();
			}
		});
	}
	toggleValue('search', 'focus');
	toggleValue('zip-num', 'focus');
	toggleValue('zip-char', 'focus');
});
