(function ($) {
   // Original JavaScript code.
  $(document).ready(function() {
    $('a.popup').click(function(event) {
      event.preventDefault();
      $popup = $(this).closest('.views-row').find('.views-field-entity-id-2');
      $.fancybox($popup.html(), {'autoDimensions': false, 'width': 775, 'height': 'auto'});
    });
    $('a.freetrial').live('click', function(event) {
      event.preventDefault();
      $content = '<h3>Celebrate the holidays with a free SchoolTown account that lasts forever!</h3><p>Free Accounts for Educators...</p><p>Now educators can register on SchoolTown for an account that will last forever. The new Free account allows educator to create two learning groups on SchoolTown’s award winning collaboration, sharing, and eLearning platform. More than two classes per educator and district level controls are an easy upgrade.</p><p>Find out why SchoolTown is one of the fastest growing platforms in K-12. The "right time" is right now!</p><p>Register for your free account by visiting <a href="https://www1.schooltown.net/RegistrationV2/signup.aspx">our registration page</a>.</p><p>Happy Holidays!</p>';
      $.fancybox($content, {'autoDimensions': false, 'width': 775, 'height': 400});
    });
    $('a.video').live('click', function(event) {
      event.preventDefault();
      $id = '.' + $(this).attr('id');
      $(this).parent().parent().find('.active').hide();
      $active = $(this).parent().parent().find($id);
      $active.show(); 
      $active.addClass('active');
    });
    $('div.video').each(function(){
      if(!$(this).hasClass('active')) {
        $(this).hide();
      }
    });
  });
})(jQuery);

