function resize(which, max) {
    var elem = document.getElementById(which);
    if (elem == undefined || elem == null) return false;
    if (max == undefined) max = 100;
  if (elem.width > max || elem.height > max) {
       if (elem.width < elem.height) {
           max = (max*elem.width/elem.height)
           // elem.width = max;
           // elem.writeAttribute({width : max});
           // alert(max);
       }
       elem.width = max;
  }
  // alert(elem.width);
}