// JavaScript Document
/*------------------------------------------------------
 * Subject: 使用 javascript 函数 完美控制页面图片显示大小 By shawl.qiu  
 * 使用:
 * --------------------------------------
 * 1. Javascript 脚本块
 *window.onload=function(){
 *fResizeImg(500, 500, 'img');
 *------fResizeImg(500, 500);------
 *}
 *
 * 2. html body 标签
 * <body onload="fResizeImg(500, 500, 'textMain');" >
 * --------------------------------------
 * 注: 必须在页面加载完毕后使用本函数(这是基本的客户端应用概念)
 *-------------------------------------------------------*/
//---------------------------------begin function fResizeImg();
function fResizeImg(w, h, id){
var img='';
var obj;
if(id==undefined)obj=document.images;
else obj=document.getElementsByTagName('img');
//alert(obj.length);
for(var i=0; i<obj.length; i++)
{
img=obj[i];
if(img.name=="imgss22")
{
	if(img.width>w&&(img.height<img.width)){
	img.height=img.height-(img.height/(img.width/(img.width-w)))
	img.width=w;
	}else if(img.height>h&&(img.height>img.width)){
	img.width=img.width-(img.width/(img.height/(img.height-h)))
	img.height=h;
	}else if((img.width>w||img.height>h)&&(img.height==img.width))
	{
		img.width=w;
		img.height=h;
	}

} // shawl.qiu script
}
}
//---------------------------------end function fResizeImg();
//]]&gt;
