$(document).ready(function() {
	// TRAINING / ONLINE APPLICATION FORM
	// fading in/out the different steps
	//
	var num = 0;
	window['show'] = 'contact_details';
	if ($('div#errors').length > 0) {
		window['show'] = 'errors';
	}
	
	$('div.details')
		.each(function() {
			if ($(this).attr('id') != window['show']) {
				$(this).css('display', 'none');
			}
		})
		.prev('h2').css('cursor','pointer').click(function() {
			if ($(this).next('div.details').css('display') != 'block') {
				$('div.details').hide('fast');
				$(this).next('div.details').show('fast');
			}
		
		})
	;
	
	// BOTH FORMS
	// controlling the date of birth
	//
	var dob = $('#f_dob').css('display', 'none').val();
	if (dob === undefined) {
		dob = 'YYYYMMDD';
	}
	$('#dob_year').css('display', 'inline').css('width','34px').val(dob.substring(0,4)).focus(function() {
		if ($(this).val() == 'YYYY') {
			$(this).val("");
		}
	});
	
	$('#dob_month').css('display', 'inline').css('width','21px').val(dob.substring(4,6)).focus(function() {
		if ($(this).val() == 'MM') {
			$(this).val("");
		}
	});
	
	$('#dob_day').css('display', 'inline').css('width', '21px').val(dob.substring(6,8)).focus(function() {
		if ($(this).val() == 'DD') {
			$(this).val("");
		}
	});
	
	$('#dob_label').attr('for', 'dob_day');
	
	$('#bigform').submit(function() {
		var day = $('#dob_day').val();
		var mon = $('#dob_month').val();
		var yea = $('#dob_year').val();
		
		$('#f_dob').val( yea + mon + day );
		return true;
	});
	
	// TRAINING / ONLINE APPLICATION FORM
	// confirmation that above info is correct otherrwise no submit
	//
	$('#confirm').click(function() {
		if ($(this).attr('checked')) {
			$('#submit').show();
		} else {
			$('#submit').hide();
		}
	});
	
	if ($('#confirm').length == 0) {
		$('#submit').show();
	}
	
	$('.be-hidden').hide();
});

