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;
}
}
<a href='ProductDetail.asp?ID=<%=rs_proShow("id")%>&SortID=<%=rs_proShow("SortID")%>'><img src="<%=rs_proShow("smallPic")%>" οnlοad="pimsize(this,180,140)" border="0" /></a>