
<!--
//调用方式<img src='"+url+"' onload='javascript:DrawImage(this,300,380)'>

//图片按比例缩放
var flag=false;
function DrawImage(ImgD,iwidth,iheight){
    //参数(图片,允许的宽度,允许的高度)
    var image=new Image();
    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 showpic(url,divname){
var obj=document.getElementById(divname);
  document.all(divname).style.display="block";
  obj.innerHTML="<img src='"+url+"' onload='javascript:DrawImage(this,300,380)'><br><a href='#' onClick='javascrpt:closeshowpic();'>关闭</a>";
}
function closeshowpic()
{
document.all("lookuppic").style.display="none";
}
//-->
function setScope(obj,setW,setH) {
var mainObj = document.getElementById(obj);
var subObj = mainObj.getElementsByTagName("img");
for (i=0;i<subObj.length;i++) {
   divW = subObj[i].width;
   divH = subObj[i].height;
   if (divW > divH) {
    if (divW > setW) {
     valW = setW;
     valH = parseInt(setW * divH / divW);   //目标高度
     if (valH > setH) {
      valH = setH;
      valW = parseInt(setH * valW / valH); //目标宽度
     }
     subObj[i].style.width = valW + "px";
     subObj[i].style.height = valH + "px";
     subObj[i].style.marginTop = parseInt((setH - valH) / 2) + "px";
    }
   }
   else if (divH > divW) {
    if (divH > setH) {
     valH = setH;
     valW = parseInt(setH * divW / divH);   //目标宽度
     if (valW > setW) {
      valW = setW;
      valH = parseInt(setW * valH / valW); //目标高度
     }
     subObj[i].style.height = valH + "px";
     subObj[i].style.width = valW + "px";
    }
   }
   else {
    if (divH < setH) {
     subObj[i].style.marginTop = parseInt((setH - divH) / 2) + "px";
    }
    else if (divH > setH) {
     val = setW - setH >= 0?setH:setW;
     subObj[i].style.width = subObj[i].style.height = val + "px";
     if (setH > val) {
      subObj[i].style.marginTop = parseInt((setH - val) / 2) + "px";
     }
    }
   }
}
}

