function ImgSize(i,MaxW,MaxH,sFont,autoS){
var o = new Image();
o.src = i.src;
if(o.width>0 && o.height>0){
	if(MaxW!=0 && MaxH!=0){ //Ex:ImgSize(this,120,120,'',120)
         if(o.width/o.height>=MaxW/MaxH){
             if(o.width>MaxW){
               i.width = MaxW;
               i.height = (o.height*MaxW)/o.width;
             }else{
               i.width = o.width;
               i.height = o.height;
             }
         }else{
             if(o.height>MaxH){
               i.height = MaxH;
               i.width = (o.width*MaxH)/o.height;
             }else{
               i.width = o.width;
               i.height = o.height;
             }
         }
	}else{
		 if(MaxW==0 && MaxH!=0){ //Ex:ImgSize(this,0,120,'',120)
			 if(o.height>=MaxH) i.height = MaxH;
		 }else if(MaxW!=0 && MaxH==0){ //Ex:ImgSize(this,120,0,'',120)
			 if(o.width>=MaxW) i.width = MaxW;
		 }else if(MaxW==0 && MaxH==0){ //Ex:ImgSize(this,0,0,'',120)，一般需要填满容器时用到
		 	 if(isNaN(autoS))autoS=120;
			 if(o.width/o.height>=1){
			 	if(o.width>autoS) i.width = autoS;
			 }else{
			 	if(o.height>autoS) i.height = autoS;
			 }
		 }
	}
    if(sFont) i.alt = sFont; //Ex:ImgSize(this,120,120,'显示信息',120)
}
}