/* loadPhotos.js
Reference uploaded photos here.

WHAT IT DOES:
This document stores a multidimensional (2x1) array of
thumbnail paths, full size image paths and captions. 
It then loads those images into the element on which
the "loadPhotos()" function is called.


HOW IT WORKS:
A loop iterates over the array, in it calls a function,
createDivElement. 

The createDivElement function simply executes a series
of commands to create a specific layout in HTML. That 
layout defines how the image is presented on the page.

The loop which called the createDivElement function
then proforms the attachment to the specified root
element.


ADDING PHOTOS
Copy the following:
	//image('thumbnail source', 'photo source', 'caption');

Paste into the PHOTOS array, put it at the top (more
recent photos first). 

replace each 'source' with the filepath to the thumbnail
and full-size image respectively and add a short 
descriptive caption in the 'caption' part.

Save and Upload to server.
*/

var PHOTOS = new Array(
	//image('thumbnail source', 'photo source', 'caption');
	image('./photos/thumbnails/2010-04-10FoundersDay-1.jpg',	'./photos/2010-04-10FoundersDay-1.jpg', 'Puppies!!!'),
	image('./photos/thumbnails/2010-04-10FoundersDay-2.jpg',	'./photos/2010-04-10FoundersDay-2.jpg', 'From left to right: Everyone'),
	image('./photos/thumbnails/2010-04-10FoundersDay-3.jpg',	'./photos/2010-04-10FoundersDay-3.jpg', 'Dont ask dont tell'),
	image('./photos/thumbnails/2010-04-10FoundersDay-4.jpg',	'./photos/2010-04-10FoundersDay-4.jpg', 'No suprises there'),
	image('./photos/thumbnails/2010-04-10FoundersDay-5.jpg',	'./photos/2010-04-10FoundersDay-5.jpg', 'Sleepy Spoodle'),
	image('./photos/thumbnails/2010-04-10FoundersDay-6.jpg',	'./photos/2010-04-10FoundersDay-6.jpg', 'Bro-ing-out'),
	image('./photos/thumbnails/2010-04-10FoundersDay-7.jpg',	'./photos/2010-04-10FoundersDay-7.jpg', 'The FARM'),
	
	image('./photos/thumbnails/2009-10-18HighwayCleanup2.jpg',	'./photos/2009-10-18HighwayCleanup2.jpg', 'Good enough for CAP'),
	image('./photos/thumbnails/2009-10-18HighwayCleanup3.jpg',	'./photos/2009-10-18HighwayCleanup3.jpg', 'Pledges are like hobbits'),
	image('./photos/thumbnails/2009-10-16PhillyTrip1.jpg',		'./photos/2009-10-16PhillyTrip1.jpg', 'McLovin makes happy with JQA'),
	image('./photos/thumbnails/2009-10-16PhillyTrip2.jpg',		'./photos/2009-10-16PhillyTrip2.jpg', 'Inquisitive Pablo'),
	image('./photos/thumbnails/2009-10-16PhillyTrip3.jpg',		'./photos/2009-10-16PhillyTrip3.jpg', 'Hmm, I concur'),
	image('./photos/thumbnails/2009-10-14GreekRunway2.jpg',		'./photos/2009-10-14GreekRunway2.jpg', 'Its a me LUGI'),
	image('./photos/thumbnails/2009-10-11DelawareMudRun1.jpg',	'./photos/2009-10-11DelawareMudRun1.jpg', 'Alumni Running Dirty'),
	image('./photos/thumbnails/2009-10-11DelawareMudRun2.jpg',	'./photos/2009-10-11DelawareMudRun2.jpg', 'Chum & BTom not Pictured'),
	image('./photos/thumbnails/thumbnail-1.jpg',				'./photos/photo-1.jpg', 'Flag Football'),
	image('./photos/thumbnails/thumbnail-2.jpg',				'./photos/photo-2.jpg', 'Plane Pull'),
	image('./photos/thumbnails/thumbnail-3.jpg',				'./photos/photo-3.jpg', 'Frankling Institute Science Museum'),
	image('./photos/thumbnails/thumbnail-4.jpg',				'./photos/photo-4.jpg', 'Spring Break!'),
	//image('./photos/thumbnails/thumbnail-5.jpg',				'./photos/photo-5.jpg', 'Shots with Beta Gamma'),
	image('./photos/thumbnails/thumbnail-6.jpg',				'./photos/photo-6.jpg', 'Ren on Bat'),
	image('./photos/thumbnails/thumbnail-7.jpg',				'./photos/photo-7.jpg', 'John, Rammick & Date'),
	image('./photos/thumbnails/thumbnail-8.jpg',				'./photos/photo-8.jpg', "Founder's Day"),
	image('./photos/thumbnails/thumbnail-17.jpg',				'./photos/photo-17.jpg', '70,000lbs later'),
	image('./photos/thumbnails/thumbnail-9.jpg',				'./photos/photo-9.jpg', 'Highway Cleanup'),
	image('./photos/thumbnails/thumbnail-10.jpg',				'./photos/photo-10.jpg', 'Moss in Montreal'),
	image('./photos/thumbnails/thumbnail-11.jpg',				'./photos/photo-11.jpg', 'John on Tight Pope'),
	image('./photos/thumbnails/thumbnail-12.jpg',				'./photos/photo-12.jpg', 'Tall is Paul'),
	image('./photos/thumbnails/thumbnail-13.jpg',				'./photos/photo-13.jpg', 'Robbins is Man'),
	image('./photos/thumbnails/thumbnail-14.jpg',				'./photos/photo-14.jpg', 'Fort 40% Complete'),
	image('./photos/thumbnails/thumbnail-15.jpg',				'./photos/photo-15.jpg', 'Real Men'),
	image('./photos/thumbnails/thumbnail-16.jpg',				'./photos/photo-16.jpg', 'Camping'));

function image(thumbnailSrc, imgSrc, caption){
	return new Array(thumbnailSrc, imgSrc, caption);
}

function loadPhotos(rootElementId){
	var rootPhotoElement = document.getElementById(rootElementId);
	var div = null;

	for(var i=0; i < PHOTOS.length; i++){
		div = createDivElement(PHOTOS[i]);
		rootPhotoElement.appendChild(div);
	}	
}

function createDivElement(img){
/* function returns an element of the following form:
	<div>
		<center>
			<a alt="photos[i][2]" rel="lightbox[0]" href="photos[i][1]">
				<div style="background-image:url(photos[i][0]);"> &nbsp </div>
			</a>
		</center>
	</div>
*/
	var div = document.createElement('DIV');
	div.setAttribute('class','thumbnail');
	
	var center = document.createElement('CENTER');

	var anchor = document.createElement('A');
	anchor.setAttribute('title',img[2]);
	anchor.rel = "group";
	anchor.href=img[1];
	
	var thumbnail = document.createElement('DIV');
	thumbnail.style.backgroundImage="url("+img[0]+")";
	thumbnail.innerHTML = '&nbsp';
	
	anchor.appendChild(thumbnail)
	center.appendChild(anchor);
	div.appendChild(center);
	return div;
}