// JavaScript Document

function textCounter(field, countfield, maxlimit) {
	if (field.value.length > maxlimit){
		field.value = field.value.substring(0, maxlimit);
	}else{
		countfield.value = maxlimit - field.value.length;
	}
}


//jeroen on the road slideshow
window.addEvent('domready',function() {
	if($('mootools_jeroen_on_the_road')){
		/* settings */
		var showDuration = 6000;
		var container = $('mootools_jeroen_on_the_road');
		var artikelen = container.getElements('span');
		if(artikelen.length > 1){
			var currentIndex = 0;
			var interval;
			/* opacity and fade */
			artikelen.each(function(img,i){ 
				if(i > 0) {
					img.set('opacity',0);
				}
			});
			/* worker */
			var show = function() {
				artikelen[currentIndex].fade('out');
				artikelen[currentIndex = currentIndex < artikelen.length - 1 ? currentIndex+1 : 0].fade('in');
			};
			/* start once the page is finished loading */
			interval = show.periodical(showDuration);
		}
	}
});

//jeroen memo slideshow
window.addEvent('domready',function() {
	if($('mootools_jeroen_memo')){
		/* settings */
		var showDuration = 6000;
		var container = $('mootools_jeroen_memo');
		var artikelen = container.getElements('span');
		if(artikelen.length > 1){
			var currentIndex = 0;
			var interval;
			/* opacity and fade */
			artikelen.each(function(img,i){ 
				if(i > 0) {
					img.set('opacity',0);
				}
			});
			/* worker */
			var show = function() {
				artikelen[currentIndex].fade('out');
				artikelen[currentIndex = currentIndex < artikelen.length - 1 ? currentIndex+1 : 0].fade('in');
			};
			/* start once the page is finished loading */
			interval = show.periodical(showDuration);
		}
	}
});

//film wegklikken
window.addEvent('domready',function() {
	if($('mootools_header-film-wegklik')){
		$('mootools_header-film-wegklik').addEvent('click', function(event) {
			streamerStageClick();
		});		
	}	
});

function streamerStageClick(){
	if($$('.mootools_header-flash-film')){
		$$('.mootools_header-flash-film').set('html', '');
		$$('.mootools_header-flash-film').dispose();	
	}
	//document.getElementById('filmpjes-container').removeChild( document.getElementById('filmpjes') );
}

// Load Flash
function flash(swf, w, h)
{
	document.write('<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,29,0" width="'+w+'" height="'+h+'">');
	document.write('<param name="allowScriptAccess" value="always"><param name="wmode" value="transparent"><param name="movie" value="'+swf+'"><embed src="'+swf+'" wmode="transparent" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" width="'+w+'" height="'+h+'"></embed></object>');
}

