
function validate(discount_code) {

  if (discount_code.toLowerCase() == "giftbeat")
   {
   alert("Your discount coupon entitles you to purchase the hardcover book for $20 plus tax and shipping. You may purchase it in either Canadian or US dollars, at your preference. This discount coupon does not apply to the eBook.");
   }

  if (discount_code.toLowerCase() !== "giftbeat")
   {
   alert("I'm sorry.  That discount coupon code is not valid.  Please check your coupon code and try again.  Discount codes do have expiry dates, so the coupon code may be correct but have expired.");
   }

}

function calculateOrder(form) {
  var discount_received = false;

  //alert("form number = " + form.form_number.value + " coupon = " + form.coupon.value);

  if (form.coupon.value == "giftbeat") {
    //alert("discount code is correct");

    if (form.form_number.value == "2") {
      //alert("discount code is valid for product 2");
      form.discount_amount.value = "7.95";
      form.discount_amount2.value = "7.95";
      form.on3.value = "coupon:";
      form.os3.value = "giftbeat";
      discount_received = true;
    }
    else if (form.form_number.value == "4") {
      //alert("discount code is valid for product 4");
      form.discount_amount.value = "4.95";
      form.discount_amount2.value = "4.95";
      form.on3.value = "coupon:";
      form.os3.value = "giftbeat";
      discount_received = true;
    }
  }

  if ((discount_received == false) && (form.coupon.value != "")) {
    alert("The discount coupon you have entered does not apply to this product.");
  }

}
