function resize(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 resize1(img,hmax,wmax)
{
	var hscale,wscale,scale,newwidth,newheight;
	
	hscale = img.height / hmax;
	wscale = img.width / wmax;
	if( (hscale > 1)||(wscale > 1) )
	{
		scale = (hscale > wscale) ? hscale: wscale;
	}
	else
	{
		scale = 1;
	}
	newwidth = Math.floor(img.width / scale);
	newheight= Math.floor(img.height / scale);
	img.height=newheight;
	img.width=newwidth;	 
}