// (c) Windmill - (r) clt 20090625 2000 //

// layer control

function formScheme() {
   if (document.cltForm.authorisation.checked == false) {
      alert("You need to confirm you are 16 or over.");
      document.cltForm.authorisation.focus();
   }
   else {
      document.cltForm.submit();
   }
}

function formOne() {
   var str=document.cltForm.email.value;
   var filter=/^([\w-]+(?:\.[\w-]+)*)@((?:[\w-]+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$/i;

   if (document.cltForm.authorisation.checked == false) {
      alert("You need to check this box to authorise the transaction.");
      document.cltForm.authorisation.focus();
   }
   else if (!document.cltForm.name.value) {
      alert("Please enter your name");
      document.cltForm.name.focus();
   }
   else if (!document.cltForm.address1.value && !document.cltForm.address2.value && !document.cltForm.address3.value && !document.cltForm.address4.value) {
      alert("Please enter your address.");
      document.cltForm.address1.focus();
   }
   else if (!document.cltForm.postcode.value) {
      alert("Please enter your postcode.");
      document.cltForm.postcode.focus();
   }
   else if (!document.cltForm.email.value) {
      alert("Please enter your email address.");
      document.cltForm.email.focus();
   }
   else if (!filter.test(str)) {
      alert("Please enter a valid, working email address.");
      document.cltForm.email.focus();
   }
   else if (!document.cltForm.telephone.value) {
      alert("Please enter your daytime telephone number.");
      document.cltForm.telephone.focus();
   }

   else {
      if (document.cltForm.same_address[0].checked) {
         makeNone('card_address');
      }
      else if (document.cltForm.same_address[1].checked) {
         makeBlock('card_address');
      }
      makeNone('form_one');
      makeBlock('form_two');
   }
}

function formTwo(cltForm) {
   if (document.cltForm.authorisation.checked == false) {
      alert("You need to check this box to authorise the transaction.");
      document.cltForm.authorisation.focus();
   }
   else if (!document.cltForm.cardholder.value) {
      alert("Please enter your name as it appears on your card.");
      document.cltForm.cardholder.focus();
   }
   else if (!document.cltForm.cardnumber.value) {
      alert("Please enter the long number from the middle of your card.");
      document.cltForm.cardnumber.focus();
   }
   else if (document.cltForm.expiry_mm.selectedIndex == 0 || document.cltForm.expiry_mm.selectedIndex == 1) {
      alert("Please enter the expiry date from your card (mm yyyy).");
      document.cltForm.expiry_mm.focus();
   }
   else if (document.cltForm.expiry_yyyy.selectedIndex == 0 || document.cltForm.expiry_yyyy.selectedIndex == 1) {
      alert("Please enter the expiry date from your card (mm yyyy).");
      document.cltForm.expiry_yyyy.focus();
   }
   else if (!document.cltForm.security.value) {
      alert("Please enter the three digit security code from the reverse of your card.");
      document.cltForm.security.focus();
   }
   else if (document.cltForm.same_address[1].checked) {
      if (!document.cltForm.card_address1.value && !document.cltForm.card_address2.value && !document.cltForm.card_address3.value && !document.cltForm.card_address4.value) {
         alert("Please enter your card's billing address.");
         document.cltForm.card_address1.focus();
      }
      else if (!document.cltForm.card_postcode.value) {
         alert("Please enter your postcode.");
         document.cltForm.card_postcode.focus();
      }
      else {
         document.cltForm.submit();
      }
   }

   else {
      document.cltForm.submit();
   }
}

