    imgLoaded = -1;
    imgList = new Array();

    function resizeWindow(){
        $('.mainWindow').css('height',$(document).height());
        if (imgLoaded == 1) {
            var tmpHeight = ($(document).height())+10;
            $("body").height(tmpHeight);
        }
    }
    function checkPic(){
        $("img").each(function(i){
            if(($(this).height()) > 0) {
                imgList[i] = $(this).height();
            }
        });
        if (imgList.length == $('img').size()) {
            imgLoaded = 1;
            resizeWindow();
        } else {
            setTimeout("checkPic()", 1000);
        }
    }
    $(document).ready(function() {
        resizeWindow();
    });
    $(window).load(function() {
        resizeWindow();
        checkPic();
    });

