function thumb_resize which max var elem document getElementById which

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
function thumb_resize(which, max) {
var elem = document.getElementById(which);
if (elem == undefined || elem == null) return false;
var orig_width = elem.width;
var orig_height = elem.height;
if (max == undefined) max = 150;
if (elem.width > elem.height) {
if (elem.width > max) { elem.width = max; elem.height = orig_height*(max/orig_width);}
} else {
if (elem.height > max) { elem.height = max; elem.width = orig_width*(max/orig_height);};
}
}