var IntermediateFrameId = "KlIntermediateFrame.{3CFCD6D1-EC3B-476C-9C27-D76C2F01EAF5}";

function isInsideIntermediateFrame()
{
    return IntermediateFrameId == window.name;
}

function getNearestMeaningfulFrame()
{
    var result = window;

    while (result.name == IntermediateFrameId)
    {
        if (result.parent == result)
        {
            return result;
        }
        result = result.parent;
    }

    return result;
}