/*
  Método que permite redimensionar uma imagem baseado nas dimensões máximas permitidas.
*/
function resize(obj, width, height)
{
  // Obtém a imagem a apresentar
  var _thumb = new Image();
  _thumb.src = obj.src;

  if((_thumb.width > width) || (_thumb.height > height)) {
    // Verifica o formato da imagem
    if(_thumb.width >= _thumb.height) {
	  obj.width = width;
    } else {
	  obj.height = height;
    }
  }
}

function DetailResize(obj, w, h) {
    var t = new Image();
    t.src = obj.src;

    if ((t.width > w) || (t.height > h)) {
        var arw = w / parseFloat(t.width);
        var arh = h / parseFloat(t.height);

        var ar = Math.min(arh, arw);

        obj.width = parseInt(parseFloat(t.width) * ar);
        obj.height = parseInt(parseFloat(t.height) * ar);
    }
}

/*
  Método que configura a imagem a apresentar quando não for possível descarregar a imagem do servidor.
*/
function preview(obj, size)
{
  obj.onerror = null;
  switch(size) {
	case "90,60":
	  obj.src = "/Images/noPic/noPic_90x60.jpg";
	  break;
	case "140,105":
	  obj.src = "/Images/noPic/noPic_140x105.jpg";
	  break;
	case "180,135":
	  obj.src = "/Images/noPic/noPic_180x135.jpg";
	  break;
	case "200,150":
	  obj.src = "/Images/noPic/noPic_200x150.jpg";
	  break;    case "270,180":
      obj.src = "/Images/noPic/noPic_270x180.jpg";
      break;
    case "300,225":
	  obj.src = "/Images/noPic/noPic_300x225.jpg";
	  break;
	case "500,375":
	  obj.src = "/Images/noPic/noPic_500x375.jpg";
	  break;
  }
}
