Add scroll to div

Add scroll to div

I am trying to add a scroll event and drag event to a container.  I added the scroll event to the window but cannot specify the container.  I am looking to create an image sequence and cycle thru the images on scroll and on drag. 

  1. <div id="container">
  2. <img src="frames/noindex_basset_02_img000.jpg" class="animated">
  3. <img src="frames/noindex_basset_02_img001.jpg" class="animated">
  4. <img src="frames/noindex_basset_02_img002.jpg" class="animated">
I have 61 images in the container, just posted to code to the first 3 
  1. $(document).ready(function () {
  2.     var pictureCount = $('#container img').length;
  3.     var scrollResolution = 50;

  4.     animateImage();

  5.     function animateImage() {
  6.         var currentScrollPosition = window.pageYOffset;
  7.         var imageIndex = Math.round(currentScrollPosition / scrollResolution);

  8.         if (imageIndex >= pictureCount) {
  9.             imageIndex = pictureCount - 1; // Select last image
  10.         }

  11.         $("#container img").hide();
  12.         $("#container img").eq(imageIndex).show();
  13.     }

  14.     $("#container").click(function(){
  15.         animateImage();
  16.     });

  17.     $(window).on('scroll', function() {
  18.         animateImage();
  19.     });
  20. });