	
	// -----------------------------------------------------------------------------------
	// 
	// This page coded by Scott Upton
	// http://www.uptonic.com | http://www.couloir.org
	//
	// This work is licensed under a Creative Commons License
	// Attribution-ShareAlike 2.0
	// http://creativecommons.org/licenses/by-sa/2.0/
	//
	// Associated API copyright 2002, Travis Beckham (www.squidfingers.com)
	//
	// -----------------------------------------------------------------------------------
	// --- version date: 04/30/05 ------------------------------------------------------
	
	var photoDir = "http://www219.pair.com/swansonr/pride_of_hawaii/";
        // was for Max Kiesler (thanks!) http://www.maxkiesler.com/images/doors/"; // Location of photos for gallery
	var borderSize = 6;	 // = 2x CSS border size
	
	// get current photo id from URL
	var thisURL = document.location.href;
	var splitURL = thisURL.split("#");
	var photoId = splitURL[1] - 1;
	
	// if no id in query string then set to 0
	photoId = (!photoId)? 0:photoId;
		
	// Define each photo's name, height, width, and caption
	var photoArray = new Array(
		// Source, Width, Height, Caption
            new Array("100_3674.jpg", "640", "480", "Just Finished Lifeboat Drill, Los Angeles","First CC Meeting"),
            new Array("100_3673.jpg", "640", "480", "Don't Let the Look Fool You, Everyone Had a Great Time","Having a Good Time (Really)"),
            new Array("100_3672.jpg", "640", "480", "More CruiseCritic Folks","More CC'ers"),
            new Array("100_3675.jpg", "640", "480", "This Lady and Her Husband Have Been on 37 NCL Cruises (plus many others)" ,"37 NCL Cruises"),
            new Array("100_3676.jpg", "640", "480", "The Whole Family is Cruising" ,"Cruisin' Families"),
            new Array("100_3677.jpg", "640", "480", "Maeve Blogged the Cruise Live on CruiseCritic" ,"And She Blogged, Too"),
            new Array("100_3678.jpg", "640", "480", "Even the Photographer Needs an Adult Beverage by Now" ,"Photog Enjoys a Break"),
            new Array("100_3771.jpg", "640", "480", "Vickie (Group Coordinator) Set Up an Official Get-Together for Us","Official Get-Together"),
            new Array("100_3772.jpg", "640", "480", "Sandi Talking with a Deck Officer" ,"Meeting the Officers"),
            new Array("100_3773.jpg", "640","480","CC'ers Meeting and Chatting" ,"CC'ers Meeting and Greeting"),
            // 10
            new Array("100_3775.jpg", "640", "480", "More CC'ers" ,"More CC'ers"),
            new Array("100_3777.jpg", "640", "480", "Maeve Meets the Cruise Directory" ,"Cruise Director"),
            new Array("100_3778.jpg", "640", "480", "Vickie (Group Coordinator) Arranged these Get-Togethers" ,"Vickie, Group Coordinator"),
            new Array("100_3779.jpg", "640", "480", "CC'ers Chatting with Bartender" ,"CC'ers Chatting with Bartender"),
            new Array("100_3780.jpg", "640", "480", "The Little Girl is Fascinated by the 'Bubbling' Bar Decorations" ,"CC Fun"),
            new Array("100_3781.jpg", "640", "480", "Ship's Officers Chatting with CC'ers" ,"Ship's Officers"),
            new Array("100_3782.jpg", "640", "480", "CC'ers Chatting" ,"More CC Folks"),
            new Array("100_3783.jpg", "640", "480", "Our Two Concierges, Eric and Robb" ,"Concierges"),
            new Array("100_3785.jpg", "640", "480", "Kamana'o (Onboard Hawaiian Ambassador) and Sandi" ,"Kamana'o and Sandi"),
            new Array("100_3786.jpg", "640", "480", "We Were Offered Complimentary Coffee" ,"CC'ers"),
            // 20
            new Array("100_3789.jpg", "640", "480", "Eric and Robb, the Concierges Answer CC'ers Questions" ,"Eric and Robb Answer CC'ers Questions"),
            new Array("100_3790.jpg", "640", "480", "CC'ers Getting Acquainted" ,"CC'ers Getting Acquainted"),
            new Array("100_3791.jpg", "640", "480", "More CC'ers Getting Acquainted" ,"More CC'ers Getting Acquainted"),
            new Array("100_4093.jpg", "640", "480", "Sharing Our Cruise Experiences" ,"Final CC Get-Together"),
            new Array("100_4094.jpg", "640", "480", "More CC'ers at the Final Party" ,"More CC'ers"),
            new Array("100_4095.jpg", "640", "480", "Sandi Thanks Vickie (Group Coordinator) for Setting Up the Party for Us" ,"Appreciation for Vickie and the NCL Staff"),
            new Array("100_4096.jpg", "640", "480", "Some CC'ers at the Final Party" ,"More CC'ers"),
            new Array("100_4097.jpg", "640", "480", "Don't Those Couches Look Inviting?" ,"Maeve Interacting"),
            new Array("100_4098.jpg", "640", "480", "Sign Up and Have a Chocolate Macadamia Nut, Too!" ,"Making Name Tags"),
            new Array("100_4099.jpg", "640", "480", "Sharing a Laugh as We Leave Maui" ,"Sharing a Laugh"),
            // 30
            new Array("100_4101.jpg", "640", "480", "Chatting About Our Cruise" ,"More CC'ers"),
            new Array("100_4100.jpg", "640", "480", "As the CC'ers Chatted, NCL Provided Wine (unasked!)" ,"Enjoying the Wine and the Company"),
            new Array("100_4102.jpg", "640", "480", "Chatting About Our Cruise" ,"More CC'ers"),
            new Array("100_4105.jpg", "640", "480", "Chatting About Our Cruise" ,"More CC'ers"),
            new Array("100_4104.jpg", "640", "480", "We Are Leaving Maui (sob!)" ,"Leaving Maui")
        );
        function removeAllChildren(xxx)
        {
            while (xxx.hasChildNodes()) 
            {
                xxx.removeChild(xxx.firstChild);
            }
        }

        function set_head(text)
        {
            var prompt = document.getElementById("subhead");
            removeAllChildren(prompt); // remove all content
            //
            // add back in
            //
            newtext = document.createTextNode(text); // text for subhead
            prompt.appendChild(newtext); // add text to subhead
        }

        function load_larger()
        {
            //
            // set the target for the "larger" photo based on
            // the current target
            //
            var url = photoDir + '8' + photoArray[photoId][0];
            
            popUp = window.open(url,
                                'photo',
                                'height=600,width=800,scrollbars=yes,resizable=yes,toolbar=yes,location=yes');
        }
	
	// Number of photos in this gallery
	var photoNum = photoArray.length;
	
	// Create access to 'Detect' object and a place to put instances of 'HTMLobj'
	API = new Detect();
	
	// CREATE INSTANCES & LOAD
	loadAPI = function(){
		// Instantiate HTMLobj
		API.Container		= new HTMLobj('Container');
		API.Photo			= new HTMLobj('Photo');
		API.PhotoContainer	= new HTMLobj('PhotoContainer');
		API.LinkContainer	= new HTMLobj('LinkContainer');
		API.PrevLink		= new HTMLobj('PrevLink');
		API.NextLink		= new HTMLobj('NextLink');
		API.CaptionBlock	= new HTMLobj('CaptionBlock');
		API.Counter			= new HTMLobj('Counter');
		API.Caption			= new HTMLobj('Caption');
		API.LoadImg			= new HTMLobj('LoadImg');
		
		// Show initial photo
		cyclePhoto(photoId);
	}
	onload = loadAPI;
	
	// Fade in photo when it is loaded from the server
	initFade = function(){
		// Show PhotoContainer again
		API.PhotoContainer.show();
		
		// Be certain the tween is complete before fading, too
		var fade_timer = setInterval('startFade()', 1000);
						
		// Fade photo in when ready and clear listener
		startFade = function(){
			if(API.Container._tweenRunning == false){
				clearInterval(fade_timer);
				
				// Be certain fade is done running before allowing next/previous links to work
				// This avoids rapid fade-in when users click next/previous links in quick succession
				var adv_timer = setInterval('permitNextPrev()', 500);
				
				// Permit next/previous links to function normally when fade is completed
				permitNextPrev = function(){
					if(API.Photo._fadeRunning == false){
						clearInterval(adv_timer);
						
						// Only show links if there is more than one photo in array
						if(photoNum > 1){
							API.LinkContainer.displayShow();
							document.getElementById('NextLink').onclick = nextPhoto;
							document.getElementById('PrevLink').onclick = prevPhoto;
						}
					} else {return;}
				}
				// Swap out loading animation to spare CPU cycles when hidden anyway
//				API.LoadImg.setSrc("http://www.maxkiesler.com/images/slideshow/start.gif");
				API.LoadImg.setSrc("start.gif");
				
				// Show caption again
				API.CaptionBlock.show();
				
				// Fade photo in
				API.Photo.fadeIn(0,15,33);
			} else {return;}
		}
	}
	
	// Prevent next/previous
	falsify = function(){
		return false;
	}
	
	// Go to next photo
	nextPhoto = function(){
		// Go to next photo
		if(photoId == (photoArray.length - 1)){
			photoId = 0;
		} else {photoId++;}
		cyclePhoto(photoId);
	}
	
	// Go to previous photo
	prevPhoto = function(){
		// If at start, go back to end
		if(photoId == 0){
			photoId = photoArray.length - 1;
		} else {photoId--;}
		cyclePhoto(photoId);
	}
	
	// Alter class of elements
	changeElementClass = function(objId,setClass) {
		document.getElementById(objId).className = setClass;
	}
	
	// Function to load subsequent photos in gallery
	cyclePhoto = function(photoId){
				
		// Swap in loading animation
//		API.LoadImg.setSrc("http://www.maxkiesler.com/images/slideshow/loading_ani2.gif");
		//API.LoadImg.setSrc("radar-transparent.gif");
            API.LoadImg.setSrc("snake_transparent.gif");
		//API.LoadImg.setSrc("loading_ani2.gif");
		
		// Hide link container if it is not already hidden
		API.LinkContainer.displayHide();
		
		// Hide photo container and caption temporarily
		API.Photo.hide();
		API.Photo.setOpacity(0);
		API.CaptionBlock.hide();
		
		// Get dimensions of photo
		var wNew = photoArray[photoId][1];
		var hNew = photoArray[photoId][2];
		
		// Start tween on a delay
		var wCur = API.Container.getWidth() - borderSize;
		var hCur = API.Container.getHeight() - borderSize;
		
		// Begin tweening on a short timer
		setTimeout('API.Container.tweenTo(easeInQuad, ['+wCur+', '+hCur+'], ['+wNew+','+hNew+'], 7)',500);
		setTimeout('API.LinkContainer.sizeTo('+wNew+','+hNew+')',500);
		setTimeout('API.PrevLink.sizeTo('+wNew/2+','+hNew+')',500);
		setTimeout('API.NextLink.sizeTo('+wNew/2+','+hNew+')',500);
		setTimeout('API.CaptionBlock.sizeTo('+wNew+',18)',500);
		
		// Get new photo source
		var newPhoto = photoDir + photoArray[photoId][0];
		//alert(newPhoto);
		// Set source, width, and height of new photo
		API.Photo.setSrc(newPhoto);		
		API.Photo.sizeTo(wNew,hNew);
		
		// Set links to new targets based on photoId
		API.NextLink.setHref("#" + (photoId+1));
		API.PrevLink.setHref("#" + (photoId+1));
		API.Counter.setInnerHtml((photoId+1)+" of "+photoNum+" |");
		API.Caption.setInnerHtml(photoArray[photoId][3]);
		
                set_head(photoArray[photoId][4]); // set subhead
		// Event listeners for onload and onclick events
		document.getElementById('Photo').onload = initFade;
		
		// Block next/previous links until permitNextPrev() has fired
		document.getElementById('NextLink').onclick = falsify;
		document.getElementById('PrevLink').onclick = falsify;
	}
