$(document).ready(function () {
    // Slide Show Nav setup
    $('#slideshow-nav a').css('opacity', 0.5)
        .mouseover( function () {
            $(this).addClass('current')
                .fadeTo('fast', 1)
        })
        .mouseout( function () {
            $(this).removeClass('current')
            if (!$(this).hasClass('active')) {
                $(this).fadeTo('fast', 0.5)
            };
        });

    
    // Slide Show Grabber
    $('#slideshow-grab').cycle({
        fx: 'fade',
        pause: true,
        timeout: 8000, // 8 sec
        speed: 1500, // 1.5 sec
        //next: '#slideshow-grab',
        pager: '#slideshow-nav',
        pagerAnchorBuilder: function(idx, slide) { 
            // return selector string for existing anchor 
            return '#slideshow-nav li:eq(' + idx + ') a'; 
        },
        before: function (curr, next, opts) {
            var targetId = '#' + next.id + '-nav';
            
            // Fade out current selection
            $('#slideshow-nav a:not(.current)').removeClass('active')
                .fadeTo('fast', 0.5)

            // Fade in next slide
            $(targetId).addClass('active')
                .fadeTo('fast', 1)
        }
    });
});