	// brevity is good.
	var d = document;
	function id(i){ return d.getElementById(i); }
	function idc(i){ return d.getElementById(i).firstChild; }
	
	// window.onload = function(){ fireInTheDisco(); };
	
	function fireInTheDisco(){
	
		// JSON -> real object.
		eval(gallery);
	
		// we'll be using this a lot
		navChildren = id('igx_gal_nav').childNodes;
				
		// This bit makes our JavaScript unobtrusive. somewhere, Jeremy Keith smiles
		idc('prev').onclick = function(){ doSlideshow(false); swapB(--k); return false; };
		idc('play').onclick = function(){ doSlideshow(); return false; };
		idc('next').onclick = function(){ doSlideshow(false); swapB(++k); return false; };
		idc('bucket').onclick = function(){ bucket(); return false; };
		
		// give the photo 'next' functionality, too.
		idc('photoGalleryPhoto').onclick = function(){ doSlideshow(false); swapB(++k); return false; };
		
		// attach click events to the thumbs. stop playing & goto that pic.
		for(var m = 0; m < navChildren.length; m++){
			navChildren[m].firstChild.onclick = (function(t){ return function(){
				doSlideshow(false);
				swap(t);
				return false; } })(m);
		}
		
		// hide the images. this makes our script non-Javascript-kosher,
		// and preloads it for the JS kiddies.
		$('.nsPhoto[id!=photoGalleryPhoto]').addClass('hide');
		
		// this just makes stuff a little prettier for our non-JS friends.
		id('leftControls').className = 'controls';
		id('rightControls').className = 'controls';
		id('photoGalleryPhoto').style.width = 'auto';
		id('photoGalleryPhoto').style.textAlign = 'center';
		id('tehBucket').className = 'dynamic';
		id('closeBucket').style.display = 'block';
		id('closeBucket').onclick = bucket;
		
		// let's get it started in haa
		slideshow = window.setInterval("swapB(++k)", SS_DELAY);
		bPlay = true;
		
	}
	
	var k = 0;		// global... current image.
	var navChildren;
	var slideshow;
	var bPlay;
	
	function doSlideshow(bOff){
	
		// makes bOff optional parameter,
		// thereby, toggling on/off
		if(typeof(bOff)!='undefined')
			bPlay = !bOff;
	
		// are we rolling? stop it
		if(bPlay){
			window.clearInterval(slideshow);
			idc('play').firstChild.src = "images/icons/play.gif";
		} else {	// not rolling? play, go go go
			slideshow = window.setInterval("swapB(++k)", SS_DELAY);
			idc('play').firstChild.src = "images/icons/pause.gif";
		}
		
		bPlay = !bPlay;
	}
	
	function swapB(j){
	
		// detects out-of-bounds j.
		if(j>=gallery.photos.length)
			j = 0;
		if(j<0)
			j = gallery.photos.length-1;

		// ok now flip it.
		swap(j);
	}
	
	function swap(j){
	
		// makes prev/next buttons align to
		// the thumbnail outline like if you clicked on it.

		/* for(var m = 0; m < navChildren.length; m++){
			if(m==j){	// selected. boom
				navChildren[m].firstChild.className = 'hasFocus';
			} else {
				navChildren[m].firstChild.blur();
				navChildren[m].firstChild.className = '';
			}
		} */
		
		// sets the correct image & caption
		id('bigPic').src = "images/" + gallery.photos[j].large;
		id('BPcaption').innerHTML = gallery.photos[j].caption;
		// id('bigPicLink').href = thisPageURL + "#photo" + j;
		// id('photoGalleryPhoto').style.width = gallery[j].width + "px";
		k = j;	// for global static greatness
			
	}
	
	function bucket(){
		
		// stop the slideshow.
		doSlideshow(false);
		
		// hide or show
		if ($('#tehBucket').is(":hidden")) {
			$('#tehBucket').slideDown(400);
		} else {
			// zip back just a leeeeetle faster
			$('#tehBucket').slideUp(275);
		}	
	
	}
