 /**
   * The Custome Script.
   *
   *
   * @package   serenity WordPress Theme
   * @copyright Copyright (C) 2015, OrdaSoft
   * @license  http://www.gnu.org/licenses/gpl-2.0.html  GNU General Public License v2 or later
   * @author    AUTHOR <www.ordasoft.com>
   * serenity is distributed under the terms of the GNU GPL
   */

jQuery(document).ready(function (){

    jQuery( '.menu-item-has-children' ).hover(
        function(){
            jQuery(this).children('.sub-menu').slideToggle(400);
        },
        function(){
            jQuery(this).children('.sub-menu').slideToggle(400);
        }
    );
});
  // var swiper2 = new Swiper('.swiper2', {
  //       pagination: '.swiper-pagination2',
  //       nextButton: '.swiper-button-next',
  //        prevButton: '.swiper-button-prev',
  //       paginationClickable: true,
  //        slidesPerView: 4,
  //        grabCursor: true,
  //       loop: true
  //   });




( function( $ ) {
  var timelineBlocks = $('.cd-timeline-block'),
    offset = 0.8;

  //hide timeline blocks which are outside the viewport
  hideBlocks(timelineBlocks, offset);

  //on scolling, show/animate timeline blocks when enter the viewport
  $(window).on('scroll', function(){
    (!window.requestAnimationFrame)
      ? setTimeout(function(){ showBlocks(timelineBlocks, offset); }, 100)
      : window.requestAnimationFrame(function(){ showBlocks(timelineBlocks, offset); });
  });

  function hideBlocks(blocks, offset) {
    blocks.each(function(){
      ( $(this).offset().top > $(window).scrollTop()+$(window).height()*offset ) && $(this).find('.cd-timeline-img, .cd-timeline-content').addClass('is-hidden');
    });
  }

  function showBlocks(blocks, offset) {
    blocks.each(function(){
      ( $(this).offset().top <= $(window).scrollTop()+$(window).height()*offset && $(this).find('.cd-timeline-img').hasClass('is-hidden') ) && $(this).find('.cd-timeline-img, .cd-timeline-content').removeClass('is-hidden').addClass('bounce-in');
    });
  }
} )( jQuery );
