var nativeHeight = 0, nativeWidth = 0;

function saveImageSize(id) {

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

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);
        }
    }
}



imageonload =  function(){
	/* Похоже на то, что ready срабатыет тогда, когда все компоненты страницы уже загружены, в т.ч. картинки, сооответственно
	.load() не издается */
	saveImageSize("fullimage");
        changeImageSize("fullimage");
        $("img#fullimage").css({"display":"inline"});
    }


/*$(document).ready(
)*/

