function resizeImage(img,nWidth,nHeight){
	oWidth=img.width;
	oHeight=img.height;
	if(oWidth>nWidth){
			var r=oWidth/nWidth;//scale
			oWidth=nWidth;
			oHeight=oHeight/r;
		if(oHeight>nHeight){
			var r2=oHeight/nHeight;
			oHeight=nHeight;
			oWidth=oWidth/r2;
		}
	}else if(oHeight>nHeight){
		var r=oHeight/nHeight;//scale
		oHeight=nHeight;
		oWidth=oWidth/r;
		if(oWidth>nWidth){
			var r2=oWidth/nWidth;
			oWidth=nWidth;
			oHeight=oHeight/r2;
		}
	}
	img.width=parseInt(oWidth);
	img.height=parseInt(oHeight);
}

