// $Id: view_util.js,v 1.1 2006/05/25 12:32:58 cvsadmin Exp $
  var resized = new Array();

  function resizeImage(name, url, maxWidth, maxHeight) {
    if (resized[name]) {
        return;
    }

    img = new Image();
    img.src = url;

    height = 0;
    width = 0;

    if (img.width > maxWidth && img.height > maxHeight) {
        width = img.width * (maxHeight / img.height);
        height = maxHeight;
        if (width > maxWidth) {
            height = img.height * (maxWidth / img.width);
            width = maxWidth;  
        }
    } else if (img.height > maxHeight) {
        width = img.width * (maxHeight / img.height);
        height = maxHeight;
    } else if (img.width > maxWidth) {
        height = img.height * (maxWidth / img.width);
        width = maxWidth;  
    } else {
        width = img.width;
        height = img.height;
    }
    document.images[name].width = width ? width : maxWidth;
    document.images[name].height = height ? height : maxHeight;

    resized[name] = true;
  }

