function formSanityCheck() {
  var okFlagPost=okFlagVoucher=false;
  var bObj=document.getElementsByName("bkPostage");
  for (var i=0; i<bObj.length; i++)
    if (bObj.item(i).checked) okFlagPost=true;
  var voucherCode=checkVoucherValidity();
  okFlagVoucher=!voucherCode;
  if (okFlagPost && okFlagVoucher) return true;
  else {
    if (!okFlagPost)
      alert("Please Select a Postage Option");
    if (!okFlagVoucher) {
      if (voucherCode==1)
        alert("Your Voucher Code is invalid, please enter a valid code or leave the box blank.");
      if (voucherCode==2)
        alert("Your Voucher Code has expired, please enter a new Voucher Code or leave the box blank.");
      if (voucherCode==3)
        alert("Your Voucher Code has already been redeemed, please enter a new Voucher Code or leave the box blank.");
      if (voucherCode==4)
        alert("There has been a website error. Please contact the webmaster of this site, quoting the following error code: BAD_VOUCHER_CHECK_CODE");
    }
  }
  return false;
}

function checkVoucherValidity() {
  xmlObj=window.XMLHttpRequest ? new XMLHttpRequest() : new ActiveXObject("MSXML2.XMLHTTP.3.0");
  xmlObj.open("POST","voucherchk.asp",false);
  xmlObj.setRequestHeader("Content-Type","application/x-www-form-urlencoded");
  xmlObj.send(document.getElementById("bkVoucher").value);
  voucherCode=parseInt(xmlObj.responseText);
  return (isNaN(voucherCode) ? 4 : voucherCode);
}
