function newimg(imgurl) { 
newwin=window.open('about:blank','','width=10,height=10,left=150,top=150,status=yes'); //先新打开一个小窗口
newwin.document.open();
newwin.document.write('<html><title></title>'); //把窗口的大小调整到与图片一样大。
newwin.document.write('<body leftmargin=0 topmargin=0 marginheight="0" marginwidth="0" onBlur="self.close()">'); 
newwin.document.write('<a href="####"><img id=img1 src='+imgurl+' alt="点击关闭窗口"'); 
newwin.document.write(' onClick="window.close()"'); 
newwin.document.write(' onload="self.resizeTo(this.offsetWidth+10,this.offsetHeight+49);" border="0"></a>'); 
newwin.document.write('</body></html>');
newwin.document.close();
newwin.focus();
}
var flag=false;
function DrawImage(ImgD,FitWidth,FitHeight){
   var image=new Image();
   image.src=ImgD.src;
   if(image.width>0 && image.height>0){
    flag=true;
    if(image.width/image.height>= FitWidth/FitHeight){
     if(image.width>FitWidth){  
     ImgD.width=FitWidth;
     ImgD.height=(image.height*FitWidth)/image.width;
     }else{
     ImgD.width=image.width;  
     ImgD.height=image.height;
     }
     ImgD.alt="点击图片放大("+image.width+"×"+image.height+")";
     }
    else{
     if(image.height>FitHeight){  
     ImgD.height=FitHeight;
     ImgD.width=(image.width*FitHeight)/image.height;     
     }else{
     ImgD.width=image.width;  
     ImgD.height=image.height;
     }
     ImgD.alt="点击图片放大("+image.width+"×"+image.height+")";
     }
    }
}
