jQuery(document).ready(function($) {

$('div.photo').each(function(){
	var options_div = $(this).children('.options');
	options_div.removeClass('nojquery');
	options_div.css('display', 'none');
	$(this).hover(function(){
		options_div.stop();
		options_div.fadeTo(400, 1);
	}, function() {
		options_div.stop();
		options_div.fadeOut(400);
	});
});
	
$('a.before-after-link').each(function(){
	var img = $(this).closest('div.photo').find('img.photo-img');
    var img_after = img.attr('src'); // initial src
    var img_before = img_after.substring(0, img_after.lastIndexOf('.')) + '_before.' + /[^.]+$/.exec(img_after);
    $(this).toggle(function(){
        change_image(img, img_before);
        $(this).html($(this).html().replace('before','after'));
    }, function(){
        change_image(img, img_after);
        $(this).html($(this).html().replace('after','before'));
    });
});

$('#shrink').click(function(event){
		event.preventDefault();
		$('#content').css('width','600px');
		$('div.photo').each(function(){
			$(this).css("max-width", $(this).width()+'px');
			$(this).animate({
			    "max-width": "600px"
			  }, 5000, function() {
			    // Animation complete.
	    });
	});
});

});

function change_image(img, src) {
	img.attr('src', src);
};

