function rdvGetDocumentHeight(doc) {

    if (doc.height) return doc.height;

    if (!doc.body) return 0;

    var height = 0;
    var scrollHeight, offsetHeight;

    if (doc.body.scrollHeight) height = scrollHeight = doc.body.scrollHeight;
    if (doc.body.offsetHeight) height = offsetHeight = doc.body.offsetHeight;
    if (scrollHeight && offsetHeight) height = Math.max(scrollHeight, offsetHeight);

    return height;
}

function rdvSetIframeHeight(ifrmName) {

    var ifrmWnd = window.frames[ifrmName];

    var ifrmElem = document.getElementById ?
        document.getElementById(ifrmName) :
        document.all ? document.all[ifrmName] : null;

    if (ifrmElem && ifrmWnd) {

        // this could help proper resizing if the next window is shorter than
        // the previous one
        ifrmElem.style.height = "auto";
  
        var height = rdvGetDocumentHeight(ifrmWnd.document);

        // assign minimum height that is no longer set in main_panel_header.php for welcome.php
        // see also globals.php, $main_panel_min_height:

        if (height < (515 - 50)) height = (515 - 50);

        // add some more pixels to make sure it all fits into new height
        if (height) ifrmElem.style.height = height + 50 + "px";
    }
}
