$(document).ready(function() {
	// Initialize Advanced Galleriffic Gallery
	var gallery = $('#thumbs').galleriffic({
		delay:						5000,
		numThumbs:					50,
		preloadAhead:				3,
		enableTopPager:				false,
		enableBottomPager:			false,
		imageContainerSel:			'#g-slideshow',
		controlsContainerSel:		false,
		loadingContainerSel:		'#g-loading',
		autoStart:					true,
		syncTransitions:			true,
		defaultTransitionDuration:	900,
		enableKeyboardNavigation:	false,
		onTransitionIn:				function (newSlide, newCaption, isSync) {
			if(headerSlideshow[this.currentImage.index].url == "") {
				$("a", newSlide)
					.css('cursor', 'default')
					.unbind('click')
					.bind('click', function() {return false;});
			} else {
				$("a", newSlide)
					.unbind('click')
					.attr('href', headerSlideshow[this.currentImage.index].url);
			}
			newSlide.fadeTo(this.getDefaultTransitionDuration(isSync), 1.0);
			if(!this.isSlideshowRunning) {
				this.play();
			}
		}
	});

	$('div.pagination a.prev').click(function(e) {
		gallery.previous(true, true);
		e.preventDefault();
	});

	$('div.pagination a.next').click(function(e) {
		gallery.next(true, true);
		e.preventDefault();
	});
});
