 $(document).ready(function(){

  $('.contactForm')
  .bootstrapValidator({
    fields: {
      name: {
        validators: {
          notEmpty: {
            message: 'The name is required'
          }
        }
      },
      phone: {
        validators: {
          notEmpty: {
            message: 'The phone is required. '
          },
          stringLength: {
            min: 10,
            max: 10,
            message: 'Enter 10 digit number. '
          },
          regexp: {
            regexp: /^[6789]\d{9}$/i,
            message: 'Enter valid number. '
          },
          callback: {
            message: 'Occurs repeated number.',
            callback: function(value, validator, $field) {

              var fieldNum = ['000000','111111','222222','333333','444444','555555','666666','777777','888888','999999','1234567','2345678','3456789','4567890','3434343','1212121','5656565','9090909','3434343','8989898','987654'];


              for (var i = 0; i < fieldNum.length; i++) {
                if (value.indexOf(fieldNum[i]) > -1) {
                 return {
                  valid: false,
                };
              }
            }
            return {
              valid: true,
            };

            }
          }
        }
      }
    }
  })

        // form submit
        .on('success.form.bv', function(e) {

          // Prevent form submission
          e.preventDefault();
          $.ajax({
            url: "send-mail.php",
            type: "POST",
            data:  new FormData(this),
            contentType: false,
            cache: false,
            processData:false,
            success: function(response) {
                 // alert(response); 

                 if(response.indexOf("success") > -1){
                  // alert('in');
                  swal({
                    title: "Congrats!",
                    text: "Email has been sent successfully",
                    type: "success",
                    showConfirmButton: false,
                    showCancelButton: false,
                    timer: 4000
                  });

                  $('#brochureModal').modal('toggle');

                }else{
                  swal({
                    title: "Oops!",
                    text: "Something went wrong, Please try again.",
                    type: "warning",
                    showConfirmButton: false,
                    showCancelButton: false,
                    timer: 2000
                  });
                }
              }
            });
        });

// onload modal


  $('.onloadContactForm')
  .bootstrapValidator({
    fields: {
      name: {
        validators: {
          notEmpty: {
            message: 'The name is required'
          }
        }
      },
      phone: {
        validators: {
          notEmpty: {
            message: 'The phone is required. '
          },
          stringLength: {
            min: 10,
            max: 10,
            message: 'Enter 10 digit number. '
          },
          regexp: {
            regexp: /^[6789]\d{9}$/i,
            message: 'Enter valid number. '
          },
          callback: {
            message: 'Occurs repeated number.',
            callback: function(value, validator, $field) {

              var fieldNum = ['000000','111111','222222','333333','444444','555555','666666','777777','888888','999999','1234567','2345678','3456789','4567890','3434343','1212121','5656565','9090909','3434343','8989898','987654'];


              for (var i = 0; i < fieldNum.length; i++) {
                if (value.indexOf(fieldNum[i]) > -1) {
                 return {
                  valid: false,
                };
              }
            }
            return {
              valid: true,
            };

            }
          }
        }
      }
    }
  })

        // form submit
        .on('success.form.bv', function(e) {
          
          // Prevent form submission
          e.preventDefault();
          $.ajax({
            url: "send-mail.php",
            type: "POST",
            data:  new FormData(this),
            contentType: false,
            cache: false,
            processData:false,
            success: function(response) {
                 // alert(response); 

                 if(response.indexOf("success") > -1){
                  // alert('in');
                  swal({
                    title: "Congrats!",
                    text: "Email has been sent successfully",
                    type: "success",
                    showConfirmButton: false,
                    showCancelButton: false,
                    timer: 4000
                  });

                  $('#onloadModal').modal('toggle');

                }else{
                  swal({
                    title: "Oops!",
                    text: "Something went wrong, Please try again.",
                    type: "warning",
                    showConfirmButton: false,
                    showCancelButton: false,
                    timer: 2000
                  });

                }
              }
            });
        });

     $(window).on('load',function(){
      setTimeout(function() {
        $('#onloadModal').modal({backdrop: 'static', keyboard: false}); 
      }, 2500);
    });

   });

