// JavaScript Document


 function text (str) { return /[0-9_;:'!~?=+<|>]/g.test(str); }
 
 function textandnumber (str) { return /[0-9]/g.test(str); }

   function numeric (str) { return /^[0-9-\+\(\)\s]+z/.test(str + "z"); }

   function mail (str) { return /^[a-z0-9_\.]+@[a-z0-9_\.]+.[a-z]{2,3}$/.test(str); }

   function checkForm ()
      {
      var title;
      var elem;
      var dutyField = "Field is not ";
      var wrongField = "Invalid field value ";
      var check = true;

      function checkError (field, str)
         {
         document.getElementById("alert").innerHTML = str;
         document.forms.preview.field.focus();
         check = false;
         }

      document.getElementById("alert").innerHTML = "";

    //  if (check)
	     {
            elem = document.preview.datePart1.value;
            if (elem == 0) 
            {
               document.preview.datePart1.style.backgroundColor = '#FFAEB9';
               check=false;
            }
            else 
               document.preview.datePart1.style.backgroundColor = 'white';
         }
		 {
            elem = document.preview.datePart2.value;
            if (elem == 0) 
            {
               document.preview.datePart2.style.backgroundColor = '#FFAEB9';
               check=false;
            }
            else 
               document.preview.datePart2.style.backgroundColor = 'white';
         }
		 {
            elem = document.preview.datePart3.value;
            if (elem == 0) 
            {
               document.preview.datePart3.style.backgroundColor = '#FFAEB9';
               check=false;
            }
            else 
               document.preview.datePart3.style.backgroundColor = 'white';
         }
	
	     {
            elem = document.preview.credit_card_type.value;
            if (elem == 0) 
            {
               document.preview.credit_card_type.style.backgroundColor = '#FFAEB9';
               check=false;
            }
            else 
               document.preview.credit_card_type.style.backgroundColor = 'white';
         }
		 {
            elem = document.preview.number_of_passenger.value;
            if (elem == 0) 
            {
               document.preview.number_of_passenger.style.backgroundColor = '#FFAEB9';
               check=false;
            }
            else 
               document.preview.number_of_passenger.style.backgroundColor = 'white';
         }
	
	
         {
            elem = document.preview.puTime1.value;
            if (elem == 0) 
            {
               document.preview.puTime1.style.backgroundColor = '#FFAEB9';
               check=false;
            }
            else 
               document.preview.puTime1.style.backgroundColor = 'white';
         }
		
 
   //     if (check)
         {
            elem = document.preview.puTime2.value;
            if (elem == 0) 
            {
               document.preview.puTime2.style.backgroundColor = '#FFAEB9';
               check=false;
            }
            else 
                document.preview.puTime2.style.backgroundColor = 'white';
         }

    //  if (check)
         {
            title = '"Start Address"';
            elem = document.preview.start_address.value;

            if (elem.length == 0) 
	    {
                document.preview.start_address.style.backgroundColor = '#FFAEB9';
                check=false;
	    }
            else if (textandnumber(elem)) 
            {
                document.preview.start_address.style.backgroundColor = '#FFAEB9';
                check=false;
	    }
            else 
                document.preview.start_address.style.backgroundColor = 'white';
         }




    //  if (check)
         {
            title = '"City"';
            elem = document.preview.city.value;

            if (elem.length == 0) 
	    {
                document.preview.city.style.backgroundColor = '#FFAEB9';
                check=false;
	    }
            else if (text(elem)) 
            {
                document.preview.city.style.backgroundColor = '#FFAEB9';
                check=false;
	    }
            else 
                document.preview.city.style.backgroundColor = 'white';
         }

    // if (check)
         {
            title = '"Zip Code"';
            elem = document.preview.zip_code.value;

            if (elem.length == 0) 
	    {
                document.preview.zip_code.style.backgroundColor = '#FFAEB9';
                check=false;
	    }
            else if (!numeric(elem)) 
            {
                document.preview.zip_code.style.backgroundColor = '#FFAEB9';
                check=false;
	    }
            else 
                document.preview.zip_code.style.backgroundColor = 'white';
         }

   // if (check)
         {
            title = '"Passenger First Name"';
            elem = document.preview.passenger_first_name.value;

            if (elem.length == 0)
	    {
                document.preview.passenger_first_name.style.backgroundColor = '#FFAEB9';
                check=false;
	    }
            else if (text(elem))
            {
                document.preview.passenger_first_name.style.backgroundColor = '#FFAEB9';
                check=false;
	    }
            else 
                document.preview.passenger_first_name.style.backgroundColor = 'white';
         }


    //  if (check)
         {
            title = '"Passenger Last Name"';
            elem = document.preview.passenger_last_name.value;

            if (elem.length == 0) 
	    {
                document.preview.passenger_last_name.style.backgroundColor = '#FFAEB9';
                check=false;
	    }
            else if (text(elem))
            {
                document.preview.passenger_last_name.style.backgroundColor = '#FFAEB9';
                check=false;
	    }
            else 
                document.preview.passenger_last_name.style.backgroundColor = 'white';
         }


    //    if (check)
         {
            title = '"Cellular Phone Number"';
            elem = document.preview.cellular_phone_number.value;

            if (elem.length == 0) 
	    {
                document.preview.cellular_phone_number.style.backgroundColor = '#FFAEB9';
                check=false;
	    }
            else if (!numeric(elem))
            {
                document.preview.cellular_phone_number.style.backgroundColor = '#FFAEB9';
                check=false;
	    }
            else 
                document.preview.cellular_phone_number.style.backgroundColor = 'white';
         }

//if (check)
         {
            title = '"Card Number"';
            elem = document.preview.card_number.value;

            if (elem.length == 0) 
	    {
                document.preview.card_number.style.backgroundColor = '#FFAEB9';
                check=false;
	    }
            else if (!numeric(elem))
            {
                document.preview.card_number.style.backgroundColor = '#FFAEB9';
                check=false;
	    }
            else 
                document.preview.card_number.style.backgroundColor = 'white';
         }
//if (check)
         {
            title = '"Expire"';
            elem = document.preview.expire.value;

            if (elem.length == 0) 
	    {
                document.preview.expire.style.backgroundColor = '#FFAEB9';
                check=false;
	    }
            else if (!numeric(elem))
            {
                document.preview.expire.style.backgroundColor = '#FFAEB9';
                check=false;
	    }
            else 
                document.preview.expire.style.backgroundColor = 'white';
         }
		 
         
  /* if (check)
         {
         title = '"E-mail"';
         elem = document.preview.email_address.value;
         if (elem.length == 0) checkError('email_address', dutyField + title);
         else if (!mail(elem)) checkError('email_address', wrongField + title);
         }
*/
       
      if (check)  { document.preview.submit(); }
       else  document.forms.preview.field.focus();

      return check;
      }

//80939826462
