window.addEvent('domready', function() {
	
	if ($chk($('AanmeldForm'))) {
		formcheck = new FormCheck('AanmeldForm');
	}
	
	if ($chk($('voorstelling-functie'))) {
		if ($('voorstelling-functie').get('value') == 'Anders: ') {
			$('voorstelling-anders-cont').setStyle('display', 'block');
			$('voorstelling-anders').addClass("validate['required']");
			formcheck.register($('voorstelling-anders'));
		}
		$('voorstelling-functie').addEvent('change', function() {
			if (this.value == 'Anders: ') {
				$('voorstelling-anders-cont').setStyle('display', 'block');
				$('voorstelling-anders').addClass("validate['required']");
				//formcheck.register($('voorstelling-anders'));
			} else {
				$('voorstelling-anders').removeClass("validate['required']");
				//formcheck.dispose($('voorstelling-anders'));
				$('voorstelling-anders-cont').setStyle('display', 'none');
			}
		});
	}
	
	if ($chk($('voorstelling-regio')) && $chk($('voorstelling-datum'))) {
		if ($('voorstelling-regio').get('value') != '') {
			$('voorstelling-datum').empty();
			if ($chk(voorstelling[$('voorstelling-regio').get('value')])) {
				new Element('option', {text: 'Maak een keuze:', value: ''}).inject('voorstelling-datum');

				for (var j = 0; j < voorstelling.length; j++) {
					for (var i = 0; i < voorstelling[j].length; i++) {
						if (voorstelling[j][i][3] != '') {
							new Element('optgroup', {label: voorstelling[j][i][3]}).inject('voorstelling-datum');
						} 
						new Element('option', {text: voorstelling[j][i][1]+' -- '+voorstelling[j][i][2], value: voorstelling[j][i][0]}).inject('voorstelling-datum');
					};
				}
			} else {
				new Element('option', {text: 'Er zijn geen voorstellingen meer beschikbaar', value: ''}).inject('voorstelling-datum');
			}
		}
		$('voorstelling-regio').addEvent('change', function() {
			if (this.get('value') != '') {
				$('voorstelling-datum').empty();
				if ($chk(voorstelling[this.value])) {
					new Element('option', {text: 'Maak een keuze:', value: ''}).inject('voorstelling-datum');
					for (var j = 0; j < voorstelling.length; j++) {
						for (var i = 0; i < voorstelling[j].length; i++) {
							if (voorstelling[j][i][3] != '') {
								new Element('optgroup', {label: voorstelling[j][i][3]}).inject('voorstelling-datum');
							} 
							new Element('option', {text: voorstelling[j][i][1]+' -- '+voorstelling[j][i][2], value: voorstelling[j][i][0]}).inject('voorstelling-datum');
						};
					}
				} else {
					new Element('option', {text: 'Er zijn geen voorstellingen meer beschikbaar', value: ''}).inject('voorstelling-datum');
				}
			}
			$('plaats').set('value', this.getSelected().getProperty('html'));
		});
	}
	
	if ($chk($('tourForm'))) {
		new DatePicker('.gebdat', { 
			allowEmpty: true,
			format: 'Y-m-d',
			startView: 'decades',
			pickerClass: 'datepicker_vista',
			days: ['Zondag', 'Maandag', 'Dinsdag', 'Woensdag', 'Donderdag', 'Vrijdag', 'Zaterdag'],
			months: ['Januari', 'Februari', 'Maart', 'April', 'Mei', 'Juni', 'Juli', 'Augustus', 'September', 'October', 'November', 'December'],
			inputOutputFormat: 'Y-m-d'
		});
		new FormCheck('tourForm');
	}
	
	if ($chk($$('div.gallery-thumb'))) {
		$$('div.gallery-thumb').each(function(el) {
			el.set('opacity', .75);
		}); 
		$$('div.gallery-thumb').addEvents({
			'mouseover' : function () { this.set('opacity', 1); },
			'mouseout' : function () { this.set('opacity', .75); }
		});
	}
	
	if ($chk($('autocomplete'))) {
		new SelectAutocompleter('autocomplete');
	}
	
	if ($chk($('accordion'))) {
		var myAccordion = new Accordion($('accordion'), 'h3.toggler', 'div.element', {
			opacity: false,
			alwaysHide: true,
			display: -1,
			onActive: function(toggler, element){
				toggler.setStyle('color', '#96bf0d');
				toggler.setStyle('background-image', 'url(assets/templates/wecycle_200909/images/ico-accordeon-min.gif)');
				toggler.setStyle('background-repeat', 'no-repeat');
				toggler.setStyle('background-position', 'left 0');
			},
			onBackground: function(toggler, element){
				toggler.setStyle('color', '#96bf0d');
				toggler.setStyle('background-image', 'url(assets/templates/wecycle_200909/images/ico-accordeon-plus.gif)');
				toggler.setStyle('background-repeat', 'no-repeat');
				toggler.setStyle('background-position', 'left 0');
			}
		});
	}
		
	var obj = new Swiff('assets/templates/wecycle_200909/flash/logo-animatie.swf', {
		id: 'homepage_logo',
		width: 157,
		height: 42,
		container: $('logo'),
		params: {
			quality: 'high',
			wmode: 'transparent',
			swfversion: '9.0.45.0'
		}
	});
	
	if ($chk($('middle-home'))) {
		var obj = new Swiff(swf_homepage, {
			id: 'homepage_movie',
			width: 1003,
			height: 463,
			container: $('middle-home'),
			params: {
				quality: 'high',
				wmode: 'transparent',
				swfversion: '9.0.45.0'
			}
		});
	}
	
	if ($chk($('content-movie'))) {
		var obj = new Swiff(swf_content, {
			id: 'content_movie',
			width: 159,
			height: 397,
			container: $('content-movie'),
			params: {
				quality: 'high',
				wmode: 'opaque',
				swfversion: '9.0.45.0'
			}
		});
	}
	
	loadSIFR();
	
});

function getStraten(item)
{
	var myRequest = new Request({
		url: 'index.php',
		method: 'get',
		async: false, 
		noCache: true,
		onFailure: function() {
			$('milieustraten-cont').set('html', '<br /><br /><br />Er zijn geen milieustraten gevonden gegevens');
		},
		onComplete: function(txt, xml) { 
			$('milieustraten-cont').set('html', txt);
		}
	}).send('id='+cid+'&milieu-gemeente='+item);
}

function loadSIFR() {
	if(typeof sIFR == "function") 
	{
		sIFR.replaceElement(named({
			sSelector:"li.mainmenu-item", 
			sFlashSrc:"assets/templates/wecycle_200909/flash/titles.swf", 
			sColor:"#FFFFFF", 
			sLinkColor:"#FFFFFF", 
			sBgColor:"#0055A5", 
			sHoverColor:"#CBDF86", 
			nPaddingTop:0, 
			nPaddingBottom:0, 
			sWmode: "transparent"
		}));
		
		/*
		sIFR.replaceElement(named({
			sSelector:"li.submenu-item", 
			sFlashSrc:"assets/templates/wecycle_200909/flash/titles.swf", 
			sColor:"#FFFFFF", 
			sLinkColor:"#FFFFFF", 
			sBgColor:"#0055A5", 
			sHoverColor:"#CBDF86", 
			nPaddingTop:0, 
			nPaddingBottom:0, 
			sWmode: "transparent"
		}));
		*/
		
		sIFR.replaceElement(named({
			sSelector:"h1", 
			sFlashSrc:"assets/templates/wecycle_200909/flash/titles.swf", 
			sColor:"#3F3855"
		}));
		
		
		/*
		sIFR.replaceElement(named({
			sSelector:"div#footer ul li", 
			sFlashSrc:"assets/templates/wecycle_200909/flash/titles.swf", 
			sColor:"#FFFFFF", 
			sLinkColor:"#FFFFFF", 
			sBgColor:"#0055A5", 
			sHoverColor:"#CBDF86", 
			nPaddingTop:0, 
			nPaddingBottom:0, 
			sWmode: "transparent"
		}));
		*/
				
		// This is the older, ordered syntax
		//sIFR.replaceElement("h6", "tradegothic.swf", "#000000", null, null, null, 0, 0, 0, 0, null);
	};
}