var FitWidth = 120;
var FitHeight = 100;
function ResizePic(ImgTag)
{
    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 fordiv(divi,divbi,divci)
 
 {//alert('fdfd');
  if(divi.style.display=="block"){
  divi.style.display="none";
 }
  else
  {
   divi.style.display="block";
  
   }
   divbi.style.display="none";
   divci.style.display="inline";
 
 }
 
<!--
/*
功能：图片等比例缩放
目标:ImgTag
图片宽度:FitWidth
图片高度:FitHeight
使用： onload="javascript:ResizePic(this)" 
*/

//-->