function createAlbum(i){	
	// Album data
	var data = albums[i].photos;
	// Index of slide in slides array
	var index = 0;	
	// Holder for current slide
	var current;	
	// Width of slides plus margin
	var slideWidth = 119;	
	// Width of elements that fit inside clipped area (plus margin)
	var filmstripWidth = 714;	
	// Anything greater than this will be out of view and need to be animated into view
	var xLimit = filmstripWidth - slideWidth;	
	// Total number of slide elements
	var numberOfSlides = data.length;	
	// Total width of slide elements
	var totalWidth = slideWidth * numberOfSlides;
	// Position for thumb list
	var pos;
	// Left position for thumb list
	var posLeft;
	
	var ul = $('<ul id="thumbs"></ul>');
	$(ul).css('width', totalWidth);
	
	$('#filmstrip').append(ul);	
	
	$.each(data, function(i, value) {
 		//create item 
		var li = $('<li></li>');
		 //create link  
		var imageLink = $('<a></a>')
		.click(function() {
			current = this;
			index = $('#thumbs li a').index(this);
			showImage(i, value.lrg, value.title);
			return false;
		})
		.html('<img src="'+value.sml+'" alt="'+value.title+'" title="'+value.title+'" width="100" height="90" />')
		.attr({href:value.lrg});
		
		// Append list item to list
		$(ul).append(li);
		// Add image and link to list item
		$(li).append(imageLink);
	});
	
	
	showImage(0, data[0].lrg, data[0].title);
	reflectImages('#thumbs img', 0.2, 0.33);
	
	$('#next a').click(function(){
		// Get next list item sibling
		current = $('#thumbs li a').eq(index).parent().next().find('a');
		if(index == numberOfSlides - 1){
			current = $('#thumbs li:first a');
			index = 0;
			$('#thumbs').animate({'marginLeft' : 0});
		} else {
			// Get position of current slide
			pos = $(current).position();				
			// Get x position of current slide
			posLeft = pos.left;
			index++;
			if (posLeft > filmstripWidth -slideWidth) {
				$('#thumbs').animate({'marginLeft' : '-='+slideWidth});
			}
		}			
		showImage(index, data[index].lrg, data[index].title);
		return false;
	});
	$('#photo img').click(function(){
		// Get next list item sibling
		current = $('#thumbs li a').eq(index).parent().next().find('a');
		if(index == numberOfSlides - 1){
			current = $('#thumbs li:first a');
			index = 0;
			$('#thumbs').animate({'marginLeft' : 0});
		} else {
			// Get position of current slide
			pos = $(current).position();				
			// Get x position of current slide
			posLeft = pos.left;
			index++;
			if (posLeft > filmstripWidth -slideWidth) {
				$('#thumbs').animate({'marginLeft' : '-='+slideWidth});
			}
		}			
		showImage(index, data[index].lrg, data[index].title);
		return false;
	});
	$('#prev a').click(function(){				
		// Get next list item sibling
		current = $('#thumbs li a').eq(index).parent().prev().find('a');
		// Get previous list item sibling		
		if(index == 0) {
			current = $('#thumbs li:last a');
			index = numberOfSlides-1;
			$('#thumbs').animate({'marginLeft' : -(totalWidth - filmstripWidth)});
		} else {
			// Get position of current slide
			pos = $(current).position();				
			// Get x position of current slide
			posLeft = pos.left;
			index--;
			if (posLeft < 0) {
				$('#thumbs').animate({'marginLeft' : '+='+slideWidth});
			}
		}
		showImage(index, data[index].lrg, data[index].title);
		return false;
	});		
}
function showImage(num, imgSrc, imgAlt) {
	$('#loader').css('opacity', 0);
	$('#loader').stop();
	$('#loader').fadeTo(600, 0.7);
	$('#thumbs li a.selected').removeClass('selected');
	$('#thumbs li a').eq(num).addClass('selected');
	//$('#photo img').attr({ src: imgSrc, alt: imgAlt});
	$('#photo img').load(function () {
		$('#loader').stop();
		$('#loader').fadeTo(300, 0);
	})
	.error(function () {
		// notify the user that the image could not be loaded
	})
	.attr({ src: imgSrc, alt: imgAlt});
}
// Creates reflection for thumbnail images.
function reflectImages(images, h, o) {	
	// Grab each image
	$(images).each(function(){
		// When loaded, create reflection
		$(this).load( 
			function(){ 
				$(this).reflect({height: h, opacity: o} );
			} 
		);
	});	
}
/* 
	createTabs(tabList,	tabContent, tabNumber)

	Create tabs from an unordered list.
	
	tabList: unordered list to turn into tabs. Point to the elements anchor.
	tabContent: content belonging to a tab. Point to the content container of each tab.
	tabNumber: select which tab to show first. Begin at 0.
	
*/
function createTabs(tabList, tabContent, tabNumber) {
	//Unhide tabs
	$(tabList).parents('ul').show();
	
	// Hide all content
	$(tabContent).hide();
	
	// Show and activate requested tab
	$(tabContent).eq(tabNumber).show();
	$(tabList).eq(tabNumber).parent('li').addClass('active');
	
	$(tabList).click(function(){						   
		
		// Get current tab via anchor
		currentTab = $(this).attr('href');
		
		// Remove active class from all tabs
		$(tabList).parent('li').removeClass('active');
		
		// Add active class to current tab
		$(this).parent('li').addClass('active');	
		
		// Hide all content
		$(tabContent).hide();
		
		// Show current tab content
		$(currentTab).show();
		
		// Prevent URL showing in address bar
		return false;
	});
}
// Loop through billboard images on home page
function slideShow() {
	$('.panel-overlay').css('opacity', 0.9);
	$('#billboard').cycle({ 
		fx:			'fade',
		speed:		2000,
		timeout:	6000
 	});	
}
function randomPhoto(target, size, start, end) {
	// Get random album
	var randAlbumNum = Math.floor(albums.length*Math.random());
	// Get list of photos from selected album
	var photoList = albums[randAlbumNum].photos;
	// Get random photo from range of numbers to avoid using the same image
	var randPhotoNum = Math.floor((end-(start-1))*Math.random()) + start;
	// Get photo from random number
	var photo = photoList[randPhotoNum];
	// If size is medium get medium image, else get small image
	if (size == 'm') {
		$(target).html('<img src="'+photo.med+'" alt="'+photo.title+'" title="'+photo.title+'" width="220" height="198" />');
	} else if (size == 's') {
		$(target).html('<img src="'+photo.sml+'" alt="'+photo.title+'" title="'+photo.title+'" width="100" height="90" />');
	}	
}