(function($) {
  "use strict";

  $('.pushy-left').scotchPanel({
    containerSelector: 'body',
    beforePanelOpen: function() {
      $(".icon_menu").hide();
      $(".menu-btn .arrow_right").fadeIn();
    },
    beforePanelClose: function() {
      $(".icon_menu").fadeIn();
      $(".menu-btn .arrow_right").hide();
    },
    direction: 'left',
    duration: 500,
    transition: 'ease',
    clickSelector: '.menu-btn',
    distanceX: '300px'
  });

  jQuery.fn.center = function ()
      {
          this.css("position","fixed");
          this.css("top", ($(window).height() / 2) - (this.outerHeight() / 2));
          this.css("left", ($(window).width() / 2) - (this.outerWidth() / 2));
          return this;
      }

      $('#loader').center();
      $(window).resize(function(){
         $('#loader').center();
      });

  $(document).ready(function() {


    $('.accordion').dcAccordion({
      saveState: false,
    });
    $('.social-toggle').on('click', function() {
      $(this).next().toggleClass('open-menu');
    });
    // Target your .container, .wrapper, .post, etc.
    if ($(".post-format-video").length) {
      $(".post-format-video").fitVids();
    }
    if ($('audio,video').length) // use this if you are using id to check
    {
      $('audio,video').mediaelementplayer();
    }
    if ($('.blog-post-slider').length) {
      $('.blog-post-slider').flexslider({
        animation: "fade",
        controlNav: false,
        nextText: '',
        prevText: '',
        slideshowSpeed: 4000
      });
    }
  });
  if ($('.work_listing').length) {
    $('.work_listing').magnificPopup({
      delegate: 'a',
      type: 'image',
      tLoading: 'Loading image #%curr%...',
      mainClass: 'mfp-img-mobile',
      gallery: {
        enabled: true,
        navigateByImgClick: true,
        preload: [0, 1] // Will preload 0 - before current, and 1 after the current image
      },
      image: {
        tError: '<a href="%url%">The image #%curr%</a> could not be loaded.',
        titleSrc: function(item) {
          return item.el.attr('title');
        }
      },
      zoom: {
        enabled: true,
        duration: 300 // don't foget to change the duration also in CSS
      }
    });
  }

      // jQuery(window).scroll(function () {
      //   if(jQuery(this).scrollTop() > 100 ) {
      //       jQuery(".go-up").css("right","20px");
      //   }else {
      //       jQuery(".go-up").css("right","-60px");
      //   }
      // });
      // jQuery(".go-up").click(function(){
      //   jQuery("html,body").animate({scrollTop:0},500);
      //   return false;
      // });
})(jQuery);