//让图片不变形，修改图片的最大高和宽值

function DrawImage(ImgD,MaxWidth,MaxHeight){ 
var image=new Image(); 
image.src=ImgD.src; 
	if(image.width>0 && image.height>0){ 
		if(image.width/image.height>= MaxWidth/MaxHeight){ 
			if(image.width>MaxWidth){
			ImgD.width=MaxWidth; 
			ImgD.height=(image.height*MaxWidth)/image.width; 
			}else{ 
			ImgD.width=image.width;
			ImgD.height=image.height; 
			} 
			//ImgD.alt="点击新窗口中查看大图..."; 
		} 
		else{ 
			if(image.height>MaxHeight){
			ImgD.height=MaxHeight; 
			ImgD.width=(image.width*MaxHeight)/image.height; 
			}else{ 
			ImgD.width=image.width;
			ImgD.height=image.height; 
			} 
			//ImgD.alt="点击新窗口中查看大图..."; 
		} 
	}
}
drawimageAll=function()
{
    var MaxWidth=140;
    var MaxHeight=106;
    var obj = document.aspnetForm.drawimage;
    if(obj != null)
	{
	    for(var ii=0; ii < obj.length; ii++)
	    {
            var image=new Image(); 
            image.src=obj[ii].src;
            if(image.width>0 && image.height>0)
            {
                if(image.width/image.height>= MaxWidth/MaxHeight)
                {
                    if(image.width>MaxWidth){
			        obj[ii].width=MaxWidth; 
			        obj[ii].height=(image.height*MaxWidth)/image.width; 
			        }else{ 
			        obj[ii].width=image.width;
			        obj[ii].height=image.height; 
			        } 
                }
		        else{ 
			        if(image.height>MaxHeight){
			        obj[ii].height=MaxHeight; 
			        obj[ii].width=(image.width*MaxHeight)/image.height; 
			        }else{ 
			        obj[ii].width=image.width;
			        obj[ii].height=image.height; 
			        }
		        } 
            }       
	    }	    
	}
}
