/*
 * jQuery FlickrGallery - jQuery plug-in
 * Version 1.0.1, Released 
 *
 * Copyright (c) 2008 Steven Dugas
 * This work is licensed under a Creative Commons Attribution 3.0 Unported License.
 */
(function($) {
$.fn.flickrDisplay = function(options) {

 var defaults = {
		flickrAPIKey: '', // [string], required for Flickr gallery.
		photosetID: '', // [string], required for Flickr gallery.
		per_page: '' // [integer], amount of thumbnails per 'page'.
  };
  //var options = $.extend(defaults, options);
	//options.galleryHeight = 'auto';
  return this.each(function() {
	obj = $(this);

	// Massive function to create the Image Gallery and register all event handlers. Must be a function to recreate gallery on Next/Prev Page.
	function makeGallery(){
		
		// Create Variables
		var theCaption;
		var container;
		var stepCount;
		var count = 1;
		var totalImageCount = 0;
		var currentImageCount = 1;	
		thumbs = obj.find('ul');
		thumbs.addClass('galleryUL');			
	
		// Add unique IDs to each thumbnail image

		count = 1;
		totalImageCount = 0;
		currentImageCount = 1;
		obj.find('.galleryUL img').each(function(){
			var IESRC = $(this).attr('src');
			$(this).attr('src',IESRC);
			$(this).attr('id','galleryThumb_'+count);
			/*h = (125 - $(this).attr("height")) / 2;
			$(this).css("margin-top", h);*/
			count++;
			totalImageCount++;
		});		
		
	}

		obj.flickr({     
			api_key: options.flickrAPIKey,     
			type: 'photoset',
			photoset_id: options.photosetID,
			thumb_size: 't',
			per_page: options.per_page,
			page: options.page,
			callback: function(){ 
				makeGallery();
			}
		});
  });
 };
})(jQuery);
