
  var timeOut = 3000;
  var t;

  $(function() {
    t = setTimeout('timedCount()', timeOut);
    $('#gallery li').hover(
       function() { // over
         clearTimeout(t);
       },
       function() { // out
         t = setTimeout('timedCount()', timeOut);
       });
  });
      
  function timedCount() {      
    var $nextImage;
    $('#gallery li').each(function(i) {
      if ($(this).hasClass('current')) {
        $(this).removeClass();
        $nextImage = $(this).next();
        if ($nextImage.length == 0) {
          $nextImage = $('#gallery li:first');
        }          
      }
    });         
    $nextImage.addClass('current');
    t = setTimeout('timedCount()', timeOut);
  };      
      

