﻿// JScript File
    function resizeImg(img, maxWidth, maxHeight){
        var currImg = new Image();
        currImg.src = img.src;
        var doWidth = false;
        if(currImg.width > currImg.height){
            doWidth = true;
        }
        else{
            if((currImg.width/currImg.height) <= (maxWidth/maxHeight))
                doWidth = false;
            else
                doWidth = true;
        }
        if(doWidth == true){
            if(currImg.width > maxWidth){
                img.style.width = parseInt(maxWidth) + "px";
            }
            else{
                img.style.width = parseInt(currImg.width) + "px";
            }
        }
        else{
            if(currImg.height > maxHeight){
                img.style.height = parseInt(maxHeight.width) + "px";
                //alert("c: " + img.height);
            }
            else{
                img.height = currImg.height;
                //alert("d: " + img.height);
            }
        //alert(img.height + ' -- ' + currImg.width + ' -- ' + currImg.height);
        }
    }


