$(document).ready(function() {
	
		$('.gallery-icon a').click(function(event){
			event.preventDefault();
		});
		
		var img_width = 0;
		
		// set width of div outside right-aligned image to be width of image
		$(".alignright a img").each(function(){
			img_width = $(this).width();
			$(this).parent().parent().css("width", img_width);
		});
		
		$(".alignright img").each(function(){
			img_width = $(this).width();
			$(this).parent().css("width", img_width);
		});
		
		// set width of div outside left-aligned image to be width of image
		$(".alignleft a img").each(function(){
			img_width = $(this).width();
			$(this).parent().parent().css("width", img_width);
		});
		
		$(".alignleft img").each(function(){
			img_width = $(this).width();
			$(this).parent().css("width", img_width);
		});
		
		// add three spaces before each paragraph that is indented using WordPress's indent tool
		/*$(".entry-content p").each(function(){
			if ($(this).css("padding-left") == "30px"){
				$(this).css("padding-left", "0");
				$(this).prepend("&nbsp;&nbsp;&nbsp;");
			}
		});*/
		
		// add 50px to the left of each paragraph that is 
		// (a) indented using WordPress's indent tool and is 
		// (b) to the right of an image
		$(".entry-content p").each(function(){
			if ($(this).css("padding-left") == "30px" && $(this).prev().is("img")){
				img_width = $(this).prev().width();
				$(this).css("padding-left", (img_width + 50) + "px");
			}
			if ($(this).css("padding-left") == "30px" && $(this).prev().prev().is("img")){
				img_width = $(this).prev().prev().width();
				$(this).css("padding-left", (img_width + 50) + "px");
			}
		});
	
});