Proportional Image Resize in JavaScript