var nativeHeight = 0, nativeWidth = 0;

function saveImageSize(id) {

    ob = document.getElementById(id);
    
    nativeHeight = ob.height;
    nativeWidth = ob.width;
    
    changeImageSize(id);
}

function changeImageSize(id) {
    var ob, width, height;
    
    width = parseInt((window.innerWidth || document.documentElement.clientWidth) - 50);
    height = parseInt((window.innerHeight || document.documentElement.clientHeight) - 130);

    ob = document.getElementById(id);
    
    if ((nativeWidth > width) || (nativeHeight > height)) {
    
        if ((nativeWidth / width) > (nativeHeight / height)) {
            ob.width = width;
            ob.height = ob.width / (nativeWidth / nativeHeight);
        } else {
            ob.height = height;
            ob.width = height * (nativeWidth / nativeHeight);
        }
    }
}

