$(function() {
	$('#donation')
		.validate();
	$('#csa_membership')
		.validate();
	$('#information')
		.validate();
	$('#cno_registration')
		.validate();
		
/*** Chefs' Night Out page ***/

	$('#company_info').hide();
	
	$('#yes').click(function()
	{
		$('#company_info').slideDown();
		$('#company_info input').attr('class', 'required');
	});
	
	$('#no').click(function()
	{
		$('#company_info').slideUp();
		$('#company_info input').attr('class', '');
	});

/*** Online donation page ***/

	$('#tribute_box').hide();
	$('#shared_box').hide();
	$('#card_info').hide();
		
	$("#other_amount").focus(function()
	{
		if (this.value == this.defaultValue) {
			this.value = '';
		}
		$('#amount_other').attr('checked', 'checked');
	}).blur(function()
	{
		if (!this.value.length) {
			this.value = this.defaultValue;
		}
	});
	
	$('#amount_other').click(function() {
		$('#other_amount').focus();
	});

    $('#tribute_question').click(function() {
        if ($('#tribute_question:checked').val() == 'yes') {
            $('#tribute_box').slideDown();
        } else {
            $('#tribute_box').slideUp();
        }
	});

    $('#tribute_card').click(function() {
        if ($('#tribute_card:checked').val() == 'yes') {
            $('#card_info').slideDown();
        } else {
            $('#card_info').slideUp();
        }
	});

/*** CSA membership page ***/

	$('#one_lump_sum').attr('disabled', '');
	$('#lump_amount').attr('disabled', '');
	$('#installments').attr('disabled', '');
	$('#monthly_amount').attr('disabled', '');

	$('#lump_amount').focus(function() {
		$('#one_lump_sum').attr('checked', 'checked');
	}).change(function() {
		$('#amount').attr('value', $(this).attr('value'));
	});
	
	$('#monthly_amount').focus(function() {
		$('#installments').attr('checked', 'checked');
	}).change(function() {
		$('#amount').attr('value', $(this).attr('value'));
	});

    $('#shared_box_question').click(function() {
        if ($('#shared_box_question:checked').val() == 'yes') {
            $('#shared_box').slideDown();
        } else {
            $('#shared_box').slideUp();
        }
	});

});
