jQuery(document).ready(function($) {
	// We only want these styles applied when javascript is enabled
	$('div.fotoview').css('display', 'block');

	// Initially set opacity on thumbs and add
	// additional styling for hover effect on thumbs
	var onMouseOutOpacity = 0.67;
	$('#thumbs ul.thumbs li').opacityrollover({
		mouseOutOpacity:   onMouseOutOpacity,
		mouseOverOpacity:  1.0,
		fadeSpeed:         'fast',
		exemptionSelector: '.selected'
	});
	
	// Initialize Advanced Galleriffic Gallery
	var gallery = $('#thumbs').galleriffic({
		delay:                     5000,
		numThumbs:                 6,
		preloadAhead:              6,
		enableTopPager:            false,
		enableBottomPager:         false,
		imageContainerSel:         '#slideshow',
		captionContainerSel:       '#caption',
		loadingContainerSel:       '#loading',
		controlsContainerSel:      '#controls',
		playLinkText:              '<input type="button" class="t_red10025" value="Slide Show">',
		pauseLinkText:             '<input type="button" class="t_red10025" value="Slide Show">',
		prevLinkText:              '<input type="button" class="t_red2525" value="&lt;">',
		nextLinkText:              '<input type="button" class="t_red2525" value="&gt;">',
		renderSSControls:          true,
		renderNavControls:         true,
		enableHistory:             false,
		autoStart:                 false,
		syncTransitions:           true,
		defaultTransitionDuration: 1500,
		onSlideChange:             function(prevIndex, nextIndex) {
			// 'this' refers to the gallery, which is an extension of $('#thumbs')
			this.find('ul.thumbs').children()
				.eq(prevIndex).fadeTo('fast', onMouseOutOpacity).end()
				.eq(nextIndex).fadeTo('fast', 1.0);
		}
	});
});
