$(function() {
	$("a.fancybox").fancybox();

	$('.bodycopy pre').mouseenter(function() {
		if ($(this).data('original_width') == undefined)
			$(this).data('original_width', $(this).width());

		original_width = $(this).data('original_width');
		
		// map all children onto code_widths
		code_widths = $(this).children().map(function() {
			return $(this).width();
		});

		// get the largest item in array
		code_width = Math.max.apply(Math, code_widths.get());

		if (code_width > original_width) {
			$(this)
				.stop(true)
				.animate({ width: code_width }, 'fast');
			
			$(this).mouseleave(function() {
				$(this)
					.delay(1000)
					.animate({ width: original_width }, 'fast', function() {
						$(this).stop(true);
					});
			});
		}
	});
});