$(function() {
  (function(win) {
    var $tabTitles = $('.tab-titles >.item');
    var $tabContents = $('.tab-contents >.item');
    $tabTitles.hover(function(){
      var me = $(this);
      if (me.hasClass('active')) return;
      var index = $tabTitles.index(me);
      me.addClass('active').siblings().removeClass('active');
      $tabContents.eq(index).show().siblings('.item').hide();
    })
    var teachersSlider = $("#teacher-slider").owlCarousel({
      loop: true,
      items: 1,
      autoplay: true,
      autoplayTimeout: 3500,
      autoplayHoverPause: true
    });
    $('#prev-btn').on('click',function(event){
      teachersSlider.trigger('prev.owl.carousel');
    });
    $('#next-btn').on('click',function(event){
      teachersSlider.trigger('next.owl.carousel');
    });
    var $modal = $('#modal');
    var $closeBtn = $('#modal-close-btn');
    win.setTimeout(function(){
      $modal.show();
    },5000);
    $closeBtn.click(function(){
      $modal.hide();
      win.setTimeout(function(){
        $modal.show();
      },20000);
    })
  })(window);
});
