   var photoDir = "images/frontpage/"; // Location of photos for gallery
	var borderSize = 0;	 // = 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("1.jpg", "1000", "400", "Chaotic Dreams - My mind"),
new Array("myknowledgeintype.jpg", "1000", "600", "My Knowledge in Type. - This is my knowledge brought to you Typographically"),
new Array("itsburning.jpg", "1000", "500", "Going Green. - Am I helping the planet with this?"),
new Array("2.jpg", "1000", "500", "Helium Colony - Inspired by a song")
);
	
	// 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();
	
	loadAPI = function(){
		// Instantiate HTMLobj
		API.slideshow_container		= new HTMLobj('slideshow_container');
		API.Photo			= new HTMLobj('Photo');
		API.Photoslideshow_container	= new HTMLobj('Photoslideshow_container');
		API.Linkslideshow_container	= new HTMLobj('Linkslideshow_container');
		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 Photoslideshow_container again
		API.Photoslideshow_container.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.slideshow_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.Linkslideshow_container.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("images/slideshow/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.marcosebastian.com/js/loader2.gif");
		
		// Hide link slideshow_container if it is not already hidden
		API.Linkslideshow_container.displayHide();
		
		// Hide photo slideshow_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.slideshow_container.getWidth() - borderSize;
		var hCur = API.slideshow_container.getHeight() - borderSize;
		
		// Begin tweening on a short timer
		setTimeout('API.slideshow_container.tweenTo(easeInQuad, ['+wCur+', '+hCur+'], ['+wNew+','+hNew+'], 7)',500);
		setTimeout('API.Linkslideshow_container.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];
		
		// 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+" images &bull;");
		API.Caption.setInnerHtml(photoArray[photoId][3]);
		
		// 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;
	}
	//