function generateThumbnails(images)
{
	// Make sure we're only dealing with actual images.
	$(images).filter('img').each(function(index)
	{
		var image = $(this);
		var container = image.parent();
		if (container.is('a'))
		{
			// Don't bother generating thumbnails if a link's already provided.
			return;
		}
		
		// Generate a link to surround the image.
		image.wrap('<a href="' + image.attr('src') + '" class="scaled"></a>');
		container = image.parent();
		
		// Generate scaled thumbnails. Thanks Galleria!
		var width = Math.ceil(image.width() / image.height() * container.height());
		var height = Math.ceil(image.height() / image.width() * container.width());
		if (width < height)
		{
			image.css({ height: 'auto', width: container.width(), marginTop: - (height - container.height()) / 2 });
		}
		else
		{
			image.css({ width: 'auto', height: container.height(), marginLeft: - (width - container.width()) / 2 });
		}
	});
}