function ResizeImage(obj, newW, newH)
{
    if(obj == null) return;
    var oImg = new Image();
    oImg.src = obj.src;
    var oldW=oImg.width;
	var oldH=oImg.height;
	//准备传递变量
	if(document.getElementById("dwPicWidth"))
		document.getElementById("dwPicWidth").value=oldW;
	if(document.getElementById("dwPicHeight"))
		document.getElementById("dwPicHeight").value=oldH;
		
    if(oldW>newW || oldH>newH) {
        w=oldW/newW; 
		h=oldH/newH;
        if(h>w) w=h;
        oldW=oldW/w; 
		oldH=oldH/w;
    }
    if(oldW > 0 && oldH > 0)
        obj.width=oldW;
		obj.height=oldH;
    if(obj.width>newW || obj.height>newH) {
        setTimeout("ResizeImage(null,"+newW+","+newH+")",40);
    }
}
