$(document).ready(function(){
  $('.theme-main-menu .dropdown').on('mouseenter', menu_open).on('mouseleave', menu_timer);

  $('.jcarousel').jcarousel({ wrap: 'circular', animation: 'slow' }).jcarouselAutoscroll({ interval: 5000, target: '-=1', autostart: true });

  $('.carousel-front').jcarousel({ center: false, wrap: 'circular', animation: 'slow' }).jcarouselAutoscroll({ interval: 2500, target: '+=1', autostart: true });

  $('.jcarousel-2').jcarousel({ center: true, wrap: 'circular', animation: 'slow' }).jcarouselAutoscroll({ interval: 2500, target: '+=1', autostart: true });

  $('a[rel^="lightbox"]').fancybox({ titlePosition: "over", padding: 2, titleFormat: function(title, currentArray, currentIndex, currentOpts){
		        return '<span id="fancybox-title-over">' + (currentIndex + 1) + ' / ' + currentArray.length + (title.length ? ' &nbsp; ' + title : '') + '</span>';
		    } 
    });

   $('.theme-main-menu>ul').clone().appendTo('.theme-mobile-main-menu');
   $('.theme-mobile-main-menu>ul>li').first().remove();
   $('.theme-mobile-menu-icons a').click(function(event){
      event.preventDefault();
      $('.theme-mobile-main-menu').toggle('display');
   });
   $('.theme-mobile-main-menu .menu-item i').click(function(event){
      event.preventDefault();
      $(this).closest('.dropdown').find('.submenu').toggle('display');
   });
   
   $(window).scroll(function () {
       if ($(this).scrollTop() > 100) {
           $('#toTop').addClass('theme-to-top-active');
       } else {
           $('#toTop').removeClass('theme-to-top-active');
       }
   });
   $('#toTop').click(function (event) {
       $('body,html').animate({ scrollTop: 0 }, 400);
       return false;
   });

});
$(document).on('click', menu_close);