Image resize proportional to window resize

Image resize proportional to window resize

i need to resize an inline img upon user window resize, while respecting the original proportions from image/window... using the following code, the image gets resized way too much... what am i doing wrong? must be some logic mistake by me... please help
  1.     
    $ ( window ). resize ( function () {

             // window dimenstions
    var windowWidth = $ ( window ). width ();
    var windowHeight = $ ( window ). height ();

             // figure dimensions
             var figureWidth = $ ( '#detailScreen figure' ). width ();
             var figureHeight = $ ( '#detailScreen figure' ). height ();

             // proportions figure/window
             var widthPropWinToBigImg = figureWidth / windowWidth ;
             var heightPropWinToBigImg = figureHeight / windowHeight ;

             // resize figure according to proportion
             $ ( '#detailScreen figure' ). css ({
                 'width' : figureWidth * widthPropWinToBigImg ,
                 'height' : figureHeight * heightPropWinToBigImg ,
             })
    });