
function imageResizer(image, delimiterSize, criteria)
{
  newWidth = 0;
  newHeight = 0;
  originalWidth = image.width;
  originalHeight = image.height;

  if (criteria == "larger")
  {
    if (originalWidth >= originalHeight)
    {
      newWidth = delimiterSize;
      newHeight = (newWidth / originalWidth) * originalHeight;
    }
    else 
    {
      newHeight = delimiterSize;
      newWidth = (newHeight / originalHeight) * originalWidth;
    }
  }
  else if (criteria == "shorter")
  {
    if (originalWidth <= originalHeight)
    {
      newWidth = delimiterSize;
      newHeight = (newWidth / originalWidth) * originalHeight;
    }
    else 
    {
      newHeight = delimiterSize;
      newWidth = (newHeight / originalHeight) * originalWidth;
    }
  }
  else if (criteria == "width")
  {
    newWidth = delimiterSize;
    newHeight = (newWidth / originalWidth) * originalHeight;
  }
  else if (criteria == "height")
  {
    newHeight = delimiterSize;
    newWidth = (newHeight / originalHeight) * originalWidth;
  }

  image.width = Math.round(newWidth);
  image.height = Math.round(newHeight);

}
