// JavaScript Document
function redimImage(inImg, inMW, inMH, monAlign)
{
// inImg : Chemin relatif de l'image
  // inMW  : Largeur maximale
  // inMH   : Hauteur maximale
  document.writeln("<input type=\"hidden\" name=\"test_nom\" value=\""+inImg+"\">");
  //alert(inImg);
  var maxWidth = inMW;
  var maxHeight = inMH;
  var oImg = new Image();
  // Affectation du chemin de l'image a l'objet
  oImg.src = inImg;
  var h = oImg.height;
  var dH = oImg.height;
  var w = oImg.width;
  var dW = oImg.width;
  //alert(h+"/"+w);
  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);
    }
  }
  //alert("largeur:"+dW+"/Hauteur:"+dH+",Largeur:"+w+"/Hauteur:"+h);
  document.writeln("<input type=\"hidden\" name=\"test\" value=\""+dH+"/"+dW+"\">");	 
  if (monAlign!="") {
	  document.writeln("<img src=\"" + inImg + "\" width=\"" + dW + "\" height=\"" + dH + "\" border=\"0\"  name=\"netattirance\" 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=\"netattirance\" hspace=\"5\" vspace=\"5\" border=\"0\" align=\"right\" >");
  }
};
