$(function() {
$('#slideshow').cycle({ 
    fx:     'fade', 
    speed:  'slow',
    prev:   '#prev', 
    next:   '#next', 
    after:   onAfter, 
    timeout: 0 
});
});

function onAfter(curr, next, opts) {
    var index = $(this).parent().children().index(this);
    $('#prev')[index == 0 ? 'hide' : 'show']();
    $('#next')[index == opts.slideCount - 1 ? 'hide' : 'show']();
}
