function DimensionaImagen(img,anchomaximo,altomaximo){
	var x, y;
	x = y = 0;
	x = img.width;
	y = img.height;
	if(isNaN(x) || isNaN(y)){
	   img.style.visibility = 'hidden';
	   return false;
	}
	if(x>anchomaximo){
	   porcentaje = anchomaximo / x;
	   x= Math.round(x * porcentaje);
	   y= Math.round(y * porcentaje);
	}
	if(y>altomaximo){
	   porcentaje = altomaximo / y;
	   x= Math.round(x * porcentaje);
	   y= Math.round(y * porcentaje);
	}
	img.width  = x;
	img.height = y;
	return true;
}
