<!--
//同比例缩放图片大小
//alert("test");
//var flag=false;
function DrawImage(ImgD){
	
	var image=new Image();
	image.src=ImgD.src;
	if(image.width>0 && image.height>0){
		//flag=true;
		if(image.width/image.height>= 200/150){
			if(image.width>200){
				ImgD.width=200;
				ImgD.height=(image.height*200)/image.width;
				//alert(ImgD.width+' '+ImgD.height)
			}else{
				ImgD.width=image.width;
				ImgD.height=image.height;
			}
			/*ImgD.alt="bigpic" */
		}else{
			if(image.height>150){
				ImgD.height=150;
				ImgD.width=(image.width*150)/image.height;
			}else{
				ImgD.width=image.width;
				ImgD.height=image.height;
			}
		/*ImgD.alt="bigpic" */
		}
	}
}
function DrawBigImage(ImgD){
	
	var image=new Image();
	image.src=ImgD.src;
	if(image.width>0 && image.height>0){
		//flag=true;
		if(image.width/image.height>= 500/375){
			if(image.width>500){
				ImgD.width=500;
				ImgD.height=(image.height*500)/image.width;
				//alert(ImgD.width+' '+ImgD.height)
			}else{
				ImgD.width=image.width;
				ImgD.height=image.height;
			}
			/*ImgD.alt="bigpic" */
		}else{
			if(image.height>375){
				ImgD.height=375;
				ImgD.width=(image.width*375)/image.height;
			}else{
				ImgD.width=image.width;
				ImgD.height=image.height;
			}
		/*ImgD.alt="bigpic" */
		}
	}
}
function DrawSmallImage(ImgD){
	
	var image=new Image();
	image.src=ImgD.src;
	if(image.width>0 && image.height>0){
		//flag=true;
		if(image.width/image.height>= 120/90){
			if(image.width>120){
				ImgD.width=120;
				ImgD.height=(image.height*120)/image.width;
				//alert(ImgD.width+' '+ImgD.height)
			}else{
				ImgD.width=image.width;
				ImgD.height=image.height;
			}
			/*ImgD.alt="bigpic" */
		}else{
			if(image.height>90){
				ImgD.height=90;
				ImgD.width=(image.width*90)/image.height;
			}else{
				ImgD.width=image.width;
				ImgD.height=image.height;
			}
		/*ImgD.alt="bigpic" */
		}
	}
}

var imageObject;
function ResizeImage(obj, MaxW, MaxH)
{
    if (obj != null) imageObject = obj;
    var state=imageObject.readyState;
	if(state!='complete') {
        setTimeout("ResizeImage(null,"+MaxW+","+MaxH+")",50);
		return;
    }
    var oldImage = new Image();
    oldImage.src = imageObject.src;
    var dW=oldImage.width; var dH=oldImage.height;
    if(dW>MaxW || dH>MaxH) {
        a=dW/MaxW; b=dH/MaxH;
        if(b>a) a=b;
        dW=dW/a; dH=dH/a;
    }
    if(dW > 0 && dH > 0) {
        imageObject.width=dW;
		imageObject.height=dH;
	}
}


function PreviewImg(imgFile,no)
{
    //原来的预览代码，不支持 IE7。
    //var oldPreview = document.getElementById("oldPreview");
    //oldPreview.innerHTML = "<img src=\"file:\\\\" + imgFile.value + "\" width=\"80\" height=\"60\" />";
    
    //新的预览代码，支持 IE6、IE7。
	if(imgFile.value.IsPicture()==false){
		alert('请选择正确的图片格式！');
		return false;
	}
    var previewImage = document.getElementById("previewImage"+no);
	previewImage.innerHTML='';
	imgFile.select();
    previewImage.filters.item("DXImageTransform.Microsoft.AlphaImageLoader").src = document.selection.createRange().text;
    DrawImage(previewImage);
}

// 增加一个名为 IsPicture 的函数作为
// String 构造函数的原型对象的一个方法。
String.prototype.IsPicture = function()
{
	//判断是否是图片 - strFilter必须是小写列举
	var strFilter=".jpeg|.gif|.jpg|.png|.bmp|.pic|"
	if(this.indexOf(".")>-1)
	{
		var p = this.lastIndexOf(".");
		//alert(p);
		//alert(this.length);
		var strPostfix=this.substring(p,this.length) + '|';        
		strPostfix = strPostfix.toLowerCase();
		//alert(strPostfix);
		if(strFilter.indexOf(strPostfix)>-1)
		{
			//alert("True");
			return true;
		}
	}        
	//alert('False');
	return false;            
}
//-->