function autoresizeimage(maxwidth,maxheight,objimg){ var img = new image(); img.src = objimg.src; var hratio; var wratio; var ratio = 1; var w = img.width; var h = img.height; wratio = maxwidth / w; hratio = maxheight / h; if (maxwidth ==0 && maxheight==0){ ratio = 1; }else if (maxwidth==0){// if (hratio<1) ratio = hratio; }else if (maxheight==0){ if (wratio<1) ratio = wratio; }else if (wratio<1 || hratio<1){ ratio = (wratio<=hratio?wratio:hratio); } if (ratio<1){ w = w * ratio; h = h * ratio; } objimg.height = h; objimg.width = w; }