function pimsize(imgname,widths,heights){ 

var w; 

var h; 

//window.alert(picimg.width); 

//window.alert(picimg.height); 

w=imgname.width; 

h=imgname.height; 

if(imgname.width>widths){ 

do 

w=w-1; 

while (w>widths) ; 



s=w/imgname.width; 

//window.alert(s); 

imgname.width=w; 

imgname.height=h*s; 

h=imgname.height 

} 

//window.alert(imgname.height); 

//window.alert(heights); 

if(imgname.height>heights){ 

do 

h=h-1; 

while (h>heights) ; 



s=h/imgname.height; 

//window.alert(s); 

imgname.width=w*s; 

imgname.height=heights; 

} 

} 