// Open external links in new window
$(document).ready(function() {
	$("a[@href^=http]").each(function() {
		if(this.href.indexOf(location.hostname.replace(/www./gi, "")) == -1) {
			$(this).click(function() { window.open(this.href, "_blank"); return false; });
		}
	})
});

// Add captions from title attribute
// Must be after page is loaded to get
// the correct width calculation
$(window).load(function() {
	$("img.photo-caption").each(function() {
		$(this).wrap('<div class="caption">' + '</div>');
		$(this).parent().width($(this).width());
		if($(this).hasClass("right")) {
			$(this).parent().addClass("right");
			$(this).removeClass("right");
		}
		if($(this).hasClass("left")) {
			$(this).parent().addClass("left");
			$(this).removeClass("left");
		}
		$(this).after($(this).attr('title'));		
	})
});