size = 168;

 function resize(id) {
  if (document.images[id].width > document.images[id].height) document.images[id].width = size ;
  else document.images[id].height = size ;
 }