function check_form() {
if (!document.checkout_form.name.value) {
 alert('One or more mandatory fields are empty in the Shipping Address section. All fields with a orange * are required.');
 return false;
}
if (!document.checkout_form.addy1.value) {
 alert('One or more mandatory fields are empty in the Shipping Address section. All fields with a orange * are required.');
 return false;
}
if (!document.checkout_form.city.value) {
 alert('One or more mandatory fields are empty in the Shipping Address section. All fields with a orange * are required.');
 return false;
}
if (!document.checkout_form.state.value) {
 alert('One or more mandatory fields are empty in the Shipping Address section. All fields with a orange * are required.');
 return false;
}
if (!document.checkout_form.zip.value) {
 alert('One or more mandatory fields are empty in the Shipping Address section. All fields with a orange * are required.');
 return false;
}
if (!document.checkout_form.country.value) {
 alert('One or more mandatory fields are empty in the Shipping Address section. All fields with a orange * are required.');
 return false;
}
if (!document.checkout_form.phone.value) {
 alert('One or more mandatory fields are empty in the Shipping Address section. All fields with a orange * are required.');
 return false;
}

var filter  = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;
var email = document.checkout_form.email.value;
if (!filter.test(email)) {
  alert('You have entered an invalid email address.');
  return false;
}

if (!document.checkout_form.bill_same_as_ship.checked) {
	if (!document.checkout_form.b_name.value) {
	 alert('One or more mandatory fields are empty in the Billing Address section. If the billing address is different from the shipping address, all fields are required.');
	 return false;
	}
	if (!document.checkout_form.b_addy1.value) {
	 alert('One or more mandatory fields are empty in the Billing Address section. If the billing address is different from the shipping address, all fields are required.');
	 return false;
	}
	if (!document.checkout_form.b_city.value) {
	 alert('One or more mandatory fields are empty in the Billing Address section. If the billing address is different from the shipping address, all fields are required.');
	 return false;
	}
	if (!document.checkout_form.b_state.value) {
	 alert('One or more mandatory fields are empty in the Billing Address section. If the billing address is different from the shipping address, all fields are required.');
	 return false;
	}
	if (!document.checkout_form.b_zip.value) {
	 alert('One or more mandatory fields are empty in the Billing Address section. If the billing address is different from the shipping address, all fields are required.');
	 return false;
	}
	if (!document.checkout_form.b_country.value) {
	 alert('One or more mandatory fields are empty in the Billing Address section. If the billing address is different from the shipping address, all fields are required.');
	 return false;
	}
	if (!document.checkout_form.b_phone.value) {
	 alert('One or more mandatory fields are empty in the Billing Address section. If the billing address is different from the shipping address, all fields are required.');
	 return false;
	}
	
	var filter  = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;
	var email = document.checkout_form.b_email.value;
	if (!filter.test(email)) {
	  alert('You have entered an invalid email address in the Billing Address section.');
	  return false;
	}
}
}