$(window).load(function() {

	$('img').each(function() {
			var ratio = 1.8;  // Used for aspect ratio
			var maxWidth = parseInt($(window).width() / ratio); // Max width for the image
			var width = $(this).width();    // Current image width
			var height = $(this).height();  // Current image height
	 
			// Check if the current width is larger than the max
			if(width > maxWidth){
				ratio = maxWidth / width;   // get ratio for scaling image
				$(this).css("width", maxWidth); // Set new width
				$(this).css("height", parseInt(height * ratio));  // Scale height based on ratio
				$(this).css("border", "2px dashed #890000");  // Scale height based on ratio
				$(this).css("cursor", "pointer");  // Scale height based on ratio
				$(this).attr("title", "Click to enlarge");
			}
	});
});
