function submitContactForm() {
	var errors = [];
	var erroredField = false;

	if ($('#contact_us_name').val().length < 2) {
		errors.push('Please enter your name.');
		if (!erroredField) erroredField = 'name';
	}

	if ($('#contact_us_email').val().length < 2) {
		errors.push('Please enter your e-mail address so that we can get back to you if necessary.');
		if (!erroredField) erroredField = 'email';
	} else if (!$('#contact_us_email').val().match(/^[_a-zA-Z0-9-]+(\.[_a-zA-Z0-9-]+)*@[a-zA-Z0-9-]+(\.[a-zA-Z0-9-]+)*\.(([0-9]{1,3})|([a-zA-Z]{2,3})|(aero|coop|info|museum|name))$/)) {
		errors.push('The e-mail address you entered is not valid.  Please check it is typed correctly and try again.');
		if (!erroredField) erroredField = 'email';
	}

	if ($('#contact_us_comments').val().length < 10) {
		errors.push('Please enter your comments.  This must be at least 10 characters long.');
		if (!erroredField) erroredField = 'comments';
	} else if ($('#contact_us_comments').val().length > 1024) {
		errors.push('Your comment is too long.  Please shorten it to less than 1000 characters and try again.');
		if (!erroredField) erroredField = 'comments';
	}


	if (errors.length > 0) {
		alert(errors.join('\n'));
	} else {
		$.ajax({
			url: '/email_contact.php',
			data: {
				name: $('#contact_us_name').val(),
				email: $('#contact_us_email').val(),
				comments: $('#contact_us_comments').val()
			},
			dataType:'json',
			type:'post',
			error: function() {
				alert('Sorry, but we are unable to receive your comments at this time.  Please try again later.');
			},
			success: function(data) {
				if (data.success) {
					//alert('Thank you for contacting us.  If your comments require a response, we will get back to you as soon as possible.');
					$('#contact_us_rollup').slideUp(250, function() {
						$('#contact_us_thankyou').slideDown(250);
					});
					$('#contact_us_name, #contact_us_email, #contact_us_comments').val('');
				} else {
					alert('Sorry, but we are unable to receive your comments at this time.  Please try again later.');
				}
			}
		});
	}

	return false;
}

function submitNewsletterForm() {
	var errors = [];
	var erroredField = false;

	if ($('#newsletter_name').val().length < 2) {
		errors.push('Please enter your name.');
		if (!erroredField) erroredField = 'name';
	}

	if ($('#newsletter_email').val().length < 2) {
		errors.push('Please enter your e-mail address so that we can get back to you if necessary.');
		if (!erroredField) erroredField = 'email';
	} else if (!$('#newsletter_email').val().match(/^[_a-zA-Z0-9-]+(\.[_a-zA-Z0-9-]+)*@[a-zA-Z0-9-]+(\.[a-zA-Z0-9-]+)*\.(([0-9]{1,3})|([a-zA-Z]{2,3})|(aero|coop|info|museum|name))$/)) {
		errors.push('The e-mail address you entered is not valid.  Please check it is typed correctly and try again.');
		if (!erroredField) erroredField = 'email';
	}

	if (errors.length > 0) {
		alert(errors.join('\n'));
	} else {
		$.ajax({
			url: '/newsletter.php',
			data: {
				name: $('#newsletter_name').val(),
				email: $('#newsletter_email').val()
			},
			error: function() {
				alert('Sorry, but we are unable to sign you up to our newsletter at this time.  Please try again later.');
			},
			dataType:'json',
			type:'post',
			success: function(data) {
				if (data.success) {
					//alert('Thank you for signing up for our newsletter.');
					$('#newsletter_rollup').slideUp(250, function() {
						$('#newsletter_thankyou').slideDown(250);
					});
					$('#newsletter_name, #newsletter_email').val('');
				} else {
					alert('Sorry, but we are unable to sign you up to our newsletter at this time.  Please try again later.');
				}
			}
		});
	}

	return false;
}

$(document).ready(function() {
	$('div.faq_content').hide();

	$('div.faq_category h2').hide();
	$('div.faq h3').click(function() {
		$(this).parent('div.faq').children('div.faq_content').slideToggle(250);
	});
});

