﻿/*
    Simple jQuery Slideshow Script
    Released by Jon Raasch (jonraasch.com) under FreeBSD license: free to use or modify, not responsible for anything, etc. 
*/
function slideswitch() {
    var $active = $('#slideshow img.active');
    if ( $active.length == 0 ) $active = $('#slideshow img:last');
    // use this to pull the images in the order they appear in the markup
    var $next =  $active.next().length ? $active.next() : $('#slideshow img:first');
    // uncomment the 3 lines below to pull the images in random order
    //var $sibs  = $active.siblings();
    //var rndNum = Math.floor(Math.random() * $sibs.length );
    //var $next  = $( $sibs[ rndNum ] );
    $active.addClass('last-active');
    $next.css({opacity: 0.0})
    	.addClass('active')
        .animate({opacity: 1.0}, 1000, function() {
            $active.removeClass('active last-active');
        });
}
$(function() {
    setInterval( "slideswitch()", 5000 );
});
// Initially set opacity on thumbs and add
// additional styling for hover effect on thumbs
var onMouseOutOpacity = 0.30;
	$('#thumbs-adv ul.thumbs li').css('opacity', onMouseOutOpacity)
	.hover(
	function () {
		$(this).not('.selected').fadeTo('fast', 1.0);
	}, 
	function () {
		$(this).not('.selected').fadeTo('fast', onMouseOutOpacity);
	}
);
$(document).ready(function() {
	// Initialize Advanced Galleriffic Gallery
	var galleryAdv = $('#gallery-adv').galleriffic('#thumbs-adv', {
		delay:                  2000,
		numThumbs:              30,
		preloadAhead:           10,
		enableTopPager:         true,
		enableBottomPager:      true,
		imageContainerSel:      '#slideshow-adv',
		controlsContainerSel:   '#controls-adv',
		renderSSControls:       true,
		renderNavControls:      true,
		playLinkText:           'Play Slideshow',
		pauseLinkText:          'Pause Slideshow',
		prevLinkText:           '&lsaquo; Previous Photo',
		nextLinkText:           'Next Photo &rsaquo;',
		nextPageLinkText:       'Next &rsaquo;',
		prevPageLinkText:       '&lsaquo; Prev',
		enableHistory:          false,
		autoStart:              false,
		syncTransitions:        true,
		defaultTransitionDuration: 2000,
		onChange:               function(prevIndex, nextIndex) {
		$('#thumbs-adv ul.thumbs').children()
			.eq(prevIndex).fadeTo('fast', onMouseOutOpacity).end()
			.eq(nextIndex).fadeTo('fast', 1.0);
		},
		onTransitionOut:        function(callback) {
			$('#slideshow-adv, #caption-adv').fadeOut('fast', callback);
		},
		onTransitionIn:         function() {
			$('#slideshow-adv, #caption-adv').fadeIn('fast');
		},
		onPageTransitionOut:    function(callback) {
			$('#thumbs-adv ul.thumbs').fadeOut('fast', callback);
		},
		onPageTransitionIn:     function() {
			$('#thumbs-adv ul.thumbs').fadeIn('fast');
		}
	});
});


