$(document).ready(function(){
	
	// Handle article images
	$("img[rel]").click(function(){
		
		var uri = $(this).attr('rel');
		var description = $(this).attr('alt');
		var caption = $(this).parent().find('figcaption p').text();
		var position = $('#media').offset();
		
		// Set image attributes
		$('#media img').attr({
			src : uri,
			alt : description
		});
		
		// Set caption
		$('#media figcaption p').text(caption);
		
		// Scroll to the image
		$('body').animate({ scrollTop : position.top - 20 }, 200);
		
	});
	
	// Fix widows
	$("h1, h2, h3, h4, article p, .logo em").widont();
});
