jQuery(document).ready(function($) {
	// We only want these styles applied when javascript is enabled
	$('div.content').css('display', 'block');

	// Initially set opacity on thumbs and add
	// additional styling for hover effect on thumbs
	$('#thumbs ul.thumbs li').opacityrollover({
		mouseOutOpacity:   1.0
	});
	
	// Initialize Advanced Galleriffic Gallery
	var gallery = $('#thumbs').galleriffic({
		delay:                     2500,
		numThumbs:                 50,
		preloadAhead:              -1,
		enableBottomPager:         false,
		imageContainerSel:         '#slideshowimages',
		controlsContainerSel:      '#controls',
		captionContainerSel:       '#caption',
		loadingContainerSel:       '#loading',
		renderSSControls:          false,
		renderNavControls:         false,
		syncTransitions:           true,
		defaultTransitionDuration: 1,
		onSlideChange:             function(prevIndex, nextIndex) {
			// 'this' refers to the gallery, which is an extension of $('#thumbs')
			this.find('ul.thumbs').children()
				.eq(prevIndex).fadeTo('fast', 1.0).end()
				.eq(nextIndex).fadeTo('fast', 1.0);
			
			$(this.imageContainerSel).html('');
			$(this.captionContainerSel).html('');
		},
		onPageTransitionOut:       function(callback) {
			this.fadeTo('fast', 0.0, callback);
		},
		onPageTransitionIn:        function() {
			this.fadeTo('fast', 1.0);
			
			if(!$(this).hasClass('jScroll') && $(this).height() > 0)
			{
				$(this).css('height','450px').addClass('jScroll');
				ScrollUtils.init();
			}
		}
	});

	/****************************************************************************************/
});

