$(document).ready(function(){
	$(".pullpic img").each(function(){
		if (typeof(this.style.maxHeight) == "undefined")
		{ //This is Internet Explorer 6 or another silly browser that doesn't recognize "max-height"/"max-width" constraints
			this.onload = function () {
				if (400 * (this.height / this.width) > 300)
				{ //Resize by height if setting with=400 would violate height<=300:
					this.style.width = "auto";
					this.style.height = "300px";
				}
				else
				{ //Resize by width if setting width=400 is fine (height constraint not violated):
					this.style.height = "auto";
					this.style.width = "400px";
				}
			};
		}
		else
		{ //Well-behaved browsers don't need forced width
			this.style.width = "auto";
		}
	});
});
