$(document).ready(function(){
	// functions to execute every page
	external();
});

function inputDefaults() {
	// toggle title in inputs and textarea
	$("input[title!=''], textarea[title!='']").each(function(index) {
		if ($(this).attr('title')!='' && ($(this).val()=='' || $(this).val()==$(this).attr('title'))) {
			$(this)
				.addClass('instruction')
				.val($(this).attr('title'))
				.focus(function(){
					if ($(this).val()==$(this).attr('title')) {
						$(this)
							.val('')
							.removeClass('instruction');
					}
				})
				.blur(function(){
					if ($(this).val()=='') {
						$(this)
							.val($(this).attr('title'))
							.addClass('instruction');
					}
				});
		}
	});
}

function external() {
	$("a[rel='external']").click(function(){
    	window.open($(this).attr('href'));
    	return false;
    });
}

function initCaptcha(){
	$('#captcha1').bind('loaded.simpleCaptcha', function(){	}).simpleCaptcha({
  		numImages: 4,
  		scriptPath: webroot+'files/simpleCaptcha.php',
  		introText: 'Klik op het juiste figuur: <span class="captchaText"></span>',
  		inputName: 'data[Contact][captchaSelection]'
  	});
}
