var flag=false;

function DrawImage(ImgD,w,h){
	var image=new Image();
	var iwidth = w; //定义允许图片宽度
	var iheight = h; //定义允许图片高度
	image.src=ImgD.src;
	if(image.width>0 && image.height>0){
	flag=true;
	if(image.width/image.height>= iwidth/iheight){
		if(image.width>iwidth){ 
			ImgD.width=iwidth;
			ImgD.height=(image.height*iwidth)/image.width;
		}else{
			ImgD.width=image.width; 
			ImgD.height=image.height;
		}

		//ImgD.alt=image.width+"×"+image.height;
	}
	else{
		if(image.height>iheight){ 
		ImgD.height=iheight;
		ImgD.width=(image.width*iheight)/image.height; 
		}else{
		ImgD.width=image.width; 
		ImgD.height=image.height;
		}
		//ImgD.alt=image.width+"×"+image.height;
	}
}
}
function _setImageSize(root,classname,w,h)
{
	for (var i = 0; i < root.childNodes.length; ++i) {
		var obj = root.childNodes[i];
		if (obj.className==classname) {
			DrawImage(obj,w,h);
		} else if (obj.hasChildNodes()) {
			_setImageSize(obj, classname,w,h);
		}
	}
}
function setImageSize(classname,w,h)
{
	if(w==0)
		w=80;
	if(h==0)
		h=80;
	_setImageSize(document.documentElement, classname,w,h);
}


