
/*
	Caption Box
*/

$(document).ready(function() {
	$('img.captioned').each(function() {
		sFloat = ($(this).css('float') != 'none') ? '-' + $(this).css('float') : '';
		// Andrew - need to come back to why this isn't working... newlines in an alt tag is preferable to a <br />
		//$(this).attr('alt', $(this).attr('alt').replace(/\n/g, '<br />'));
		$(this).css('float', 'none');
		$(this).wrap('<div class="caption-box' + sFloat + '"></div>');
		$(this).after('<p>' + $(this).attr('alt') + '</p>');
	});
});

/*
	Thumbnail Gallery
*/
$(document).ready(function() {
	$('div.thumbnail-gallery').each(function() {
		aThumbs = new Array();
		
		var sGallery = $('#' + $(this).attr('id'));
		
		$(sGallery).children('div.thumbnail-gallery-thumbs').children('img').each(function() {
			aThumbs.push($(this).attr('src'));
			$(this).mouseover(function() {
				$(sGallery).children('img.gallery-mainimage').attr('src', $(this).attr('src'));
			});
		});
		
		if (aThumbs.length > 0) {
			$(sGallery).children('img.gallery-mainimage').attr('src', aThumbs[0]);
		}
	});
});
