
function ls_galleriffic_run (gallery_height)
{
	jQuery(document).ready(function($) {
		// We only want these styles applied when javascript is enabled
		// ?? Change this 300px to a percentage.
		// $('div.navigation').css({'width' : '300px', 'float' : 'left'});
		$('div.navigation').css({'width' : '240px', 'float' : 'left'});
		$('div.content').css('display', 'block');

		// Dynamically change height of all of the 700 pix tall divs.
		if (gallery_height != undefined && gallery_height > 0) {
			// alert ("gallery height " + gallery_height);
			var hstr = "'" + gallery_height + "px'";
			// alert ("hstr " + hstr);
			var panoramic = (gallery_height == gallery_pano_height());
			// How to parameterize this?
			if (panoramic) {
				// $('div.content').css({'height' : '400px'});
				// $('div.loader').css({'height' : '400px'});
				// $('div.slideshow-container').css({'height' : '400px'});
				// $('div.slideshow').css({'height' : '400px'});
				// $('div.slideshow').css({'line-height' : '400px'});
				// document.getElementById('loading').style.height = 400 + "px";
				// document.getElementById('slideshow').style.height = 400 + "px";
				// document.getElementById('slideshow-containing').style.height = 400 + "px";
			} else {
				// $('div.content').css({'height' : '700px'});
				// $('div.loader').css({'height' : '700px'});
				// $('div.slideshow-container').css({'height' : '700px'});
				// $('div.slideshow').css({'height' : '700px'});
				// $('div.slideshow').css({'line-height' : '700px'});
				// document.getElementById('loading').style.height = 700 + "px";
				// document.getElementById('slideshow').style.height = 700 + "px";
				// document.getElementById('slideshow-containing').style.height = 700 + "px";
			}
		}

		// 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'
		});

		var numthumbs = panoramic ? 5 : 10;
		var scaleWidth = panoramic ? 800 : -1;

		// Initialize Advanced Galleriffic Gallery
		var gallery = $('#thumbs').galleriffic({
			scaleWidth:                scaleWidth, // -1 for no width scaling, else scale image width, height to this width in pixels
			delay:                     3000, // in milliseconds
			numThumbs:                 numthumbs, // The number of thumbnails to show page
			preloadAhead:              40, // Set to -1 to preload all images
			enableTopPager:            true,
			enableBottomPager:         true,
			maxPagesToShow:            7,  // The maximum number of pages to display in either the top or bottom pager
			imageContainerSel:         '#slideshow', // The CSS selector for the element within which the main slideshow image should be rendered
			controlsContainerSel:      '#controls', // The CSS selector for the element within which the slideshow controls should be rendered
			captionContainerSel:       '#caption', // The CSS selector for the element within which the captions should be rendered
			loadingContainerSel:       '#loading', // The CSS selector for the element within which should be shown when an image is loading
			renderSSControls:          true, // Specifies whether the slideshow's Play and Pause links should be rendered
			renderNavControls:         true, // Specifies whether the slideshow's Next and Previous links should be rendered
			playLinkText:              'Play',
			pauseLinkText:             'Pause',
			prevLinkText:              'Previous',
			nextLinkText:              'Next',
			nextPageLinkText:          'Next &rsaquo;',
			prevPageLinkText:          '&lsaquo; Prev',
			enableHistory:             false, // Specifies whether the url's hash and the browser's history cache should update when the current slideshow image changes
			enableKeyboardNavigation:  true, // Specifies whether keyboard navigation is enabled
			autoStart:                 false, // Specifies whether the slideshow should be playing or paused when the page first loads
			syncTransitions:           true, // Specifies whether the out and in transitions occur simultaneously or distinctly
			defaultTransitionDuration: 1000, // If using the default transitions, specifies the duration of the transitions
			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);
			},
			onTransitionOut:           undefined, // accepts a delegate like such: function(slide, caption, isSync, callback) { ... }
			onTransitionIn:            undefined, // accepts a delegate like such: function(slide, caption, isSync) { ... }
			onPageTransitionOut:       function(callback) {
				this.fadeTo('fast', 0.0, callback);
			},
			onPageTransitionIn:        function() {
				this.fadeTo('fast', 1.0);
			},
			onImageAdded:              undefined, // accepts a delegate like such: function(imageData, $li) { ... }
			onImageRemoved:            undefined  // accepts a delegate like such: function(imageData, $li) { ... }
		});


		/**** Functions to support integration of galleriffic with the jquery.history plugin ****/

		// PageLoad function
		// This function is called when:
		// 1. after calling $.historyInit();
		// 2. after calling $.historyLoad();
		// 3. after pushing "Go Back" button of a browser
		function pageload(hash) {
			// alert("pageload: " + hash);
			// hash doesn't contain the first # character.
			if(hash) {
				$.galleriffic.gotoImage(hash);
			} else {
				gallery.gotoIndex(0);
			}
		}

		// Initialize history plugin.
		// The callback is called at once by present location.hash.
		$.historyInit(pageload, "advanced.html");

		// set onlick event for buttons using the jQuery 1.3 live method
		$("a[rel='history']").live('click', function(e) {
			if (e.button != 0) return true;

			var hash = this.href;
			hash = hash.replace(/^.*#/, '');

			// moves to a new page.
			// pageload is called at once.
			// hash don't contain "#", "?"
			$.historyLoad(hash);

			return false;
		});

		/****************************************************************************************/
	});
}



