window.addEvent('domready',	function() {
	if($('cmslink')) {
		$('cmslink').setStyle('cursor', 'pointer');
		$('cmslink').addEvent('click', function() {
			window.open('http://cms.depoort.nl/index.php?id=114','CMS','status=no,toolbar=no,width=300,height=120');
		});
	}
	
	if($('emaillink')) {
		$('emaillink').setStyle('cursor', 'pointer');
		$('emaillink').addEvent('click', function() {
			var hostname = location.hostname;
			if(hostname.match(/kbs/)) {
				location.href = 'mailto:kbs@kbssneek.nl';
			}
			else if(hostname.match(/bts/)) {
				location.href = 'mailto:bts@btssneek.nl';
			}
		});
	}
	
	if($('contactformulier')) {
//		var qs = window.location.search.substr(1).parseQueryString();
//		if($defined(qs.debug)) {}
		var verzend = $('contactformulier').getElement('input[type=submit]');
		if(verzend) {
			verzend.addEvent('click', function(e) {
				var ok = true;
				var required = $('contactformulier').getElement('input[name=required]');
				if(required) {
					var messages = new Array();
					$each(required.get('value').split(','), function(line, index) {
						var data = line.split(':');
						if(data.length == 2) {
							var el = $('contactformulier').getElement('[name='+data[0]+']');
							if(el && el.get('value').length == 0) {
								messages.push(data[1]);
							}
						}
					});
					
					if(messages.length > 0) {
						ok = false;
						alert('U bent vergeten de volgende gegevens in te vullen: \n\n  - '+ messages.join('\n  - ') +'');
					}
				}
				if(!ok) {
					e.stop();
				}
			});
		}
	}
});
