// globals
var age = 0;

$('.hide').livequery(function() {
	$(this).hide();
});

// $("input[name='personWillEnroll']:checked").val()) {

$("input[name='personWillEnroll']").livequery('change', function() {
	var answer = $(this).val();
	if (answer == 'yes') {
		if ((age >= 9 && age <= 13) || age == 0) {
			$('#enrollment_question').show();
		}
		$('#enrollment_question2').hide();

	} else {
		if ((age >= 15) || age == 0) {
			$('#enrollment_question2').show();
		}
		$('#enrollment_question').hide();
	}
});

function setInsuranceQuestions() {
	age = $('#member_dob').val();
	if ($("input[name='personWillEnroll']").is(':visible')) {
		$("input[name='personWillEnroll']").attr('checked', false);
	}
	// $("input[name='personWillEnroll']").val('no');
	$('#enrollment_question2').hide();
	$('#enrollment_question').hide();

	if (age >= 18) {
		$('#registration_volunteer_label').show();
		$('#registration_volunteer_choices').show();
	} else {
		$('#registration_volunteer_label').hide();
		$('#registration_volunteer_choices').hide();

	}
	
	// if personWillEnroll is not visible
	// check if we should display coaching question:
	if (!$("input[name='personWillEnroll']").is(':visible')) {
		if (age >= 15) {
			$('#enrollment_question2').show();
		}
	}

	// populateregtypes();
	// $("input[name='personWillEnroll']").trigger('change');

}

$(function() {
    $('.date-picker').datepicker( {
        changeMonth: true,
        changeYear: true,
        showButtonPanel: true,
        dateFormat: 'MM yy',
        onClose: function(dateText, inst) { 
            var month = $("#ui-datepicker-div .ui-datepicker-month :selected").val();
            var year = $("#ui-datepicker-div .ui-datepicker-year :selected").val();
            $(this).datepicker('setDate', new Date(year, month, 1));
        }
    });
});



