// JavaScript Document
function redimImage(inImg, inMW, inMH, monAlign,cache)
{//alert(inImg+"/"+inMW+"/"+inMH+"/"+monAlign);
// inImg : Chemin relatif de l'image
  // inMW  : Largeur maximale
  // inMH   : Hauteur maximale
  var maxWidth = inMW;
  var maxHeight = inMH;
  var dW = 0;
  var dH = 0;
  var oImg = new Image();
  // Affectation du chemin de l'image a l'objet
  oImg.src = inImg;
  var h = dH = oImg.height;
  var w = dW = oImg.width;
  if ((h >= maxHeight) || (w >= maxWidth)) {
    if ((h >= maxHeight) && (w >= maxWidth)) {
      // Si la largeur ou la hauteur depasse la taille maximale
      if (h > w) {
        dH = maxHeight;
        // On recalcule la taille proportionnellement
        dW = parseInt((w * dH) / h, 10);
      } else {
        dW = maxWidth;
        // On recalcule la taille proportionnellement
        dH = parseInt((h * dW) / w, 10);
      }
    } else if ((h > maxHeight) && (w < maxWidth)) {
      // Si la hauteur depasse la taille maximale
      dH = maxHeight;
        // On recalcule la taille proportionnellement
      dW = parseInt((w * dH) / h, 10);
    } else if ((h < maxHeight) && (w > maxWidth)) {
      // Si la largeur depasse la taille maximale
      dW = maxWidth;
        // On recalcule la taille proportionnellement
      dH = parseInt((h * dW) / w, 10);
    }
  }
  document.writeln("<input type=\"hidden\" name=\"test\" value=\""+dH+"/"+dW+"\">");
 // if (dH=0 && dW=0) {
  //	dH=oImg.height;
	//dW= oImg.width;}
 // preload="pic"+inImg
 //document.writeln(preload+" = new Image ("+dH+","+dW+")");
//document.writeln(preload+".src = \"" + inImg + "\"");

  if (monAlign!="") {
	  document.writeln("<img src=\"" + inImg + "\" width=\"" + dW + "\" height=\"" + dH + "\" border=\"0\"  name=\"<%=name%>\" hspace=\"5\" vspace=\"5\" border=\"0\" align=\"+monAlign+\"> ");
  }
  else {
  // On ecrit l'image dans le document
  document.writeln("<img src=\"" + inImg + "\" width=\"" + dW + "\" height=\"" + dH + "\" border=\"0\"  name=\"<%=name%>\" hspace=\"5\" vspace=\"5\" border=\"0\" align=\"right\" >");
  }
};
