Cycle Plugin Image preview

Cycle Plugin Image preview

Hi

I'm trying to get an image preview in a Cycle gallery when clicking on navigation buttons like this:

  1. <script type="text/javascript">
  2. $(document).ready(function() {
  3.  
  4. $('#gallery').cycle({
  5. fx: 'fade',
  6. timeout: 0,
  7. speed: 1000,
  8. delay: -2000,
  9. pager: '#pager',
  10. next: '#next',
  11. prev: '#prev'
  12. });

  13. $('#pager a').click(function(evt) {
  14. //path to new preview
  15.   var imgPath = $('#gallery a').attr('href');
  16.    
  17.    //get reference to old preview
  18.   var oldPrev = $('#preview img'); 
  19.    //create HTML for new image
  20.   var  newPrev = $('<img src="' + imgPath +'">');
  21.  
  22. //make new image invisible
  23.   newPrev.hide();  
  24.  
  25. //add to the #photo div
  26. $('#preview').prepend(newPrev);  
  27.  
  28.   //fade in new image
  29. newPrev.fadeIn(850);  
  30.   //fade out old Prev and remove from DOM
  31.    oldPrev.fadeOut(850,function(){
  32. $(this).remove();
  33.     });
  34.  
  35. }); // end click

  36. }); // end ready()
  37. </script>
  38. </head>
  39. <body id="twoCol">
  40. <div id="container">  
  41.   <div id="contentWrap">
  42.   <div id="main">
  43.   <h1>Cycle Slideshow</h1>
  44.   <div id="controls">
  45.   <span id="prev" class="control">Previous</span>
  46.     <span id="pager"></span>
  47.     <span id="next" class="control">Next</span>
  48.     
  49.   </div>
  50.   <div id="gallery">
  51.     <div><a href="images/mid/blue.jpg"></a><img src="images/large/blue.jpg" width="400" height="300" alt="Blue"><p class="credit">Photo by Alin Nan</p></div>
  52.     <div><a href="images/mid/yellow.jpg"></a><img src="images/large/milk.jpg" width="275" height="432" alt="Milk Fruit Explosion"><p class="credit">Photo by David Kitchenham</p></div>
  53.     <div><a href="images/mid/green.jpg"></a><img src="images/large/fan.jpg" width="300" height="400" alt="Fan"><p class="credit">Photo by Jeltovski</p></div>
  54.     <div><a href="images/mid/orange.jpg"></a><img src="images/large/red.jpg" width="400" height="300" alt="Red"><p class="credit">Photo by Alin Nan</p></div>
  55.     <div><a href="images/mid/purple.jpg"></a><img src="images/large/weight.jpg" width="275" height="414" alt="Pink weight"><p class="credit">Photo by David Pattee</p></div>
  56.   </div>
  57.     
  58. <div id="preview"></div>  

  59. </div>
  60.     </div>
  61.   
  62. </div>
But I only get always the same first image => <a href="images/mid/blue.jpg"></a>
Online example is here.
What I'm doing wrong?

Any help appreciated!