window.addEvent('domready', function(){
	var hash, scroll = new Fx.Scroll(window, { wheelStops: false, wait: false, duration: 1000, transition: Fx.Transitions.Quad.easeInOut });
	var checkHash = function() { 
		var hash2 = window.location.hash.substring(1)?window.location.hash.substring(1):'start'; 
		if(hash != hash2 && $('a_'+hash2)) { 
			var c = $('a_'+hash2).getCoordinates(); 
			var xy = [c.left-(window.getWidth()-c.width)/2,c.top-(window.getHeight()-c.height)/2]; 
			if(xy[0] < 0) { xy[0] = 0; }
			if(xy[1] < 0) { xy[1] = 0; }
			if(!window.location.hash) { 
				window.scrollTo(xy[0],xy[1]); 
				window.location.hash = '#'+hash2; 
			} 
			else { 
				scroll.start(xy[0],xy[1]); 
			} 
			if(/MSIE (5\.5|6)/.test(navigator.userAgent)) {
				if(xy[0]+window.getWidth() > 2000) { xy[0] = 2000-window.getWidth(); }
				xy[1]+=window.getHeight()-24;
				if(xy[1] > 2000) { xy[1] = 2000-24; }
				$('dashboard').setStyle('position','absolute');
				$('dashboard').setStyle('top',xy[1]+'px');
				$('dashboard').setStyle('left',xy[0]+'px');
				$('dashboard').setStyle('width',window.getWidth()+'px');
			}
			$('dashboard').getElements('a').each(function(a) { 
				if(new RegExp(hash2+'$').test(a.href)) { 
					a.set('tween',{duration:200}).tween('color','#F71206'); 
				} 
				else { 
					a.setStyle('color',''); 
				} 
			}); 
			hash = hash2; 
		}	
	}.periodical(100);
	$$('.block').each(function(b) { b.innerHTML = '<div class="cr ctl"></div><div class="cr ctr"></div><div class="cr cbl"></div><div class="cr cbr"></div><div class="cl clt"></div><div class="cl clr"></div><div class="cl clb"></div><div class="cl cll"></div>'+b.innerHTML; });
});

function addList(form) {
	if(!echeck(form.email.value)) { alert('Het ingevulde e-mailadres is incorrect. Probeert het opnieuw.'); }
	else {
		var req = new Request.HTML({url:'mailinglist.php',evalScripts:false});
		req.addEvent('success', function() { 
			$('form').email.disabled = true;
			$('form').submit.disabled = true;
			$('form').email.value = 'Bedankt!';
			alert('Je hebt je ingeschreven voor de mailinglist. Bedankt!'); 
		});
		req.addEvent('failure', function() { alert('Kan de website niet benaderen. Is je internetverbinding actief?'); });
		var postV = {'add': form.email.value};
		req.post(postV);
	}
	return false;
}
var filledIn = false;
function init(el) {
	if(!filledIn) {
		el.value = '';
		filledIn = true;
	}
}

function echeck(str) {
	var at="@";
	var dot=".";
	var lat=str.indexOf(at);
	var lstr=str.length;
	var ldot=str.indexOf(dot);
	if (str.indexOf(at)==-1){ return false }
	if (str.indexOf(at)==-1 || str.indexOf(at)==0 || str.indexOf(at)==lstr){ return false }
	if (str.indexOf(dot)==-1 || str.indexOf(dot)==0 || str.indexOf(dot)==lstr){ return false }
	if (str.indexOf(at,(lat+1))!=-1){ return false }
	if (str.substring(lat-1,lat)==dot || str.substring(lat+1,lat+2)==dot){ return false }
	if (str.substring(lstr,lstr-1)==dot){ return false }
	if (str.indexOf(dot,(lat+2))==-1){ return false }
	if (str.indexOf(" ")!=-1){ return false }
	return true;
}

function showBio(id) {
	$('a_'+id).style.visibility = 'visible';
	window.location.hash = '#'+id;
}

function vImage(num,init) {
	if(num>0) {
		var img = new Image;
		$('iimgsrc').src = 'img/blank.gif';
		img.onload = function() {
			var x = (window.getWidth()-img.width)/2;
			var y = (window.getHeight()-img.height)/2-20;
			$('icont').setStyles({top: y+'px', left: x+'px'});
			$('iimgsrc').src = img.src, $('iimgsrc').width = img.width, $('iimgsrc').height = img.height;
			$('iimgsrc').alt = num;
			$('ititle').innerHTML = $('xpic'+num).alt;
			$('inext').setStyle('display','none');
			$('iprev').setStyle('display','none');
			$('iview').setStyle('display','block');
			var xy = window.getScroll();
			$('iview').setStyle('left', xy.x+'px');
			$('iview').setStyle('top', xy.y+'px');
		}
		img.src = 'img/fotos/'+num+'.jpg';
	}
	else {
			$('iimgsrc').src = 'img/blank.gif', $('iimgsrc').width = 200, $('iimgsrc').height = 200;
			$('ititle').innerHTML = '';
		}
}

function iClose() {
	$('iimgsrc').src = 'img/blank.gif', $('iimgsrc').width = 200, $('iimgsrc').height = 200;
	$('icont').setStyles({top: ((window.getHeight()-200)/2)-20+'px', left: (window.getWidth()-200)/2+'px'});
	$('ititle').innerHTML = '';
	$('iview').setStyle('display','none');
}
