$(document).ready(function() {
	$.ajax({
		type: "GET",
		url: "/cms-assets/image-galleries/whats-new.xml",
		dataType: "xml",
		success: function(xml) {
			$(xml).find('ImageGalleryEntry').each(function(index){
				if (index < 13) {
					var file = $(this).attr('FileName');
					var caption = ($(this).attr('Description')) ? $(this).attr('Description') : '';
					if (index == 0) {
						$('#large').attr('src', '/cms-assets/image-galleries/whats-new/images/' + file);
					}
					$('<div></div>').attr('class','thumb').attr('id','whatsnew-' + index).html('<img src=/cms-assets/image-galleries/whats-new/thumbnails/' + file + ' alt="' + caption + '" width="46" height="100"/>').appendTo('#rightCol');
					var preloadImg = $('<img />').attr('src','/cms-assets/image-galleries/whats-new/images/' + file);
				}
			});
			/* handler for images on new-stuff page */
			$('#large').attr('alt', $('.page-whatsnew .thumb:first').find('img').attr('alt'));
			$('#description').html('<p>' + $('.page-whatsnew .thumb:first').find('img').attr('alt') + '</p>');
			$('.page-whatsnew .thumb img').bind('mouseover', function() {
				var caption = $(this).attr('alt');
				$('#description').html('<p>' + caption + '</p>');
				$('#large').attr('src', $(this).attr('src').replace('thumbnails','images'));
				$('#large').attr('alt', caption);
			});
		}
	});
});
