(function ($) {

  "use strict";



  /***************************************

   jQuery MeanMenu activation code

   ***************************************/

  $('nav#dropdown').meanmenu({

    siteLogo: "<a href='index.html'><img src='images/logo.png' /></a>"

  });



  /*----------------------------

   wow js active

  ------------------------------ */

  new WOW().init();



  /*----------------------------

   Property Slider

  ------------------------------ */

  $(".property-slider").owlCarousel({

    autoPlay: false,

    slideSpeed: 2000,

    pagination: false,

    navigation: true,

    items: 1,

    /* transitionStyle : "fade", */
    /* [This code for animation ] */

    navigationText: ["<i class='fa fa-angle-left'></i>", "<i class='fa fa-angle-right'></i>"],

    itemsDesktop: [1199, 1],

    itemsDesktopSmall: [980, 1],

    itemsTablet: [768, 1],

    itemsMobile: [479, 1],

  });



  /*----------------------------

   Agent Slider

  ------------------------------ */

  $(".agent-slider").owlCarousel({

    autoPlay: true,

    slideSpeed: 2000,

    pagination: true,

    navigation: false,

    items: 4,

    /* transitionStyle : "fade", */
    /* [This code for animation ] */

    navigationText: ["<i class='fa fa-angle-left'></i>", "<i class='fa fa-angle-right'></i>"],

    itemsDesktop: [1199, 3],

    itemsDesktopSmall: [980, 3],

    itemsTablet: [768, 2],

    itemsMobile: [479, 1],

  });



  /*----------------------------

   About Slider

  ------------------------------ */

  $(".about-feature").owlCarousel({

    autoPlay: true,

    slideSpeed: 1000,

    pagination: false,

    navigation: false,

    items: 1,

    /* transitionStyle : "fade", */
    /* [This code for animation ] */

    navigationText: ["<i class='fa fa-angle-left'></i>", "<i class='fa fa-angle-right'></i>"],

    itemsDesktop: [1199, 1],

    itemsDesktopSmall: [980, 1],

    itemsTablet: [768, 1],

    itemsMobile: [479, 1],

  });



  /*-------------------------------------

  Price filtering activation  

  ---------------------------------------*/

  $("#slider-range").slider({

    range: true,

    min: 40,

    max: 600,

    values: [60, 570],

    slide: function (event, ui) {

      $("#amount").val("$" + ui.values[0] + " - $" + ui.values[1]);

    }

  });

  $("#amount").val("$" + $("#slider-range").slider("values", 0) +

    " - $" + $("#slider-range").slider("values", 1));



  /*--------------------------

   scrollUp

  ---------------------------- */

  $.scrollUp({

    scrollText: '<i class="fa fa-angle-up"></i>',

    easingType: 'linear',

    scrollSpeed: 900,

    animation: 'fade'

  });

  /*-------------------------------

  Fancybox

  ---------------------------------*/

  $('.fancybox').fancybox();



  /*--------------------------

  bxslider

  ---------------------------- */

  //Testimonial slider     

  $('.client-content').bxSlider({

    pagerCustom: '.client-img'

  });



  //Property details slider    

  $('.bg-photo').bxSlider({

    pagerCustom: '.sm-photo'

  });



  

  /*-----------------------------------

  Home Two Menu Slde

  -------------------------------------*/

  var togglebtn = $('.toggle-btn');

  if (togglebtn.length) {

    $(".toggle-btn").on("click", function () {

      $('.small-logo, .toggle-btn').toggleClass("active");

      $(".main-menu.mean-menu1").toggleClass("show-menu");

    });

  }







  /*-------------------------------------

  Client logo jQuery activation code

  -------------------------------------*/

  $(".client-logo-area").owlCarousel({

    // Most important owl features

    autoPlay: true,

    items: 6,

    itemsDesktop: [1199, 6],

    itemsDesktopSmall: [980, 4],

    itemsTablet: [768, 2],

    itemsTabletSmall: false,

    itemsMobile: [479, 1],

    singleItem: false,

    itemsScaleUp: false,

    // Navigation

    navigation: true,

    navigationText: ["<i class='fa fa-angle-left'></i>", "<i class='fa fa-angle-right'></i>"],

    // Responsive 

    responsive: true,

    pagination: false,



  });

  /*-------------------------------------

  Home Page Blog area jQuery activation

  -------------------------------------*/

  $(".latest-blog").owlCarousel({

    // Most important owl features

    autoPlay: true,

    items: 4,

    itemsDesktop: [1199, 3],

    itemsDesktopSmall: [980, 3],

    itemsTablet: [768, 2],

    itemsTabletSmall: false,

    itemsMobile: [479, 1],

    singleItem: false,

    itemsScaleUp: false,

    // Navigation

    navigation: true,

    navigationText: ["<i class='fa fa-angle-left'></i>", "<i class='fa fa-angle-right'></i>"],

    // Responsive 

    responsive: true,

    pagination: false,



  });

  /*-------------------------------------

  Home Page Blog area jQuery activation

  -------------------------------------*/

  $(".property-image-slider").owlCarousel({

    autoPlay: true,

    slideSpeed: 1000,

    pagination: false,

    navigation: false,

    items: 1,

    /* transitionStyle : "fade", */
    /* [This code for animation ] */

    navigationText: ["<i class='fa fa-angle-left'></i>", "<i class='fa fa-angle-right'></i>"],

    itemsDesktop: [1199, 1],

    itemsDesktopSmall: [980, 1],

    itemsTablet: [768, 1],

    itemsMobile: [479, 1],

  });

  /*

  -----------------------------------

  Header Sticky Menu Creation

  -----------------------------------*/

  $(window).on('scroll', function () {

    if ($(window).scrollTop() > 100) {

      $('#sticky').addClass('stick');

    } else {

      $('#sticky').removeClass('stick');

    }

  });

  /*-------------------------------

  Counter Up

  ---------------------------------*/

  $('.about-counter').counterUp({

    delay: 50,

    time: 3000

  });

  //Property details one slider

  $('.big-photo').slick({

    slidesToShow: 1,

    slidesToScroll: 1,

    arrows: false,

    fade: true,

    asNavFor: '.pagin-slider'

  });

  $('.pagin-slider').slick({

    slidesToShow: 3,

    slidesToScroll: 1,

    asNavFor: '.big-photo',

    dots: false,

    centerMode: true,

    focusOnSelect: true

  });

  /*-------------------------

  Nice Select JQuery 

  ---------------------------*/

  $('select').niceSelect();



  /*-------------------------

   jQuery Page Loader

   --------------------------*/

  $("#loading").delay(2000).fadeOut(500);


  /*-------------------------

   Ajax Contact Form

   --------------------------*/
  var form = '.ajax-contact';
  var invalidCls = 'is-invalid';
  var $email = '[name="email"]';
  var $validation = '[name="name"],[name="email"],[name="phone"],[name="subject"],[name="message"]'; // Must be use (,) without any space
  var formMessages = $('.form-messages');

  function sendContact() {
    var formData = $(form).serialize();
    var valid;
    valid = validateContact();
    if (valid) {
      jQuery.ajax({
          url: $(form).attr('action'),
          data: formData,
          type: "POST"
        })
        .done(function (response) {
          // Make sure that the formMessages div has the 'success' class.
          formMessages.removeClass('error');
          formMessages.addClass('success');
          // Set the message text.
          formMessages.text(response);
          // Clear the form.
          $(form + ' input:not([type="submit"]),' + form + ' textarea').val('');
        })
        .fail(function (data) {
          // Make sure that the formMessages div has the 'error' class.
          formMessages.removeClass('success');
          formMessages.addClass('error');
          // Set the message text.
          if (data.responseText !== '') {
            formMessages.html(data.responseText);
          } else {
            formMessages.html('Oops! An error occured and your message could not be sent.');
          }
        });
    };
  };

  function validateContact() {
    var valid = true;
    var formInput;

    function unvalid($validation) {
      $validation = $validation.split(',')
      for (var i = 0; i < $validation.length; i++) {
        formInput = form + ' ' + $validation[i];
        if (!$(formInput).val()) {
          $(formInput).addClass(invalidCls)
          valid = false;
        } else {
          $(formInput).removeClass(invalidCls)
          valid = true;
        };
      };
    };
    unvalid($validation);

    if (!$($email).val() || !$($email).val().match(/^([\w-\.]+@([\w-]+\.)+[\w-]{2,4})?$/)) {
      $($email).addClass(invalidCls)
      valid = false;
    } else {
      $($email).removeClass(invalidCls)
      valid = true;
    };
    return valid;
  };

  $(form).on('submit', function (element) {
    element.preventDefault();
    sendContact();
  });











})(jQuery);







$(window).on('load', function () {



  /*-------------------------------

  Isotope

  ---------------------------------*/



  // use document.ready instead of window.load

  // window.load waits for all resources to be loaded first,

  // can be a long time

  jQuery(function () {

    // now doc is ready, make selection

    // use another selector, not .isotope,

    // since that is dynamically added in Isotope v1

    var $container = jQuery('.grid');

    // filter items on button click

    $('.property-menu ul').on('click', 'li', function () {

      $(".property-menu ul").removeClass("active");

      $('.property-menu ul').addClass("active");

      var filterValue = $(this).attr('data-filter');

      $container.isotope({

        filter: filterValue

      });

    });

    // use imagesLoaded, instead of window.load

    $container.imagesLoaded(function () {

      $container.isotope({

        itemSelector: '.grid-item',

        percentPosition: true,

        percentPosition: true,

        // masonry is default layoutMode, no need to specify it

        sortBy: 'random',

        masonry: {

          // use outer width of grid-sizer for columnWidth

          columnWidth: '.grid-item',

        }

      });

    })

  });

}); // END load Function 