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 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 resizeImage(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;
}