addEvent(window, "load", makeImg);

function makeImg()
 {
  document.tag = document.getElementsByTagName('img');
  for (var j = 0; j < document.tag.length ; j++)
   {
    var img = document.tag[j];
    
    if (img.getAttribute('qwidth') || img.getAttribute('qheight'))
     {
      //dimension maximum définie
      var qw = img.getAttribute('qwidth');
      var qh = img.getAttribute('qheight');
      var w = img.width;
      var h = img.height;
      if (w > qw) { h = h * qw / w; w = qw; }
      if (h > qh) { w = w * qh / h; h = qh; }
      img.setAttribute('width',w+'px');
      img.setAttribute('height',h+'px');
     }else{
      if (!img.getAttribute('width') || !img.getAttribute('height'))
       {
        //pas de dimension définie -> attribuer les dimensions
        img.setAttribute('width',img.width+'px');
        img.setAttribute('height',img.height+'px');
       }
     }
    if (img.getAttribute('qdisplay'))
     {
      img.style.display = 'block';
     }
   }
 }

function makeOneImg(img)
 {
  if (img.getAttribute('qwidth') || img.getAttribute('qheight'))
   {
    //dimension maximum définie
    var qw = img.getAttribute('qwidth');
    var qh = img.getAttribute('qheight');
    var w = img.width;
    var h = img.height;
    if (w > qw) { h = h * qw / w; w = qw; }
    if (h > qh) { w = w * qh / h; h = qh; }
    img.setAttribute('width',w+'px');
    img.setAttribute('height',h+'px');
   }else{
    if (!img.getAttribute('width') || !img.getAttribute('height'))
     {
      //pas de dimension définie -> attribuer les dimensions
      img.setAttribute('width',img.width+'px');
      img.setAttribute('height',img.height+'px');
     }
   }
 }
 
