function ImgSize(o,w,h,p){
	var $ = function(o){return typeof o=="string" ? document.getElementById(o) : o},
	m = new Image(); o = $(o); m.src = o.src;
	if(m.width>0 && m.height>0){
		if(w!=0 && h!=0){ //ImgSize(this,120,120)
			if(m.width/m.height>=w/h){
				if(m.width>w){
					o.width = w;o.removeAttribute("height");
					//o.height = (m.height*w)/m.width;
				}
			}else{
				if(m.height>h){
					o.height = h;o.removeAttribute("width");
					//o.width = (m.width*h)/m.height;
				}
			}
		}else{
			if(w==0 && h!=0){ //ImgSize(this,0,120)
				if(m.height>h){o.height = h;o.removeAttribute("width")}
			}else if(w!=0 && h==0){ //ImgSize(this,120,0)
				if(m.width>w){o.width = w;o.removeAttribute("height")}
			}else if(w==0 && h==0){ //ImgSize(this,0,0,120)[ÌîÂúÈÝÆ÷ÓÃ]
				var f = isNaN(p) ? 120 : parseInt(p);
				if(m.width>=m.height){
					if(m.width>f){o.height = f;o.removeAttribute("width")}
				}else{
					if(m.height>f){o.width = f;o.removeAttribute("height")}
				}
			}
		}
		if(p && isNaN(p)) o.title = p; //ImgSize(this,120,120,'ÏÔÊ¾ÐÅÏ¢')
	}
}
