function checkForm() {
	// clear validation messages
	$('#validation_message').html('<p>In order to complete your order, the following problems must be corrected:</p>');
	
	// validation
	var errors = new Array();
	
	if ( ! $('#sendtoself').is(':checked') ) {
		if ( ! $("#recipientname").val() ) { errors.push('Please enter the recipient\'s name'); }
		if ( ! $("#recipientstreet1").val() ) { errors.push('Please enter the recipient\'s street address'); }
		if ( ! $("#recipientcity").val() ) { errors.push('Please enter the recipient\'s city'); }
		if ( ! $("#recipientstate").val() ) { errors.push('Please enter the recipient\'s state'); }
		if ( ! $("#recipientzip").val() ) { errors.push('Please enter the recipient\'s zip code'); }
	} else {
		if ( ! $("#recipientname").val() ) { errors.push('Please enter the recipient\'s name'); }
	}

	if ( ! $("#name").val() ) { errors.push('Please enter your name'); }
	if ( ! $("#email").val() ) { errors.push('Please enter your email address'); }
	if ( ! $("#phone").val() ) { errors.push('Please enter your phone number'); }
	if ( ! $("#street1").val() ) { errors.push('Please enter your street address'); }
	if ( ! $("#city").val() ) { errors.push('Please enter your city'); }
	if ( ! $("#state").val() ) { errors.push('Please enter your state'); }
	if ( ! $("#zip").val() ) { errors.push('Please enter your zip code'); }

	if ( ! $("#amount").val() ) { errors.push('Please enter the amount of the gift certificate'); }
	
	if ( ! $('#paybycheck').is(':checked') ) {
		if ( ! $("#creditcard").val() ) { errors.push('Please enter your credit card number'); }
		if ( ! $("#nameoncard").val() ) { errors.push('Please enter your name as it appears on your card'); }
		if ( ! $("#expmonth").val() || $("#expmonth").val() == '' ) { errors.push('Please enter the expiration month from your card'); }
		if ( ! $("#expyear").val() || $("#expyear").val() == '' ) { errors.push('Please enter the expiration year from your card'); }
		if ( ! $("#securitycode").val() ) { errors.push('Please enter the security code from your card'); }
	}
	
	if ( errors.length > 0 ) {
		// write out errors
		var errorList = '<p><ul>';
		for (var error in errors) {
			errorList += '<li>'+errors[error]+'</li>';
		}
		errorList += '</ul></p>';
		$('#validation_message').append(errorList);

		// and show them
		$('#validation_message').show(0);
		$('html,body').animate({scrollTop: $('#validation_message').offset().top - 5}, 1000);
		return false;
	} else {
		// submit form
		document.form.submit();
		return true;
	}
}

$(document).ready( function() {
	// setup checkbox handler
	$('#submitButton').click( function() {
	});
	
	// hide check info
	$('.usingcheck').hide(0);
	
	// setup checkbox handler
	$('#paybycheck').click( function() {
		if ( $(this).is(':checked') ) {
			$('.usingcard').hide(0);
			$('.usingcheck').show(0);
		} else {
			$('.usingcheck').hide(0);
			$('.usingcard').show(0);
		}
	});

	// setup recipient handler
	$('#sendtoself').click( function() {
		if ( $(this).is(':checked') ) {
			$('.recipientInfo').hide(0);
		} else {
			$('.recipientInfo').show(0);
		}
	});

	// hide validation message
	$('#validation_message').hide(0);
	
});
