/*--------------------------------------------------------------------
* This file controls the front-end album index page for PhotoGenoa.
*
* Dependencies: jQuery 1.3.2 and jQuery UI 1.7.1
*
* You should not need to modify this file unless you've heavily customized
* PhotoGenoa by, for instance, changing the size of the thumbnails it
* generates (in config.php).	
*
* -------------------------------------------------------------------- */
		

$(document).ready(function() {
	
	//Minimum size of album thumbnails, in pixels:
	var min_thumb_size = 75;
	
	//Maximum size of album thumbnails, in pixels:
	var max_thumb_size = 320;
	
	//Max number of album thumbnails on a single line:
	var max_albums_on_single_line = 3;
	
	//Vertical photo size-reducing multiplier:
	var vertical_reducer_multiplier = .8;
	
	
	
	
//*****************************************************************************************************************************	
//*****************************************************************************************************************************	
//********************************************* Do Not Modify Anything Below This Line ****************************************
	
	
	
	/* 
	 Change album title text color when user hovers over an album thumbnail
	*/
			$(".thumbs, .thumbs-vertical").hover(
				function() {
					$(this).next().addClass("album-title-hover");
				},
				function() {
					$(this).next().removeClass("album-title-hover");
				}
			);
	
	
	
	/*
	 Figure out what size to make album thumbnails to fit them on the page
	*/	
			var container_width = parseFloat( $('#photoBin').css('width'), 10 ); //photoBin is the div that holds all photoGenoa content.
	
			var init_left_margin = $('.album-wrapper').css('margin-left');
			var init_right_margin = $('.album-wrapper').css('margin-right');
			var init_margin = parseFloat(init_left_margin, 10) + parseFloat(init_right_margin, 10); //Strip the "px" from the returned margins

			var space_for_margins_at_max_thumb_size = init_margin * max_albums_on_single_line;
			var space_for_photos_at_max_thumb_size = container_width - space_for_margins_at_max_thumb_size - (max_albums_on_single_line * 2); //we subtract an extra two pixels for each photo just to give us a little buffer for browser idiosyncricies.


			var max_thumb_size_for_photoBin_width = Math.floor(space_for_photos_at_max_thumb_size / max_albums_on_single_line);
	
			//Thumbnails should never be larger than the actual thumbnail image size. 
			//if #photoBin were wide enough, the calculated thumbnail width could be 45,000 pixels.
			//That's bad, so we limit the thumbnail width here:
			if (max_thumb_size_for_photoBin_width < max_thumb_size) {
				max_thumb_size = max_thumb_size_for_photoBin_width;
			}
			
			$('.album-wrapper').width(max_thumb_size);
			$('.album-wrapper').height(max_thumb_size * vertical_reducer_multiplier);  //The muliplier reduces the overall size of vertical images relative to horizontal ones. This produces a tighter, more visually-pleasing grid of photos.
});


