// image: img 元素
// zoom: (true|false) 是否对图片进行缩放，缺省为true
// width/height:
//   如果只指定width，则把图片的显示宽度缩到width 范围之内；
//   如果同时指定两个参数:
//      如果zoom 为false，则强制图片的显示大小为 width(px) x height(px)；
//      如果zoom 为true，则把图片缩小到指定的 width * height 范围之内
function _missthumbnail(image, width, height, zoom) {
  // 计算原图的url 地址
  var url=image.src;
  var p1=url.lastIndexOf('.');
  if(url == '' || p1 == -1) {
    return;
  }
  if(!url.substring(p1-2, p1).match(/[_-][smol]/)) {
    return;
  }
  url=url.substring(0, p1-2) + url.substring(p1);
  image.src=url;
  image.removeAttribute('width');
  image.removeAttribute('height');
  // 显示图片的原始大小，不进行缩放
  if(zoom != null && zoom == false) {
    if(width != null) image.width=width;
    if(height != null) image.height=height;
    return;
  }
  // 把图片的宽度缩到 width 范围之内
  if(width != null && height == null) {
    if(image.width > width) {
      image.height=width*image.height/image.width;
      image.width = width;
    }
  } else if(width != null && height != null && (image.width > width || image.height > height)) {
    // 把图片缩小到指定的 width * height 范围之内
    var rWmH=image.width * height; // rWmH=>real-width * max-height
    var rHmW=image.height * width; // rHmW=>read-height * max-width
    var calWidth=width, calHeight=height;
    if(rWmH < rHmW) {
      calHeight = height;
      calWidth = height * image.width / image.height;
    } else if(rWmH > rHmW) {
      calWidth = width;
      calHeight = width * image.height / image.width;
    } else if(rWmH == rHmW) {
      calWidth = width;
      calHeight = height;
    }
    image.width=calWidth;
    image.height=calHeight;
  }
}