
 <script language="JavaScript">

  	function CheckOrderForm1(form) {

      if (form.clientname.value == "") {

  			alert('Please give us your name!');

  			form.clientname.focus();

  			return false;

  		}

      if (form.clientaddress1.value == "") {

  			alert('Please give us your address!');

  			form.clientaddress1.focus();

  			return false;

  		}

      if (form.clientpostcode.value == "") {

  			alert('Please give us your postcode!');

  			form.clientpostcode.focus();

  			return false;

  		}

      if (form.clientemail.value == "") {

  			alert('Please give us your email address!');

  			form.clientemail.focus();

  			return false;

  		}



      if (form.imagetype1.value == "0") {

  			alert('Please tell us how you will get the image to us');

  			form.imagetype1.focus();

  			return false;

  		}

      if (form.imagesize1.value == 0) {

  			alert('Please choose an image size for image #1');

  			form.imagesize1.focus();

  			return false;

  		}

      if (form.qty1.value == 0) {

  			alert('Please choose how many you would like for image #1');

  			form.qty1.focus();

  			return false;

  		}

      if (form.frametype1.value == 0) {

  			alert('Please choose what kind of frame you would like for image #1');

  			form.frametype1.focus();

  			return false;

  		}

      if (form.colourtype1.value == 0) {

  			alert('Please choose what colour option you would like for image #1');

  			form.colourtype1.focus();

  			return false;

  		}



      if (form.imagetype2.value != "0") {

         if (form.imagesize2.value == 0) {

    			alert('Please choose an image size for image #2');

    			form.imagesize2.focus();

    			return false;

    		}

        if (form.qty2.value == 0) {

    			alert('Please choose how many you would like for image #2');

    			form.qty2.focus();

    			return false;

    		}

        if (form.frametype2.value == 0) {

    			alert('Please choose what kind of frame you would like for image #2');

    			form.frametype2.focus();

    			return false;

    		}

        if (form.colourtype2.value == 0) {

    			alert('Please choose what colour option you would like for image #2');

    			form.colourtype2.focus();

    			return false;

    		}

      }



      if (form.imagetype3.value != "0") {

         if (form.imagesize3.value == 0) {

    			alert('Please choose an image size for image #3');

    			form.imagesize3.focus();

    			return false;

    		}

        if (form.qty3.value == 0) {

    			alert('Please choose how many you would like for image #3');

    			form.qty3.focus();

    			return false;

    		}

        if (form.frametype3.value == 0) {

    			alert('Please choose what kind of frame you would like for image #3');

    			form.frametype3.focus();

    			return false;

    		}

        if (form.colourtype3.value == 0) {

    			alert('Please choose what colour option you would like for image #3');

    			form.colourtype3.focus();

    			return false;

    		}

      }



      if (form.imagetype4.value != "0") {

         if (form.imagesize4.value == 0) {

    			alert('Please choose an image size for image #4');

    			form.imagesize4.focus();

    			return false;

    		}

        if (form.qty4.value == 0) {

    			alert('Please choose how many you would like for image #4');

    			form.qty4.focus();

    			return false;

    		}

        if (form.frametype4.value == 0) {

    			alert('Please choose what kind of frame you would like for image #4');

    			form.frametype4.focus();

    			return false;

    		}

        if (form.colourtype4.value == 0) {

    			alert('Please choose what colour option you would like for image #4');

    			form.colourtype4.focus();

    			return false;

    		}

      }



      if (form.imagetype5.value != "0") {

         if (form.imagesize5.value == 0) {

    			alert('Please choose an image size for image #5');

    			form.imagesize5.focus();

    			return false;

    		}

        if (form.qty5.value == 0) {

    			alert('Please choose how many you would like for image #5');

    			form.qty5.focus();

    			return false;

    		}

        if (form.frametype5.value == 0) {

    			alert('Please choose what kind of frame you would like for image #5');

    			form.frametype5.focus();

    			return false;

    		}

        if (form.colourtype5.value == 0) {

    			alert('Please choose what colour option you would like for image #5');

    			form.colourtype5.focus();

    			return false;

    		}

      }



  		return true;

  	}





	function verify_ccard(inNumber, type) {

		// returns 0 if valid, positive number if invalid.



		//alert(inNumber);

		//alert(type);



        total = 1*0;

        tmp = 1*0;



        number = "";



        // make sure there are only numbers in the string...

        for(i = 0; i < inNumber.length; i++)

        {

		    if(inNumber.charAt(i) >= "0" && inNumber.charAt(i) <= "9")

                {

                        number = number + inNumber.charAt(i);

                }

        }



        if(number.length < 13) return 10; // too short for anything



        first = "" + number.charAt(0);

        second = "" + number.charAt(1);

        third = "" + number.charAt(2);

        firstTwo = first + second;

        firstFour = firstTwo + third + number.charAt(3);



        if (type == "MC")

        {

                if(first != "5" || second < "1" || second > "5")

                        return 11;// invalid Mastercard prefix

                if(number.length != 16)

                        return 21;

        }

        else if(type == "VISA")

        {

                if(first != "4")

                        return 12;// invalid Visa prefix

                if(number.length != 13 && number.length != 16)

                        return 22;

        }

        else if(type == "AMEX")

        {

                if(first != "3" || (second != "4" && second != "7"))

                        return 13;// invalid American Express Prefix

                if(number.length != 15)

                        return 23;

        }

        else if(type == "DISC")

        {

                        if(firstFour != "6011")

                                return 14;// invalid prefix.

                        if(number.length != 16)

                                return 24;

        }

        else if(type == "DCCB")

        {

                if(firstTwo != "36"

                        && firstTwo != "38"

                        && (firstTwo != "30" ||

                                (third < "0" || third > "5")))

                {

                        return 15;

                }

                if(number.length != 14)

                        return 25;

        }

        else if(type == "enRoute")

        {

                if(firstFour != "2014"

                        && firstFour != "2149")

                        return 16;// invalid enRoute card

                if(number.length != 15)

                        return 26;

		return 0; // no check sum calculation needed

        }

        else if(type == "JCB")

        {

                if(firstFour != "2131"

                        && firstFour != "1800"

                        && (first != "3") )

                        return 17;

                if(number.length != 16 && first =="3")

                        return 27;

                if(number.length != 15 && first != "3")

                        return 28;

        }



        // now check the credit card suffix and length vs. the type





         // do the check sum

        for(loc = number.length - 2; loc >= 0; loc -= 2)

        {

                total += 1 * number.charAt(loc +1);

                tmp = number.charAt(loc) * 2;

		if(tmp > 9) total += 1;

		total += tmp%10;

        }



		if(number.length % 2 > 0)

		total += 1 * number.charAt(0);





        return (total % 10);

	}



	function confirmCard(CardNumber, CardType) {

		//alert(CardType);

        errorStrings = new Array(

                "Hee Hee.  No error here!", //0

                "Check sum failed", //1

                "Check sum failed", //2

                "Check sum failed", //3

                "Check sum failed", //4

                "Check sum failed", //5

                "Check sum failed", //6

                "Check sum failed", //7

                "Check sum failed", //8

                "Check sum failed", //9

                "Number of digits must be greater than 12", //10

                "Invalid Master Card Prefix", //11

                "Invalid Visa Prefix", //12

                "Invalid American Express Prefix", //13

                "Invalid Discover Prefix", //14

                "Invalid Diner's Club/Carte Blanche Prefix", //15

                "Invalid enRoute Prefix", //16

                "Invalid JCB Prefix", //17

                "Why are you reading my source?", //18

                "Are you just a glutton for punishment?", //19

                "Insert comment here.", //20

                "Number of digits must be 16 for Master Card", //21

                "Number of digits must be 13 or 16 for Visa", //22

                "Number of digits must be 15 for American Express", //23

                "Number of digits must be 16 for Discover ", //24

                "Number of digits must be 14 for Diner's Club/Carte Blanche", //25

                "Number of digits must be 15 for enRoute", //26

                "Number of digits must be 16 for JCB with this prefix", //27

                "Number of digits must be 15 for JCB with this prefix") //28



        if ((reason = verify_ccard(CardNumber, CardType)) == 0) {

			//alert('succeeded!');

			return 0;

			}

        else {

			//alert(reason);

            return 1;

			}

	}



  function checkValidation ( addressField ) {

      if ( stringEmpty ( addressField.value ) )

          alert ( "Error! There is no E-Mail address entered" );

      else if ( noAtSign ( addressField.value ) )

          alert ( "Error! The E-Mail address does not contain an '@' character" );

      else if ( nothingBeforeAt ( addressField.value ) )

          alert ( "Error! An E-Mail address must contain at least one character before the '@' character" );

      else if ( noLeftBracket ( addressField.value ) )

          alert ( "Error! The E-Mail address contains a right square bracket ']',\nbut no corresponding left square bracket '['" );

      else if ( noRightBracket ( addressField.value ) )

          alert ( "Error! The E-Mail address contains a left square bracket '[',\nbut no corresponding right square bracket ']'" );

      else if ( noValidPeriod ( addressField.value ) )

          alert ( "Error! An E-Mail address must contain a period ('.') character" );

      else if ( noValidSuffix ( addressField.value ) )

          alert ( "Error! An E-Mail address must contain a two or three character suffix" );

      else

          return (true);



      return ( false );

  }



  function linkCheckValidation ( formField ) {

      if ( checkValidation ( formField ) == true ) {

          alert ( 'E-Mail Address Validates OK' );

      }



      return ( false );

  }



  function stringEmpty ( address ) {

      // CHECK THAT THE STRING IS NOT EMPTY

      if ( address.length < 1 ) {

          return ( true );

      } else {

          return ( false );

      }

  }



  function noAtSign ( address ) {

      // CHECK THAT THERE IS AN '@' CHARACTER IN THE STRING

      if ( address.indexOf ( '@', 0 ) == -1 ) {

          return ( true )

      } else {

          return ( false );

      }

  }



  function nothingBeforeAt ( address ) {

      // CHECK THERE IS AT LEAST ONE CHARACTER BEFORE THE '@' CHARACTER

      if ( address.indexOf ( '@', 0 ) < 1 ) {

          return ( true )

      } else {

          return ( false );

      }

  }



  function noLeftBracket ( address ) {

      // IF EMAIL ADDRESS IN FORM 'user@[255,255,255,0]', THEN CHECK FOR LEFT BRACKET

      if ( address.indexOf ( '[', 0 ) == -1 && address.charAt ( address.length - 1 ) == ']' ) {

          return ( true )

      } else {

          return ( false );

      }

  }



  function noRightBracket ( address ) {

      // IF EMAIL ADDRESS IN FORM 'user@[255,255,255,0]', THEN CHECK FOR RIGHT BRACKET

      if ( address.indexOf ( '[', 0 ) > -1 && address.charAt ( address.length - 1 ) != ']' ) {

          return ( true );

      } else {

          return ( false );

      }

  }



  function noValidPeriod ( address ) {

      // IF EMAIL ADDRESS IN FORM 'user@[255,255,255,0]', THEN WE ARE NOT INTERESTED

      if ( address.indexOf ( '@', 0 ) > 1 && address.charAt ( address.length - 1 ) == ']' )

          return ( false );



      // CHECK THAT THERE IS AT LEAST ONE PERIOD IN THE STRING

      if ( address.indexOf ( '.', 0 ) == -1 )

          return ( true );



      return ( false );

  }



  function noValidSuffix ( address ) {

      // IF EMAIL ADDRESS IN FORM 'user@[255,255,255,0]', THEN WE ARE NOT INTERESTED

      if ( address.indexOf ( '@', 0 ) > 1 && address.charAt ( address.length - 1 ) == ']' )

          return ( false );



      // CHECK THAT THERE IS A TWO OR THREE CHARACTER SUFFIX AFTER THE LAST PERIOD

      var len = address.length;

      var pos = address.lastIndexOf ( '.', len - 1 ) + 1;

      if ( ( len - pos ) < 2 || ( len - pos ) > 3 ) {

          return ( true );

      } else {

          return ( false );

      }

  }

  </script>
