<!-- Javascript -->
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/2.1.4/jquery.min.js"></script>
<script src="{{ site.baseurl_javascripts }}imagesloaded.pkgd.min.js"></script>

{% if page.syntaxHighlighter %}
  <script src="{{ site.baseurl_javascripts }}prism.js"></script>
  <script src="{{ site.baseurl_javascripts }}prism-ruby.js"></script>
{% endif %}

<script>
  $(document).ready(function(){

    // Featured image loaded behavior
    $('.section-backgroundImage img').imagesLoaded()
      .done( function( instance ) {
        $('.post-featuredImage').addClass('is-loaded');
      });

    // Modal toggle behavior
    $('.modal-toggle-wrapper').click(function() {
    	$(this).toggleClass('active');
      $('.modal-toggle-bubble').toggleClass('active');
    	$('.modal-toggle-bubbleShadow').toggleClass('active');
      $('.modal-toggle-close-wrapper').toggleClass('active');
      $('.fullscreenModal').toggleClass('active');
    });

    // Prevent default anchor event and make a share popup
    $.fn.sharePopup = function (e, intWidth, intHeight, blnResize) {

      e.preventDefault();
      intWidth = intWidth || '750';
      intHeight = intHeight || '500';
      strResize = (blnResize ? 'yes' : 'no');

      //// Set title and open popup with focus on it
      var strTitle = ((typeof this.attr('title') !== 'undefined') ? this.attr('title') : 'Social Share'),
          strParam = 'width=' + intWidth + ',height=' + intHeight + ',resizable=' + strResize,
          objWindow = window.open(this.attr('href'), strTitle, strParam).focus();
    }

    $('.shareButton').on("click", function(e) {
      $(this).sharePopup(e);
    });
  });

  // Show modal toggle after scrolling 300px
  $(document).scroll(function() {
    $('.modal-toggle-group').toggleClass('active', $(document).scrollTop() >= 300);
  });
</script>

<script type="text/javascript">
  mixpanel.track("{{ page.title }}");
</script>

<script>
  (function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
  (i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
  m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
  })(window,document,'script','//www.google-analytics.com/analytics.js','ga');

  ga('create', 'UA-63859108-3', 'auto');
  ga('send', 'pageview');

</script>
