﻿		var JaS = {
			// Customization parameters
			imagePath : "projectdetails/projectphotos/",
			images : [
				["waterfront04home.jpg", "<span style='color: #00467F'><strong>Project Name:</strong></span> <br> NAVFAC MSF Design <br> 									<span style='color: #00467F'><strong>Cost: </strong></span><br>$84,500,000<br> <span style='color: #00467F'><strong>Project Description:</strong></span>	<br> SSFM is providing Project Management services for this project which will construct a new 700 ft. non-magnetic concrete slip at Beckoning Point, Pearl Harbor, Hawaii to support a drive-in solenoid structure, similar to the Magnetic Silencing  	<br><a href='projectdetailsmain.htm?projectdetails/waterfront04.htm'><span style='color: #016EC7;line-height:30px;'>More... </span></a>", ""],
				
				["airport01home.jpg", "<span style='color: #00467F'><strong>Project Name:</strong></span> <br> FY05 MILCON PN 57423, Hot Cargo Pads, Hickam Air Force Base, Oahu, Hawaii <br> 	<span style='color: #00467F'><strong>Cost: </strong></span><br>$10,800,000<br> <span style='color: #00467F'><strong>Project Description:</strong></span>   <br> SSFM's Civil group prepared the full design and contract documents to construct 2 additional hot cargo pads, adjacent to the existing taxiway 'B' at Hickam Air Force Base. The project 	<br><a href='projectdetailsmain.htm?projectdetails/airport01.htm'>	<span style='color: #016EC7;line-height:30px;'>More... </span> </a>", ""],
				
				["atfp01home.jpg", 		"<span style='color: #00467F'><strong>Project Name:</strong></span> <br> MCA Project No. 55253 Ship Operations Building<br> 					<span style='color: #00467F'><strong>Cost: </strong></span><br>$9,900,000<br> <span style='color: #00467F'><strong>Project Description:</strong></span>    <br> The Ship Operations Building will provide ship-related operational facilities for 25 shore support personnel and two boat crews of 32 persons each.  The ship operations facility includes administrative offices,	<br><a href='projectdetailsmain.htm?projectdetails/atfp01.htm'>	<span style='color: #016EC7;line-height:30px;'>More... </span> </a>", ""],
				
				["highroads05home.jpg", "<span style='color: #00467F'><strong>Project Name:</strong></span> <br> Palau Compact Road <br> 									<span style='color: #00467F'><strong>Cost: </strong></span><br>$84,500,000<br> <span style='color: #00467F'><strong>Project Description:</strong></span> <br> 	SSFM International Inc. served as a subconsultant to Earth Tech, Inc. (now AECOM) responsible for structural engineering services for the Palau Compact Road project. SSFM's scope included preparation of the major 	<br> <a href='projectdetailsmain.htm?projectdetails/highroads05.htm'><span style='color: #016EC7;line-height:30px;'>More... </span></a>", ""],

				["federal04home.jpg", "<span style='color: #00467F'><strong>Project Name:</strong></span> <br> FY04 MCA PN57461 Qualification Training Range I					<span style='color: #00467F'><strong>Cost: </strong></span><br>$7,814,000<br> <span style='color: #00467F'><strong>Project Description:</strong></span> <br> 	SSFM International, Inc. served as the prime consultant responsible for Civil Engineering services for the Qualifications Training Range I project, which was divided into two phases: Design Charrette and Design<br><a href='projectdetailsmain.htm?projectdetails/federal04.htm'><span style='color: #016EC7;line-height:30px;'>More... </span></a>", ""],				

				["highroads01home.jpg", "<span style='color: #00467F'><strong>Project Name:</strong></span> <br> Mamalahoa Hwy Bypass Road   <br> 							<span style='color: #00467F'><strong>Cost: </strong></span><br>$1,367,000<br> <span style='color: #00467F'><strong>Project Description:</strong></span> <br> 	SSFM provided civil engineering services for the planning and design for the widening of a 2 lane to 4 lane highway, which is approximately 5.6 miles in length.  <br><br><a href='projectdetailsmain.htm?projectdetails/highroads01.htm'><span style='color: #016EC7;line-height:30px;'>More... </span></a>", ""],

				["construction04home.jpg","<span style='color: #00467F'><strong>Project Name:</strong></span> <br> Rural Fiber Optic Duct Line  Statewide (Kauai, Oahu, Maui, Molokai, Lanai, and Hawaii)   <br> <span style='color: #00467F'><strong></strong></span> <span style='color: #00467F'><strong>Project Description:</strong></span> <br> 	SSFM is the prime consultant in the construction of underground fiber optic ductlines within the rights-of-ways of both State Department of Transportation (DOT) highway facilities, County of 	<br><a href='projectdetailsmain.htm?projectdetails/construction04.htm'><span style='color: #016EC7;line-height:30px;'>More... </span></a>", ""],

				["education04home.jpg", "<span style='color: #00467F'><strong>Project Name:</strong></span> <br> DOE Whole School Classroom Renovation   <br> 					<span style='color: #00467F'></span><span style='color: #00467F'><strong>Project Description:</strong></span> <br> 	SSFM International, Inc. serves as the prime consultant responsible for Project Management and Construction management for projects on Moloka‘i (2), Maui (8), Big Island (15), and Kaua‘i (4). The projects will typically involve interior and  <br>	<br><a href='projectdetailsmain.htm?projectdetails/education04.htm'><span style='color: #016EC7;line-height:30px;'>More... </span></a>", ""],

				["education05home.jpg", "<span style='color: #00467F'><strong>Project Name:</strong></span> <br> University of Hawaii, Frear Hall Student Housing  <br> 				<span style='color: #00467F'></span><span style='color: #00467F'><strong>Project Description:</strong></span> <br> 	The Office of Capital Improvements retained SSFM International, Inc. to provide professional services for Project Management/Construction Management for the development of the New Student Housing at the Frear Hall Site at the University of	<br><a href='projectdetailsmain.htm?projectdetails/education05.htm'><span style='color: #016EC7;line-height:30px;'>More... </span></a>", ""],

				["construction06home.jpg", "<span style='color: #00467F'><strong>Project Name:</strong></span> <br> Honolulu International Airport Parking Structure <br> 				<span style='color: #00467F'></span> <span style='color: #00467F'><strong>Project Description:</strong></span> <br> SSFM provided Construction Management Services for the construction of a new multilevel parking structure situated between the Interisland Terminal and the Overseas Terminal Parking  Structure (currently known as 'Lot A'). The Project also <br><br><a href='projectdetailsmain.htm?projectdetails/construction06.htm'><span style='color: #016EC7;line-height:30px;'>More... </span></a>", ""],

				["construction05home.jpg", "<span style='color: #00467F'><strong>Project Name:</strong></span> <br> Honolulu International Airport Flight Information Display System and Public Address System Replacement <br><span style='color: #00467F'><strong>Cost: </strong></span><br>$9,886,000<br> <span style='color: #00467F'><strong>Project Description:</strong></span> <br> SSFM is performing Construction Management services for the replacement of the Flight Information Display System and Public Address System, addition of  	<br><a href='projectdetailsmain.htm?projectdetails/construction05.htm'><span style='color: #016EC7;line-height:30px;'>More... </span></a>", ""],

				["civil06home.jpg", "<span style='color: #00467F'><strong>Project Name:</strong></span> <br> Kehalani Module 5 <br> 									<span style='color: #00467F'><strong>Cost: </strong></span><br>$12,000,000 <br> <span style='color: #00467F'><strong>Project Description:</strong></span> <br> SSFM will provide Civil & Electrical Engineering services for the development of a 100-unit multi-family project. Civil Engineering design services includes the following: A. Clearing and grubbing. B. Site grading for the proposed driveways, 	<br><a href='projectdetailsmain.htm?projectdetails/civil06.htm'><span style='color: #016EC7;line-height:30px;'>More... </span></a>", ""],

				["db06home.jpg", "<span style='color: #00467F'><strong>Project Name:</strong></span> <br> Carpenters Union Training Center <br><span style='color: #00467F'><strong>Cost: </strong></span><br>$15,000,000<br> <span style='color: #00467F'><strong>Project Description:</strong></span> <br> SSFM provided professional services for the design of a new 2 story 51,000 s.f. warehouse and classrooms with a 75 X 28 s.f. mezzanine for the Hawaii Carpenter’s Union located at Lauwiliwili Street, Ewa, Hawaii.<br><a href='projectdetailsmain.htm?projectdetails/db06.htm'><span style='color: #016EC7;line-height:30px;'>More... </span></a>", ""],

				//2011-11-14  pacifichome project 
				["pacifichome.jpg", "<span style='color: #00467F'><strong>Project Name:</strong></span> <br> Pacific Submarine Drive-In Magnetic Silencing Facility <br><span style='color: #00467F'><strong>Cost: </strong></span><br>$87.6 million<br> <span style='color: #00467F'><strong>Project Description:</strong></span> <br> This project was awarded to SSFM International and Moffatt & Nichol Joint Venture back in 2006.SSFM provided project management, civil engineering, and structural engineering services. The project was completed in December 2010.<br><a href='projectdetailsmain.htm?projectdetails/pacific01.htm'><span style='color: #016EC7;line-height:30px;'>More... </span></a>", ""],
				
				
				//["federal05home.jpg", "<span style='color: #00467F'><strong>Project Name:</strong></span> <br> USAG Humphreys <br>										<span style='color: #00467F'><strong></strong></span><br><span style='color: #00467F'><strong>Project Description:</strong></span> <br> SSFM will be providing project management services for new land development, new and existing utilities and infrastructure for US Army Garrison-Humphreys near Pyongtaek, Korea.  Construction work to include: hauling and placing<br><a href='projectdetailsmain.htm?projectdetails/federal05.htm'><span style='color: #016EC7;line-height:30px;'>More... </span></a>", ""],

				//090505 link change request by Marie
				["charrettes01home.jpg", "<span style='color: #00467F'><strong>Project Name:</strong></span> <br> C-17 Fuel Cell Nose Dock Hangar <br>	 						<span style='color: #00467F'><strong>Cost: </strong></span><br>$22,670,000<br> <span style='color: #00467F'><strong>Project Description:</strong></span>   <br> SSFM was the prime consultant responsible for the preparation of the parametric design and Design-Build RFP solicitation documents for construction of  an approximately 30,662 sf C-17 	<br><a href='projectdetailsmain.htm?projectdetails/idiq02.htm'><span style='color: #016EC7;line-height:30px;'>More... </span> </a>", ""]
				
			],
			fadeContainerId : "jas-container",
			imageContainerId : "jas-image",
			imageTextContainerId : "jas-image-text",
			previousLinkId : "previous-image",
			nextLinkId : "next-image",
			imageCounterId : "image-counter",
			startSlideShowId : "start-slideshow",
			stopSlideShowId : "stop-slideshow",	
			dimBackgroundOverlayId : "jas-dim-overlay",
			dimBackgroundId : "dim-background",
			noDimBackgroundId : "no-dim-background",
			thumbnailContainerId: "jas-thumbnails",
			tagsContainerId: "jas-tags",
			tagsSelectAllId: "jas-select-all-tags",
			useImageText : true,
			useThumbnails : false,
			allowDimmedBackground : true,
			automaticallyDimBackgroundWhenSlideShow : true,
			useTags : false,
			useKeyboardShortcuts : true,	
			useFadingIn : true,
			useFadingOut : true,
			useFadeWhenNotSlideshow : false,
			useFadeForSlideshow : true,
			useFadeAtInitialLoad : false,
			fadeIncrement : 0.1,	
			fadeInterval : 50, // Milliseconds	
			timeForSlideInSlideshow : 3500, // Milliseconds	
			
			// JaS function parameters
			allImages : null,
			currentImages : null,
			fadeContainer : null,
			imageContainer : null,
			imageTextContainer : null,
			previousLink : null,
			nextLink : null,
			dimBackgroundOverlay : null,
			dimBackgroundLink : null,
			noDimBackgroundLink : null,
			dimmingActivated : false,
			imageCounter : null,
			startSlideShowLink : null,
			stopSlideShowLink : null,
			thumbnailContainer : null,
			thumbnailCollection : [],
			currentThumbnailSelected : null,
			tagsContainer : null,
			tagsSelectAll : null,
			tagsList : null,
			tags : [],
			tagsCheckboxes : [],
			selectAllTags : true,
			imageText : null,
			imageText : "",
			imageSource : "",
			imageIndex : 0,
			fadingIn : false,
			fadeLevel : 0,
			fadeEndLevel : 100,
			fadeTimer : null,
			hasOpacitySupport : false,
			useMSFilter : false,
			useMSCurrentStyle : false,
			slideshowIsSupported : false,
			slideshowIsPlaying : false,
			functionAfterFade : null,
			isInitialLoad : false,
			
			init : function (){
		    	if($){
					this.fadeContainer = $(this.fadeContainerId);
					this.imageContainer = $(this.imageContainerId);
					this.slideshowIsSupported = this.fadeContainer && this.imageContainer;
					if(this.slideshowIsSupported){
						this.allImages = this.images;
						this.currentImages = this.images;
						if(this.useImageText){
							this.imageTextContainer = $(this.imageTextContainerId);
							if(!this.imageTextContainer){
								this.useImageText = false;
							}
						}
						this.hasOpacitySupport = typeof this.fadeContainer.style.filter != "undefined" || typeof this.fadeContainer.style.opacity != "undefined";
						this.useMSFilter = typeof this.fadeContainer.style.filter != "undefined";
						this.useMSCurrentStyle = typeof this.fadeContainer.currentStyle != "undefined";
						
						this.previousLink = $(this.previousLinkId);
						this.previousLink.onclick = JaS.previousLinkClick;
						this.nextLink = $(this.nextLinkId);
						this.nextLink.onclick = JaS.nextLinkClick;
						this.imageCounter = $(this.imageCounterId);
						this.startSlideShowLink = $(this.startSlideShowId);
						if(this.startSlideShowLink){
							this.startSlideShowLink.style.display = "inline";
						}
						this.startSlideShowLink.onclick = JaS.startSlideShowClick;
						this.stopSlideShowLink = $(this.stopSlideShowId);
						if(this.stopSlideShowLink){
							this.stopSlideShowLink.style.display = "none";
						}
						this.stopSlideShowLink.onclick = JaS.stopSlideshowClick;
						
						if(this.allowDimmedBackground){
							this.dimBackgroundOverlay = $(this.dimBackgroundOverlayId);
							this.dimBackgroundLink = $(this.dimBackgroundId);
							this.noDimBackgroundLink = $(this.noDimBackgroundId);
							if(this.dimBackgroundOverlay && this.dimBackgroundLink && this.noDimBackgroundLink){
								this.dimBackgroundLink.onclick = JaS.dimBackgroundClick;
								this.noDimBackgroundLink.onclick = JaS.noDimackgroundClick;
								this.noDimBackgroundLink.style.display = "none";
								this.dimmingActivated = true;
							}
						}
						
						if(this.useKeyboardShortcuts){
							document.onkeydown = JaS.documentKeyDown;
						}
						
						this.thumbnailContainer = $(this.thumbnailContainerId);
						if(this.useThumbnails && this.thumbnailContainer){
							this.createThumbnails();
						}
						
						this.tagsContainer = $(this.tagsContainerId);
						if(this.useTags && this.tagsContainer){
							this.tagsSelectAll = $(this.tagsSelectAllId);
							if(this.tagsSelectAll){
								this.tagsSelectAll.onclick = JaS.tagsSelectAllClick;
								this.createTagList();
							}
						}
						
						this.isInitialLoad = true;
						this.setImage();
						this.isInitialLoad = false;
					}
				}
			},
			
			previousLinkClick : function(oEvent){
				var oEvent = (typeof oEvent != "undefined")? oEvent : event;
				JaS.preventDefaultEventBehavior(oEvent);
				JaS.previousImage();
			},
			
			nextLinkClick : function(oEvent){
				var oEvent = (typeof oEvent != "undefined")? oEvent : event;
				JaS.preventDefaultEventBehavior(oEvent);
				JaS.nextImage();
			},
			
			startSlideShowClick : function(oEvent){
				var oEvent = (typeof oEvent != "undefined")? oEvent : event;
				JaS.preventDefaultEventBehavior(oEvent);
				JaS.startSlideshow();
			},
			
			stopSlideshowClick : function(oEvent){
				var oEvent = (typeof oEvent != "undefined")? oEvent : event;
				JaS.preventDefaultEventBehavior(oEvent);
				JaS.stopSlideshow();
			},
			
			dimBackgroundClick : function(oEvent){
				var oEvent = (typeof oEvent != "undefined")? oEvent : event;
				JaS.preventDefaultEventBehavior(oEvent);
				JaS.dimBackground();
			},
			
			documentKeyDown : function(oEvent){
				var oEvent = (typeof oEvent != "undefined")? oEvent : event;
				JaS.applyKeyboardNavigation(oEvent);
			},
			
			tagsSelectAllClick : function (oEvent){
				JaS.tagsSelectAll = this.checked;
				JaS.markAllTags();
			},
			
			noDimackgroundClick : function(oEvent){
				var oEvent = (typeof oEvent != "undefined")? oEvent : event;
				JaS.preventDefaultEventBehavior(oEvent);
				JaS.noDimBackground();
			},
			
			setImage : function (){
				if(this.currentImages.length > 0){
					this.imageContainer.style.visibility = "visible";
					this.imageSource = this.currentImages[this.imageIndex][0];
					this.imageText = this.currentImages[this.imageIndex][1];
					if(this.useFadingOut && (this.slideshowIsPlaying && this.useFadeForSlideshow) || (!this.slideshowIsPlaying && this.useFadeWhenNotSlideshow) && (this.useFadeAtInitialLoad && this.isInitialLoad || !this.isInitialLoad)){
						this.fadeOut();
					}
					else{
						this.displayImageCount();
						this.imageContainer.setAttribute("src", (this.imagePath + this.imageSource));
						this.setImageText();
						//kh start: 02/11/2009 commented out to constantly display previous and next links
						//this.previousLink.style.visibility = (this.imageIndex > 0)? "visible" : "hidden";
						//this.nextLink.style.visibility = (this.imageIndex < (this.currentImages.length - 1))? "visible" : "hidden";
						//kh end: 02/11/2009 commented out to constantly display previous and next links
						if((this.useFadeAtInitialLoad && this.isInitialLoad || !this.isInitialLoad) && ((this.slideshowIsPlaying && this.useFadeForSlideshow) || (!this.slideshowIsPlaying && this.useFadeWhenNotSlideshow))){
							this.fadeIn();
						}
					}
					if(this.useThumbnails){
						this.markCurrentThumbnail();
					}
				}
				else{
					this.imageSource = "";
					this.imageText = "";
					this.displayImageCount();
					this.imageContainer.style.visibility = "hidden";
					this.setImageText();
				}
			},
			
			displayImageCount : function (){
		    	if(this.imageCounter){
					this.imageCounter.innerHTML = (((this.currentImages.length > 0)? this.imageIndex : -1) + 1) + " / " + this.currentImages.length;
				}
			},
			
			nextImage : function (){
				if(this.imageIndex < (this.currentImages.length - 1)){
					++this.imageIndex;
					
					this.setImage();
				}
				else { //if(this.slideshowIsPlaying){ // kh: 02/11/2009 removed to enable looping at end of image for next button
					// this.stopSlideshow();  //kh: 02/11/2009 removed to enable looping
					this.imageIndex = 0;
					this.setImage();
				}
			},
			
			previousImage : function (){
				if(this.imageIndex > 0){
					--this.imageIndex;
					this.setImage();
				}      
				//kh start: 02/11/2009 added to enable going back to previous image if it's the first image on the list
				//			This assumes 15 projects are loaded.
				else { 
					this.imageIndex = 13;  //humphreys excluded. when restored, use 14
					this.setImage();
				}
				//kh end: 02/11/2009 
				   
			},
		
			setImageText : function (){
				this.imageTextContainer.setAttribute("alt", this.imageText); 
		    	if(this.useImageText && typeof this.imageText == "string"){
					this.imageTextContainer.innerHTML = this.imageText;
				}
			},
			
			setDimBackgroundSize : function(){
		         var oDimBackground = this.dimBackgroundOverlay.style;
		         var intWidth = document.body.offsetWidth;
		         var intXScroll = (typeof window.pageXOffset != "undefined")? window.pageXOffset : document.body.scrollLeft;
		         var intHeight = (typeof window.innerHeight != "undefined")? window.innerHeight : (document.documentElement)? document.documentElement.clientHeight : document.body.clientHeight;
		         var intYScroll = (typeof window.window.pageYOffset != "undefined")? window.window.pageYOffset : (document.documentElement)? document.documentElement.scrollTop : document.documentElement.scrollTop;
		         oDimBackground.width = intWidth + intXScroll + "px";
		         oDimBackground.height = intHeight + intYScroll + "px";
			},
			
			dimBackground : function (){
		         this.setDimBackgroundSize();
		         this.dimBackgroundOverlay.style.display = "block";
				 this.noDimBackgroundLink.style.display = "inline";		
			},
			
			noDimBackground : function (fromStopSlideshow){
				this.dimBackgroundOverlay.style.display = "none";
				this.noDimBackgroundLink.style.display = "none";
				if(!fromStopSlideshow){
					this.stopSlideshow();
				}
			},
				
			startSlideshow : function (){
				if(this.currentImages.length > 0){
					this.startSlideShowLink.style.display = "none";
					this.stopSlideShowLink.style.display = "inline";
					this.slideshowIsPlaying = true;
					this.fadeTimer = setTimeout("JaS.nextImage()", JaS.timeForSlideInSlideshow);
					if(this.dimmingActivated  && this.automaticallyDimBackgroundWhenSlideShow){
						this.dimBackground();
					}
				}
			},
			
			stopSlideshow : function (){
				if(this.currentImages.length > 0){
					this.startSlideShowLink.style.display = "inline";
					this.stopSlideShowLink.style.display = "none";
					this.slideshowIsPlaying = false;
					this.setFadeParams(false, 1, 0);
					this.setFade();
					clearTimeout(this.fadeTimer);
					if(this.dimmingActivated && this.automaticallyDimBackgroundWhenSlideShow){
						this.noDimBackground(true);
					}
				}
			},
			
			fadeIn : function (){
				this.setFadeParams(true, 0, 1);
				this.functionAfterFade = null;
				this.fade();
				if(this.slideshowIsPlaying){
					this.functionAfterFade = "this.startSlideshow()";
				}
			},
			
			fadeOut : function (){
				this.setFadeParams(false, 1, 0);
				this.functionAfterFade = "this.fadeOutDone()";
				this.fade();
			},
			
			fadeOutDone : function (){
		        this.displayImageCount();
				this.imageContainer.setAttribute("src", (this.imagePath + this.imageSource));
				this.setImageText();
				if(this.useFadingIn){
					this.fadeIn();
				}
				else{
					this.fadeLevel = 1;
					this.setFade();
				}
			},
			
			fade : function (){
				if((this.fadingIn && this.fadeLevel < this.fadeEndLevel) || !this.fadingIn && this.fadeLevel > this.fadeEndLevel){
					this.fadeLevel = (this.fadingIn)? this.fadeLevel + this.fadeIncrement : this.fadeLevel - this.fadeIncrement;
					// This line is b/c of a floating point bug in JavaScript
					this.fadeLevel = Math.round(this.fadeLevel * 10) / 10;
					this.setFade();
					this.fadeTimer = setTimeout("JaS.fade()", this.fadeInterval);
				}
				else{
					clearTimeout(this.fadeTimer);
					if(this.functionAfterFade){
						eval(this.functionAfterFade);
					}
				}
			},
			
			setFade : function (){
				if(this.useMSFilter){
					this.fadeContainer.style.filter = "progid:DXImageTransform.Microsoft.Alpha(opacity=" + (this.fadeLevel * 100) + ")";
				}
				else{
					this.fadeContainer.style.opacity = this.fadeLevel;
				}
			},
			
			setFadeParams : function (bFadingIn, intStartLevel, intEndLevel){
				this.fadingIn = bFadingIn;
				this.fadeLevel = intStartLevel;
				this.fadeEndLevel = intEndLevel;
			},
			
			createThumbnails : function (){
				this.thumbnailContainer.innerHTML = "";
				this.thumbnailCollection = [];
		    	var oThumbnailsList = document.createElement("ul");
				var oListItem;
				var oThumbnail;
				var oCurrentImage;
				for(var i=0; i<this.currentImages.length; i++){
		        	oCurrentImage = this.currentImages[i];
					oListItem = document.createElement("li");
					oThumbnail = document.createElement("img");
					oThumbnail.setAttribute("id", ("jas-thumbnail-" + i));
					oThumbnail.setAttribute("src", (this.imagePath + oCurrentImage[0]));
					oThumbnail.setAttribute("alt", oCurrentImage[1]);
					oThumbnail.setAttribute("title", oCurrentImage[1]);
					oThumbnail.onclick = JaS.thumbnailClick;
					this.thumbnailCollection.push(oThumbnail);
					oListItem.appendChild(oThumbnail);
					oThumbnailsList.appendChild(oListItem);			
		        }
				this.thumbnailContainer.appendChild(oThumbnailsList);
				if(this.thumbnailCollection.length > 0){
					this.markCurrentThumbnail();
				}
				if(this.slideshowIsPlaying){
					this.stopSlideshow();
				}
			},
			
			thumbnailClick : function (oEvent){
				JaS.imageIndex = parseInt(this.getAttribute("id").replace(/\D*(\d+)$/, "$1"), 10);
				JaS.setImage();
			},
			
			markCurrentThumbnail : function (){
				if(this.currentThumbnailSelected){
			        this.currentThumbnailSelected.className = "";
					// Sometimes, in IE, the image loses its reference to its parent
					if(this.currentThumbnailSelected.parentNode){
						this.currentThumbnailSelected.parentNode.className = "";
					}
				}
				this.currentThumbnailSelected = this.thumbnailCollection[this.imageIndex];
				this.currentThumbnailSelected.className = "selected";
				this.currentThumbnailSelected.parentNode.className = "selected-parent";
			},
			
			createTagList : function (){
				var strCurrentTag;
				var arrCurrentTag;
				var oRegExp;
				for(var i=0; i<this.images.length; i++){
					arrCurrentTag = this.images[i][2].replace(/\s*(,)\s*/,  "$1").split(",");
					for(var j=0; j<arrCurrentTag.length; j++){
		            	strCurrentTag = arrCurrentTag[j];
						oRegExp = new RegExp(strCurrentTag, "i");
						if(this.tags.toString().search(oRegExp) == -1){
							this.tags.push(strCurrentTag);
						}
		            }
		        }
				this.tagsList = document.createElement("ul");
				var oListItem;
				var oTagCheckbox;
				var oLabel;
				for(var k=0; k<this.tags.length; k++){
					oTag = this.tags[k];
					oListItem = document.createElement("li");
					oTagCheckbox = document.createElement("input");
					oTagCheckbox.setAttribute("type", "checkbox");
					oTagCheckbox.setAttribute("id", ("jas-" + oTag));
					oTagCheckbox.setAttribute("value", oTag);
					oTagCheckbox.checked = true;
					oTagCheckbox.onclick = JaS.tagCheckboxClick;
					oLabel = document.createElement("label");
					oLabel.setAttribute("for", ("jas-" + oTag));
					oLabel.innerHTML = oTag;
					this.tagsCheckboxes.push(oTagCheckbox);
					oListItem.appendChild(oTagCheckbox);
					oListItem.appendChild(oLabel);
					this.tagsList.appendChild(oListItem);
				}
				this.tagsContainer.appendChild(this.tagsList);
				// This loop is necessary since IE can only mark checkboxes as checked after they've been added to the document
				for(var l=0; l<this.tagsCheckboxes.length; l++){
					this.tagsCheckboxes[l].checked = true;		
				}
			},
			
			tagCheckboxClick : function (oEvent){
				JaS.applyTagFilter();
			},
			
			applyTagFilter : function (){
				this.currentImages = [];
				var arrCurrentTags = [];
				var oCheckbox;
				for(var i=0; i<this.tagsCheckboxes.length; i++){
		        	oCheckbox = this.tagsCheckboxes[i];
					if(oCheckbox.checked){
						arrCurrentTags.push(oCheckbox.value);
					}
		        }
				var oRegExp;
				var oImage;
				for(var j=0; j<this.images.length; j++){
		        	oImage = this.images[j];
					for(var k=0; k<arrCurrentTags.length; k++){
						oRegExp = new RegExp(arrCurrentTags[k], "i");
						if(oImage[2].search(oRegExp) != -1){
							this.currentImages.push(oImage);
							break;
						}
					}
		        }
				
				if(this.useThumbnails){
					this.createThumbnails();
				}
				this.imageIndex = 0;
				this.setImage();
			},
			
			markAllTags : function (){
				for(var i=0; i<this.tagsCheckboxes.length; i++){
					this.tagsCheckboxes[i].checked = this.tagsSelectAll;
		        }
				this.applyTagFilter();
			},
			
			closeSession : function (oEvent){
				JaS = null;
				delete JaS;
			},
			
			applyKeyboardNavigation : function (oEvent){
		    	var intKeyCode = oEvent.keyCode;
		    	if(!oEvent.altKey){
					switch(intKeyCode){
						case 32:
							this.slideshowIsPlaying = (this.slideshowIsPlaying)? false : true;
							if(this.slideshowIsPlaying){
								this.startSlideshow();
							}
							else{
								this.stopSlideshow();
							}
							this.preventDefaultEventBehavior(oEvent);
							break;
						case 37:
						case 38:
							this.previousImage();
							this.preventDefaultEventBehavior(oEvent);
							break;
						case 39:
						case 40:
							this.nextImage();
							this.preventDefaultEventBehavior(oEvent);
							break;
					}
				}
			},
			
			preventDefaultEventBehavior : function (oEvent){
				if(oEvent){
					oEvent.returnValue = false;
					if(oEvent.preventDefault){
						oEvent.preventDefault();
					}
				}
			}
		};
		// ---
		addEvent(window, "load", function(){JaS.init();}, false);
		addEvent(window, "unload", function(){JaS.closeSession();}, false);
		addEvent(window, "load", function(){ setTimeout(" JaS.startSlideshow()", 1)}, false);
		// ---
		// Utility functions
		function addEvent(oObject, strEvent, oFunction, bCapture){
			if(oObject){
				if(oObject.addEventListener){
					oObject.addEventListener(strEvent, oFunction, bCapture);
				}
				else if(window.attachEvent){
					oObject.attachEvent(("on" + strEvent), oFunction)
				}
			}
		}
		// ---
		function $(strId){
			return document.getElementById(strId);
		}
		// ---
		if(typeof Array.prototype.push != "function"){
			Array.prototype.push = ArrayPush;
			function ArrayPush(value){
				this[this.length] = value;
			}
		}
		// ---	

