/*实现图片适应当前大小并且按自动比例调节*/
function DrawImage(ImgD,w,h){ 
var image=new Image();
image.src=ImgD.src;
if(image.width>0 && image.height>0){
	if(image.width/image.height>1){
		if(image.width>w){
			ImgD.width=w;
			ImgD.height=(image.height*w)/image.width;
		}else{
			ImgD.width=image.width;
			ImgD.height=image.height;
		}
	}
	else{
		if(image.height>h){
			ImgD.height=h;
			ImgD.width=(image.width*h)/image.height;
		}else{
			ImgD.width=image.width;
			ImgD.height=image.height;
		}
	}
}
//setTimeout("DrawImage",100);
}


/*实现图片由半透明到不透明的逐步调节效果*/
function fadeIn(element, opacity) {
	var reduceOpacityBy = 5;
	var rate = 30;	// 15 fps


	if (opacity < 100) {
		opacity += reduceOpacityBy;
		if (opacity > 100) {
			opacity = 100;
		}

		if (element.filters) {
			try {
				element.filters.item("DXImageTransform.Microsoft.Alpha").opacity = opacity;
			} catch (e) {
				// If it is not set initially, the browser will throw an error.  This will set it if it is not set yet.
				element.style.filter = 'progid:DXImageTransform.Microsoft.Alpha(opacity=' + opacity + ')';
			}
		} else {
			element.style.opacity = opacity / 100;
		}
	}

	if (opacity < 100) {
		setTimeout(function () {
			fadeIn(element, opacity);
		}, rate);
	}
}

/*
var _flag=false;
	function DrawImage(ImgD,iwidth,iheight){
		var image=new Image();
		//var iwidth = 700; //定义允许图片宽度，当宽度大于这个值时等比例缩小
		//var iheight = 700; //定义允许图片高度，当宽度大于这个值时等比例缩小
		image.src=ImgD.src;
		if(image.width>iwidth || image.height>iheight){
			_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;
			}
		}
	}

*/
