﻿// This function can be used by any CROSS-DOMAIN iFrame child to resize itself within it's Black Box parent window
function ResizeFrame(iHeight,iWidth)
{
    // Must check document.referrer since we have multiple enviroments
    var parentUrl = document.referrer.toString().split('/');
    var rootUrl = parentUrl[0]+"//"+parentUrl[2]+"/";
    // crossframe.aspx has the script to actually resize the parent... this will call it in the right domain 
    var iSrc = rootUrl+"crossframe.aspx?iheight="+iHeight+"&iwidth="+iWidth;
    document.write('<iframe src="'+iSrc+'" height="0px" width="0px" frameborder="0" name="ResizingIframe"></iframe>');
}


// This function can be used by any LOCAL DOMAIN iFrame child to resize itself within it's Black Box parent window
function iFrameResize(inputHeight, inputWidth, iFrameUrl)
{
    if(window.top.document.getElementsByTagName("iframe")[0] != null)
    {
        var iFrames = window.top.document.getElementsByTagName("iframe");
        for (var i = 0; i < window.top.document.getElementsByTagName("iframe").length; i++)
        {
            // Double check src to make sure that you have the right iframe.
            if (iFrames[i].src == iFrameUrl)
            {
                    iFrames[i].style.height = inputHeight;
                    iFrames[i].style.width = inputWidth;
            }
        }
    }
}
