
function scaleImage(imgID, maxWidth, maxHeight)
{
	var img = document.getElementById(imgID);
	
	// Grab the image's dimensions
	var imgW = img.clientWidth;
	var imgH = img.clientHeight;

	// Grab the box's dimensions
	var boxW = maxWidth;
	var boxH = maxHeight;
	
	if ((imgW <= boxW) && (imgH <= boxH))
	{
		return;
	}
	
	var aspectRatio = Math.min(boxW/imgW, boxH/imgH);
	
	img.style.width = (imgW * aspectRatio);
	img.style.height = (imgH * aspectRatio);
}

function homeImageNotFound(imgElement)
{
	imgElement.src = './img/photonotavailable.jpg';
}

function homeDetailImageNotFound(imgElement)
{
	imgElement.src = './img/photonotavailable.jpg';
}

function agentImageNotFound(imgElement)
{
	imgElement.src = './img/pixel.gif';
}

// hide agent image panel when error occurred
// the image not found is often the case
function hideAgentImagePanel(divId)
{        
	var divElement = document.getElementById(divId);
	if (divElement != null)
	{	
	    divElement.style.display = "none";
	}
}

function adImageNotFound(imgElement)
{
	imgElement.src = './img/pixel.gif';
}

function featuredImageNotFound(imgElement)
{
	imgElement.src = './img/photonotavailable_sm.gif';	
}


//DEPRECATED--delete once we determined new model works
function curveCorners(divID)
{
  /*
  The new 'validTags' setting is optional and allows
  you to specify other HTML elements that curvyCorners
  can attempt to round.

  The value is comma separated list of html elements
  in lowercase.

  validTags: ["div", "form"]

  The above example would enable curvyCorners on FORM elements.
  */
  settings = {
      tl: { radius: 10 },
      tr: { radius: 10 },
      bl: { radius: 10 },
      br: { radius: 10 },
      antiAlias: true,
      autoPad: true,
      validTags: ["div"]
  }

  /*
  Usage:

  newCornersObj = new curvyCorners(settingsObj, classNameStr);
  newCornersObj = new curvyCorners(settingsObj, divObj1[, divObj2[, divObj3[, . . . [, divObjN]]]]);
  */
  var divElement = document.getElementById(divID);
  
  if(divElement != null)
  {
	var curvedBox = new curvyCorners(settings, divElement);
	curvedBox.applyCornersToAll();
  }
}
