﻿var alerted = false;
var ie = document.all ? true : false;
var minimumHeight = 500;
var minimumWidth = 732;
var scrollSpace = 14;

function resizeIframe(iframeName) 
{
    try {
        var height = minimumHeight;
        var width = minimumWidth;
        var iframe = document.getElementById(iframeName);
        if (iframe != null) {
            if (ie) //ie5+ syntax
            {
                if ((iframe.Document.body != null) && (iframe.src != "")) 
                {
                    if (iframe.Document.body.scrollHeight > minimumHeight)
                        height = iframe.Document.body.scrollHeight + scrollSpace;

                    if (iframe.Document.body.scrollWidth > minimumWidth)
                        width = iframe.Document.body.scrollWidth + scrollSpace;

                    iframe.width = width;
                    iframe.height = height;
                }
            }
            else if (!ie)//(innerDoc.body.offsetHeight) //ns6 syntax
            {
                if ((iframe.contentDocument.body != null) && (iframe.src != "")) 
                {
                    if (iframe.contentDocument.body.scrollHeight > minimumHeight)
                        height = iframe.contentDocument.body.scrollHeight;

                    iframe.width = iframe.scrollWidth + iframe.contentWindow.scrollMaxX;
                    iframe.height = height;
                }
            }
        }
    }
    catch (exception) {
        alert(exception.message);
    }
}

