$$('.imageViewer').each(
   function(el, index){
      resizeByHeight(el, index, 80);
   });

function resizeByHeight(el, index, maxH) {
   var pix = el.getElementsByTagName('img');
   var largeimage = el.getElementsByClassName('LARGE_IMAGE')[0];

   for(i=1; i<pix.length; i++){
      w=pix[i].width;
      h=pix[i].height;

      if (h > maxH) {
         f = 1-((h - maxH) / h);
         pix[i].width=w * f;
         pix[i].height=h * f;

         pix[i].onmouseover = function(){
            largeimage.src = this.src;
         };
      }
   }
}
