﻿function setImageSize() {

    var maxWidth = 150, maxHeight = 120; //Max size of thumbnails
    //If we can access the images
        if (document.images) {
        //Loop for all images
        var iWidth=0;
        var iHeight=0;
        var iAspect=0;
        
        for (var loopCounter = 0; loopCounter < document.images.length; loopCounter++) {
                
                iWidth = document.images[loopCounter].width;
                iHeight = document.images[loopCounter].height;
                iAspect= iWidth/iHeight;
                
                
                //If this one is too wide, shrink it
                if (document.images[loopCounter].width > maxWidth)
                document.images[loopCounter].width = maxWidth;
               
               // resize height according to aspect ratio
                document.images[loopCounter].height = maxWidth / iAspect;
            
        }
    }
}


setImageSize();

