function scaleImage(selector, maxHeight) {

	//Configuration Options
	//Sets the max width, in pixels, for every image
	//Sets the syntax for finding the images.  Defaults to all images.
	//For images inside of a particular element (id="abc") or class (class="abc"),
	//use '.abc img' or '#abc img' respectively.  Don't leave off the img tag!!!
	//End configuration options.  You don't need to change anything below here.
	
	jQuery(selector).each(function(){
		var width = jQuery(this).width();
		var height = jQuery(this).height();
		if (height > maxHeight) {
			//Set variables	for manipulation
			var ratio = (height / width );
			var newHeight = maxHeight;
			var newWidth = (newHeight * ratio);
			
			//Shrink the image and add link to full-sized image
			jQuery(this).height(newHeight).width(newWidth);
			
		} //ends if statement
	} //ends each function
	);
}

jQuery(document).ready(function($) {
	// We only want these styles applied when javascript is enabled
	$('#gallery div.navigation').css('float', 'left');
	$('#gallery div.content').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').css('opacity', onMouseOutOpacity)
		.hover(
			function () {
				$(this).not('.selected').fadeTo('fast', 1.0);
			}, 
			function () {
				$(this).not('.selected').fadeTo('fast', onMouseOutOpacity);
			}
		);

	if ($.url.segment('3') || $.url.param('4')) {
		$('.widget_ribshowalbum').appendTo('#gallery');
	}
			
	// Initialize Advanced Galleriffic Gallery
	var galGallery = $('#gallery').galleriffic('#thumbs', {
		delay:                  2000,
		numThumbs:              25,
		preloadAhead:           10,
		enableTopPager:         false,
		enableBottomPager:      true,
		imageContainerSel:      '#slideshow',
		controlsContainerSel:   '',
		captionContainerSel:    '#caption',
		loadingContainerSel:    '',
		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:          true,
		autoStart:              false,
		onChange:               function(prevIndex, nextIndex) {
			$('#thumbs ul.thumbs').children()
				.eq(prevIndex).fadeTo('fast', onMouseOutOpacity).end()
				.eq(nextIndex).fadeTo('fast', 1.0);	
		},
		onTransitionOut:        function(callback) {
			$('#caption').fadeTo('fast', 0.0);
			$('#slideshow').fadeTo('fast', 0.0, callback);
		},
		onTransitionIn:         function() {
			$('#slideshow').fadeTo('fast', 1.0);
			$('#caption').fadeTo('fast', 1.0);
		},
		onPageTransitionOut:    function(callback) {
			$('#thumbs ul.thumbs').fadeTo('fast', 0.0, callback);
		},
		onPageTransitionIn:     function() {
			$('#thumbs ul.thumbs').fadeTo('fast', 1.0);
		}
	});
});