function ResizePic(ImgTag,FitWidth,FitHeight){
var image = new Image();
image.src = ImgTag.src;
if(image.width>0 && image.height>0){
if(image.width/image.height >= FitWidth/FitHeight){
if(image.width > FitWidth){ImgTag.width = FitWidth;ImgTag.height = (image.height*FitWidth)/image.width;}
else{ImgTag.width = image.width;ImgTag.height = image.height;}
}
else{
if(image.height > FitHeight){ImgTag.height = FitHeight;ImgTag.width = (image.width*FitHeight)/image.height;}
else{ImgTag.width = image.width;ImgTag.height = image.height;}
}
}
}


function onUploadImgChange(sender,preview,onlyValidationType,fakefield,imagetype,UpBtn){
if(sender.value==""){if(document.getElementById(UpBtn))document.getElementById(UpBtn).removeAttribute("disabled");return;}
if(imagetype==null||imagetype=="")imagetype=".jpg|.jpeg|.gif|.bmp|.png";var reg=new RegExp(imagetype,"i");
if(!sender.value.match(reg)){alert("格式不正确，请上传"+imagetype.toUpperCase().replace(/\./g,"").replace(/\|/g,"、")+"格式的图片！");sender.value="";if(document.getElementById(UpBtn)){document.getElementById(UpBtn).setAttribute("disabled","disabled");}return;}else{if(document.getElementById(UpBtn))document.getElementById(UpBtn).removeAttribute("disabled");}
if(onlyValidationType==1)return;
document.getElementById(fakefield).innerHTML=sender.value;img=document.getElementById(preview);
if(navigator.userAgent.indexOf("Firefox")!=-1)if(sender.files){if(preview!=""){img.src= sender.files.item(0).getAsDataURL();img.style.display="";}}
if(navigator.userAgent.indexOf('MSIE')!=-1){
var iVer = navigator.userAgent.substr(navigator.userAgent.indexOf('MSIE') + 5,1);
if(iVer<=6){if(preview!=""){img.src=sender.value;img.style.display="";}if(iVer==6){var image=new Image(); image.dynsrc=sender.value; var iSize=Math.round(image.fileSize/1024);if(iSize>200)alert("您选择的文件大小超过了200K，可能上传过程要等待更长的时间！");}}
else if(iVer>6){if(preview!=""){img.filters.item("DXImageTransform.Microsoft.AlphaImageLoader").src = sender.value;img.style.display="";}}
}
}