//onLoad="loaded(this,w,h);"
function loaded(myimg,w,h){
var tmp_img = new Image();
tmp_img.src=myimg.src;
var mywidth=w;
var myhight=h;
image_x=tmp_img.width;
image_y=tmp_img.height;
	if(image_x > mywidth){//宽度大于要求
	tmp_img.height=image_y * mywidth / image_x;
	tmp_img.width=mywidth;}
	else if(image_y > myhight){//高度大于要求
	tmp_img.width=image_x * myhight / image_y;
	tmp_img.height=myhight;}
	myimg.width=tmp_img.width;
	myimg.height=tmp_img.height;
	window.status='loaded';
}

