jQuery(document).ready(function()
{
	// DOB date picker
    jQuery('.dob').datepicker({
		changeMonth: true,
		changeYear: true,
        yearRange: '1995:2011',
        onSelect: function(dateText, inst) {
        	jQuery('.dob').valid();
        }
	});
	
	// Custom check to make sure camp is selected
	jQuery("#vform").submit(function(){
		checked = false;
		jQuery('.camps-selection').each(function() {
			if(jQuery(this).attr('checked'))
			{
				checked = true;
			}	
		});
		
		if(!checked)
		{
			jQuery('#camp-table').addClass('error-outline');
			jQuery('html, body').scrollTop(0);
			return false;
		}
		else
		{
			jQuery('#camp-table').removeClass('error-outline');
			
			// Disable submit button to prevent duplicate submissions
			//jQuery('input[type=submit]', this).attr('disabled', 'disabled');
		}
	});
	
	// Remove error outline anytime checkbox is clicked
	jQuery('.camps-selection').click(function(){
		jQuery('#camp-table').removeClass('error-outline');
	});
	
	// Force user to accept terms and conditions before proceeding
	jQuery('#buy-now').click(function(){
		if(!jQuery('#accept-terms').is(':checked'))
		{
			alert('Please accept terms and conditions.');
			return false;
		}
	});
	
	// Form validation
	jQuery("#vform").validate();
});
