function updateQuantity() {
  document.theform.action.value='updatequantity';
  document.theform.submit();
}
function validateOrder () {
  if(document.theform.contactname.value.length < 1) {
    alert("Contact name required");
    document.theform.contactname.focus();
    return false;
  }
  else if(document.theform.companyname.value.length < 1) {
    alert("Company required");
    document.theform.companyname.focus();
    return false;
  }
  else if(document.theform.address.value.length < 1) {
    alert("Address required");
    document.theform.address.focus();
    return false;
  }
  else if(document.theform.city.value.length < 1) {
    alert("City required");
    document.theform.city.focus();
    return false;
  }
  else if(document.theform.postalcode.value.length < 1) {
    alert("Postal code required");
    document.theform.postalcode.focus();
    return false;
  }
  else if(document.theform.phone.value.length < 1) {
    alert("Phone required");
    document.theform.phone.focus();
    return false;
  }
  else if(document.theform.email.value.length < 1) {
    alert("E-mail required");
    document.theform.email.focus();
    return false;
  }
  //validate shipping fields
  if(!document.theform.shiptobilladdress.checked) {
    if(document.theform.shiptocontactname.value.length < 1) {
      alert("Shipping contact name required");
      document.theform.shiptocontactname.focus();
      return false;
    }
    else if(document.theform.shiptocompanyname.value.length < 1) {
      alert("Shipping company required");
      document.theform.shiptocompanyname.focus();
      return false;
    }
    else if(document.theform.shiptoaddress.value.length < 1) {
      alert("Shipping address required");
      document.theform.shiptoaddress.focus();
      return false;
    }
    else if(document.theform.shiptocity.value.length < 1) {
      alert("Shipping city required");
      document.theform.shiptocity.focus();
      return false;
    }
    else if(document.theform.shiptopostalcode.value.length < 1) {
      alert("Shipping postal code required");
      document.theform.shiptopostalcode.focus();
      return false;
    }
    else if(document.theform.shiptophone.value.length < 1) {
      alert("Shipping phone required");
      document.theform.shiptophone.focus();
      return false;
    }
  }
  return true;
}

function changeShipping() {
  e = document.getElementById('shipto');
  if(document.theform.shiptobilladdress.checked) {
    e.style.display = 'none';
  }
  else {
    e.style.display = '';
  }
}