var imgPreloader = new Array();

Element.observe(window, "load", function() {
    $$('.imageResize').each(function (img, index){
        var width = 0, height = 0;
        img.constWidth = img.width;
        img.constHeight = img.height;
        if (0 < img.naturalWidth){
            img.rsWidth = img.naturalWidth;
        }
        if (0 < img.naturalHeight){
            img.rsHeight = img.naturalHeight;
        }
        img.observe("click", function() {
            if (this.rsWidth == undefined || this.rsHeight == undefined){
                imgPreloader = new Image();
                imgPreloader.src = img['src'];
                img.rsWidth = imgPreloader.width;
                img.rsHeight = imgPreloader.height;
            }
            size = resizeUp(img.rsWidth, img.rsHeight, 396, 396);
            this.width  = size[0];
            this.height = size[1];
        });
        img.observe("mouseout", function() {
            this.width  = img.constWidth;
            this.height = img.constHeight;
        });
    });
});
