$(function(){
	
	// When the contact select box changes
	// either display or hide the optional contact area
	
	$("#feedback_submit").validate({
		rules: {
			email: {
 				required: true,
				email: true
			},
			telephone: {
				required: true,
				minlength: 8,
				digits: true
			}
		}
	});
	
	
	$('#contact_option').change(function(){
		options()
	})
	
	if($('#contact_option').val() == "yes"){
		options()
	}
	
})

function options(){
	if($('#contact_option').val() == "yes"){
		$('.optional').show()
		
		$('#contact_day, #contact_time').addClass("required")
	}
	else{
		$('.optional').hide()
		
		$('#contact_day, #contact_time').removeClass("required")
	}
}
