function show_error(field, msg){
	modal_window({
		message: '<div class="alert alert-danger">' + msg + '</div>',
		title: 'Error in ' + field,
		close: function(){
			$j('#' + field).focus();
			$j('#' + field).parents('.form-group').addClass('has-error');
		}
	});
	
	return false;
}

$j(function(){
	$j('#age').prop('readonly' , true);
	
	$j('#date_naissance-dd, #date_naissance-mm, #date_naissance').change(function(){
		var dob = get_date('date_naissance');
		var today = new Date();
		var age = Math.floor((today - dob) / 1000 / 60 / 60 / 24 / 365.25);
		
		$j('#age').val(age);
	});
	
	$j('#date_naissance').change();
	
});


$j(function(){
	$j('#annees_service').prop('readonly' , true);
	
	$j('#date_recrutement_cp-dd, #date_recrutement_cp-mm, #date_recrutement_cp').change(function(){
		var dor = get_date('date_recrutement_cp');
		var today = new Date();
		var anneeService = Math.floor((today - dor) / 1000 / 60 / 60 / 24 / 365.25);
		
		$j('#anneeService').val(anneeService);
	});
	
	$j('#date_recrutement_cp').change();
	
});
