function buildGallery(feed) {

	$.getJSON(feed+"&format=json&jsoncallback=?", function(data){
			$.each(data.items, function(i,item){
				$("<img/>").attr("src", item.media.m.replace(/_m\.jpg/g,'_b.jpg')).appendTo("#galleryThumbs").wrap("<li></li>");
				$('#galleryThumbs li:first').addClass('active');
			});
			
			$('ul#galleryThumbs').galleria({
				history   : false, // activates the history object for bookmarking, back-button etc.
				clickNext : true, // helper for making the image clickable
				insert    : '#galleryImg', // the containing selector for our main image
				onImage   : function(image,thumb) { // let's add some image effects for demonstration purposes

					// fade in the image & caption
					if(! ($.browser.mozilla && navigator.appVersion.indexOf("Win")!=-1) ) { // FF/Win fades large images terribly slow
						image.css('display','none').fadeIn(1000);
					}

					// fetch the thumbnail container
					var _li = thumb.parents('li');

					// fade out inactive thumbnail
					_li.siblings().children('img.selected').fadeTo(500,0.3);

					// fade in active thumbnail
					thumb.fadeTo('fast',1).addClass('selected');

					// add a title for the clickable image
					image.attr('title','Next image >>');
				}
			});
			
			$("#carousel img").click(function() {
				$("#carousel img.active").removeClass("active");
				$(this).addClass("active");
			});
			
		});

}

$(document).ready(function() {
	$("img.post-image[src='']").parent('div.postpage-image').remove();
});
