/* Post-transition hook; called after a slide changes.
 * We use this to update the caption with the current slide's
 * title attribute.
 *
 * We also need to let Cufon know to redraw the text.
 *
*/
function on_after(current_slide, next_slide, options) {
  $('#slideshow_caption').html(this.title);
  Cufon.refresh('#slideshow_caption');
}


function configure_slideshow_cycle() {
  $('#slideshow').cycle({
    fx: 'fade',
    after: on_after,
    delay: 5000,
    next: '#slideshow_controls #next',
    speed: 2000,
    timeout: 5000
  });
}


/* Show the controls when the user hovers over the slideshow, and hide
 * then when he leaves.
*/
function add_slideshow_hover_handlers() {
  var controls = $('#slideshow_controls');
  
  in_handler = function() { controls.show(); };
  out_handler = function() { controls.hide(); };

  $('#slideshow').hover(in_handler, out_handler);

  /* Make sure the controls don't disappear when we hover them. */
  controls.hover(in_handler);
}


$(document).ready(function() {
  configure_slideshow_cycle();
  add_slideshow_hover_handlers();
});

