/*
 * Functions controlling the size of the object by comparing it to a max value.
 *
 * Add this code to the file it is needed in:
 * <script type="text/javascript" src="scripts/resize.js"></script> 
 *
 * Example of use:
 * <img id="test" onload="resize('test')" src="cityxpress.gif" alt="Powered by CityXpress Ltd." border="0"/>
 *
 */

// ensures size does not reach max value regardless if it's landscape or portrait
    function resize(elem, maxh,maxw)
    {
      var minscale = 1;
      scaleh = maxh/elem.height;
      scalew = maxw/elem.width;
      if ((scalew <= scaleh) && (scalew<1))
      {
        elem.width = elem.width*scalew;
      }
      else
      {
        if (scaleh<1)
        {
          elem.height = elem.height*scaleh;
        }
      }
   }
   
// resizes only if the width exceeds the max value 
function resizew(which, max) {
  var elem = document.getElementById(which);
  if (elem == undefined || elem == null) return false;
  if (elem.width > max) elem.width = max;
}

