function set_image_size ( org_image, max_height_arg, max_width_arg ) {

		var max_height = parseInt(max_height_arg);
		var max_width = parseInt(max_width_arg);

		var image_obj = new Image();
		image_obj.src = org_image.src;

		var image_height = image_obj.height;
		var image_width = image_obj.width;

		if ( isNaN(parseInt(max_height + max_width)) 
             || ! org_image 
             || ( image_height > 0 && image_height <= max_height && image_width > 0 && image_width <= max_width ) 
             || image_height == 0 
             || image_width == 0 ) {
			return;
		}

		var bigger_dim = ( image_height / max_height ) >= ( image_width / max_width ) ? 'height' : 'width';

		var resize_ratio;
		var new_height;
		var new_width;

		if ( bigger_dim == 'height' ) {
			resize_ratio = parseFloat( max_height / image_height );
			var aspect_ratio = parseFloat( image_height / image_width );
			new_height = parseInt( image_height * resize_ratio );
			new_width = parseInt( new_height / aspect_ratio );
		}
		else {
			resize_ratio = parseFloat(max_width / image_width);
			var aspect_ratio = parseFloat(image_width / image_height );
			new_width = parseInt(image_width * resize_ratio);
			new_height = parseInt(new_width / aspect_ratio);
		}

		org_image.height = new_height;
		org_image.width = new_width;
	
}

