function myresize(which, max) {
  var elem = document.getElementById(which);
  if (elem == undefined || elem == null) return false;
  if (max == undefined) max = 100;
  if (elem.width > elem.height) {
    if (elem.width >max) elem.width = max;
  } else {
    if (elem.height > max) elem.height = max;
  }
}		

function fixImgs(whichId, maxW) {
  var pix=document.getElementById(whichId).getElementsByTagName('img');
  for (i=0; i<pix.length; i++) {
    w=pix[i].width;
    h=pix[i].height;
    if (w > maxW) {
      f=1-((w - maxW) / w);
      pix[i].width=w * f;
      pix[i].height=h * f;
    }
  }
}

function myFixImgs(whichId, maxW) {

  var elem = document.getElementById(whichId);
   w=elem.width;
   h=elem.height;
	
   if (w > maxW) {
     f=1-((w - maxW) / w);
     elem.width=w * f;
     elem.height=h * f;
   }
}

function zz(whichId, max) {
  var image = document.getElementById(whichId);

	image.removeAttribute('width');
	image.removeAttribute('height');
	var width = image.naturalWidth || image.width;
	var height = image.naturalHeight || image.height;

	ratio = Math.min( max / width, max / height );
	
	if (width > max) {
		width = ratio * width;
		height = ratio * height;		
	}

	image.width = width;
	image.height = height;
}
