jQuery(document).ready(function($) {
	
	$('#hr-job-application-form').validate({
		rules: {
			app_convictions: {
				required: "#app_crime_yes:checked"
			},
			app_terminations: {
				required: "#app_terminated_yes:checked"
			}
		}
	});
	
	$('#hr-job-application-hours').hide();
	
	$('.part-time').click(function(){		
		if ($('.part-time:checked').length > 0) {
			$('#hr-job-application-hours').slideDown();
		}
		else {
			$('#hr-job-application-hours').slideUp();
		}
	});
	
	$(".input-date").datepicker();
	
	$('#discoverers-input-submit').click(function() {
		var confirmation = confirm('Are you sure you want to continue to the next step?');
		if(confirmation) { return true; } else { return false; }
	});
	
	// Add more jobes to employment application
	$('#show-hidden-job').click(function(e) {
		e.preventDefault();
		$('#hidden-jobs .hidden-job:first').slideDown('slow');
		$('#hidden-jobs .hidden-job:first').insertBefore('#hidden-jobs');
		if($('#hidden-jobs .hidden-job:first').length == 0) { $(this).remove(); }
	});
	
	// Add more schools to employment application
	$('#show-hidden-school').click(function(e) {
		e.preventDefault();
		$('#hidden-schools').after(this).slideDown('slow');
		$(this).remove();
	});
	
	// Add more licenses to employment application
	$('#show-hidden-licenses').click(function(e) {
		e.preventDefault();
		$('#hidden-licenses .hidden-license:first').slideDown('slow');
		$('#hidden-licenses .hidden-license:first').insertBefore('#hidden-licenses');
		if($('#hidden-licenses .hidden-license:first').length == 0) { $(this).remove(); }
	});
	
	// Reveal text input if 'other' is selected for position applying for
	$('#app_position_applying_for_other_name').css('display', 'none'); // Hide it first
	$('#app_position_applying_for_other').change(function() {
		if ($("#app_position_applying_for_other:checked").val()) {
				$('#app_position_applying_for_other_name').show('slow');
		} else {
			$('#app_position_applying_for_other_name').hide('slow');
		}
	});
	
	
})


