
$(document).ready(function () {

	$(".button1").click(function(){
	  $(".video2").hide();
	  $(".video1").show();
	});

	$(".button2").click(function(){
	  $(".video1").hide();
	  $(".video2").show();
	});


   $(".Dubai_add").click(function(){

      var x = document.getElementById("Dubai");
      if (x.style.display === "none") {
        x.style.display = "block";
      } else {
        x.style.display = "none";
      }

  });
   $(".AbuDhabi_add").click(function(){

      var x = document.getElementById("AbuDhabi");
      if (x.style.display === "none") {
        x.style.display = "block";
      } else {
        x.style.display = "none";
      }

  });
  $(".Sharjah_add").click(function(){

      var x = document.getElementById("Sharjah");
      if (x.style.display === "none") {
        x.style.display = "block";
      } else {
        x.style.display = "none";
      }

  });
    $(".Ajman_add").click(function(){

      var x = document.getElementById("Ajman");
      if (x.style.display === "none") {
        x.style.display = "block";
      } else {
        x.style.display = "none";
      }

  });
  $(".RasAlKhaimah_add").click(function(){

      var x = document.getElementById("RasAlKhaimah");
      if (x.style.display === "none") {
        x.style.display = "block";
      } else {
        x.style.display = "none";
      }

  });
  $(".UmmAlQuwainMarina_add").click(function(){

      var x = document.getElementById("UmmAlQuwainMarina");
      if (x.style.display === "none") {
        x.style.display = "block";
      } else {
        x.style.display = "none";
      }

  });
  $(".AlFujayrah_add").click(function(){

      var x = document.getElementById("AlFujayrah");
      if (x.style.display === "none") {
        x.style.display = "block";
      } else {
        x.style.display = "none";
      }

  });
  $(".Kuwait_add").click(function(){

      var x = document.getElementById("Kuwait");
      if (x.style.display === "none") {
        x.style.display = "block";
      } else {
        x.style.display = "none";
      }

  });
  $(".Bahrain_add").click(function(){

      var x = document.getElementById("Bahrain");
      if (x.style.display === "none") {
        x.style.display = "block";
      } else {
        x.style.display = "none";
      }

  });
  $(".Oman_add").click(function(){

      var x = document.getElementById("Oman");
      if (x.style.display === "none") {
        x.style.display = "block";
      } else {
        x.style.display = "none";
      }

  });
  $(".SaudiArabia_add").click(function(){

      var x = document.getElementById("SaudiArabia");
      if (x.style.display === "none") {
        x.style.display = "block";
      } else {
        x.style.display = "none";
      }

  });
  $(".Qatar_add").click(function(){

      var x = document.getElementById("Qatar");
      if (x.style.display === "none") {
        x.style.display = "block";
      } else {
        x.style.display = "none";
      }

  });










	      $( "#enquiry" ).validate({
        rules: {
          name: "required",
          mobile: {
		      required: true,
		      minlength: 10,
          maxlength: 13,
		      digits: true
		    },
          email: {
            required: true,
            email: true
          },
          class: "required",
          state: "required"
        },
        messages: {
          name: "Please enter your firstname",
          mobile: "Please enter a username",
          email: "Please enter a valid email address",
          class: "Please enter class",
          state: "Please select state"
        },
        errorElement: "em",
        errorPlacement: function ( error, element ) {
         

         },
        highlight: function ( element, errorClass, validClass ) {
          
          var data = element.id;
          $("#"+data).addClass("input-error");
	  		  $("."+data).show();
        },
        unhighlight: function (element, errorClass, validClass) {
        	var data = element.id;
        	$("#"+data).removeClass("input-error");
        	$("."+data).hide();
        },
         submitHandler: function () {
              var serializeData = $('#enquiry').serialize();

              $.ajax({
                        url: './forms/enquiry.php',
                        type: 'POST',
                        dataType: 'json',
                        contentType: 'application/x-www-form-urlencoded; charset=UTF-8',   
                        data: serializeData,
                        beforeSend: function (xhr) {
                          $(".loader").show();  
                          $(".btnSb").hide();   
                          $(".book-now-btn").prop("disabled", true);                                             
                        },
                        success: function (response) {
                          

                            if (response.status == 1) {
                              Swal.fire({
                                      title: '<span style="color:#6eb4f3;"><span style="font-weight: 900;">winwintutors</span></span>',
                                      icon: 'success',
                                      html: '<b style="color: #47cf73;">Thank You !</b><br> ' +
                                        'Your registration is received and we will contact you soon',
                                     showConfirmButton: false,
                                     timer: 6000,
                              });

                            enquiry.reset();
                            $(".loader").hide();  
                            $(".btnSb").show();   
                            $(".book-now-btn").prop("disabled", false);  

                            
                            }
                            else {
                              Swal.fire({
                                icon: 'error',
                                title: 'Something went wrong !',
                                text: response.message,
                                showConfirmButton: false,
                                timer: 2000
                              });

                              $(".loader").hide();  
                              $(".btnSb").show();   
                              $(".book-now-btn").prop("disabled", false);  
                               
                            }
                        },
                        error: function (error) {

                           Swal.fire({
                                icon: 'error',
                                title: 'Something went wrong !',
                                text: "Bad Network. Try agin please.",
                                showConfirmButton: false,
                                timer: 2000
                              });
                          $(".loader").hide();  
                          $(".btnSb").show();   
                          $(".book-now-btn").prop("disabled", false);  
                            
                        }
                    });
         }
      });
});
