var first = true;
function changeSlide(curr, next, opts) {
  var nextSlide = first ? 0 : opts.nextSlide;
  $('.galLinks li').eq(nextSlide).each(function() {
    var position = $(this).position();
    var offset = $(this).height() > 20 ? 46 : 41;
    var pos = position.top + offset + parseInt($(this).css('padding-top'));
    $('#galLinkSelect').css('top', pos+'px');
  });
  first = false;
}
$(document).ready(function(){
  $('.gallery .slides').cycle({
    timeout: 5000,
    before: changeSlide
  });
  $('.galLinks li').each(function(i) {
    $(this).mouseenter(function(){ 
      $('.gallery .slides').cycle(i);
    });
  });
});

