function getQueryString(Frame, index)
{
    var queryStr = "p"+index+"=";
    if (!Frame.VIPOID)
    {
        queryStr = queryStr+"none";
    }
    else
    {
        queryStr = queryStr+Frame.VIPOID;
    }
    if (Frame.frames)
    {
        for (var i = 0; i < Frame.frames.length; i++)
        {
            queryStr = queryStr+"&"+getQueryString(Frame.frames[i], index+i);
        }
    }
    return queryStr;
}


function isInFrame(Frame,OID)
{
    if (Frame.VIPOID == OID)
    {
        return true;
    }
    else
    {
        for (var i = 0; i < Frame.frames.length; i++)
        {
            if (isInFrame(Frame.frames[i], OID))
            {
                return true;
            }
        }
    }
    return false;
}


function getNewAppletTag(VIPOID,VIPHOST,VIPINTRANET_PORT,VIPHTTP_PORT,VIPLANG,VIPSITE,VIPFRAME,VIPCODEBASE,VIPAPPLET)
{
    if (location.href.indexOf("hcl_noupdate=t") != -1)
    {
        // "t" is a substring of "true".
        return "";
    }

    if (VIPSITE == "VIPHTMLClient" || VIPSITE == "viphcl801" || VIPSITE == "viphcl800")
    {
       return "";
    }

    this.VIPOID = VIPOID;
    now = (new Date()).getTime();
    nowParam = "&hcl_time=" + now;

    if(top.frames.length > 0)
    {
        // Search for hcl_menu's URL
        var menuUrl = "";
        for(var i = 0; i < top.frames.length; i++)
        {
            if(top.frames[i].name == "hcl_menu")
            {
                menuUrl = top.frames[i].location.href;
                var ind1 = menuUrl.indexOf("?");
                if (ind1 > -1) { menuUrl = menuUrl.substring(0, ind1); }
                break;
            }
        }

        if (menuUrl != "")
        {
            // Found VIP HTML Client menu. Update menu.
            if (window.name == "hcl_content") /* || (parent.name == "hcl_content")) */
            {
                // is 'content' frame.
                window.open(menuUrl + "?hcl_oid=" + VIPOID + nowParam, "hcl_menu");

                if (top.FrameNavWindow)
                {
                    top.FrameNavWindow.close();
                }
            }
        }

        // Compute hcl_ref_menu's URL
        var refMenuUrl = "";
        for (var i = 0; i < top.frames.length; i++)
        {
            if (top.frames[i].name == "hcl_ref_menu")
            {
                refMenuUrl = top.frames[i].location.href;
                var ind1 = refMenuUrl.indexOf("?");
                if (ind1 > -1) refMenuUrl = refMenuUrl.substring(0, ind1);
                break;
            }
        }

        if (refMenuUrl != "")
        {
            // Found VIP HTML Client ref menu. Update menu.
            if (window.name == "hcl_ref_content") /* || parent.name == "hcl_ref_content") */
            {
                // is 'content' frame.
                window.open(refMenuUrl + "?hcl_roid=" + VIPOID, "hcl_ref_menu");

                if (top.FrameNavWindow)
                {
                    top.FrameNavWindow.close();
                }
            }
        }

        // Switch off applet.
        for(var i = 0; i < top.frames.length; i++)
        {
            if (top.frames[i].name.indexOf("hcl_") == 0)
            {
                return "";
            }
        }

    }

    if (top.name == "hcl_separate_content")
    {
        if (top.opener == null) { return ""; }
        if (window.name == "hcl_separate_content")
        {
            if (top.opener.top.hcl_menu == null) { return ""; }
            var menuUrl = top.opener.top.hcl_menu.location.href;
            var ind1 = menuUrl.indexOf("?");
            if (ind1 > -1) menuUrl = menuUrl.substring(0, ind1);
            top.opener.top.open(menuUrl + "?hcl_oid=" + VIPOID + nowParam, "hcl_menu");

            if (top.FrameNavWindow)
            {
                top.FrameNavWindow.close();
            }

            return "";
        }
        else
        {
            return "";
        }
    }
    else if (top.name == "hcl_separate_ref_content")
    {
        if (top.opener == null) { return ""; }
        if (window.name == "hcl_separate_ref_content")
        {
            if (top.opener.top.hcl_ref_menu == null) { return ""; }
            var menuUrl = top.opener.top.hcl_ref_menu.location.href;
            var ind1 = menuUrl.indexOf("?");
            if (ind1 > -1) menuUrl = menuUrl.substring(0, ind1);
            top.opener.top.open(menuUrl + "?hcl_roid=" + VIPOID + nowParam, "hcl_ref_menu");

            if (top.RefFrameNavWindow)
            {
                top.RefFrameNavWindow.close();
            }

            return "";
        }
        else
        {
            return "";
        }
    }

    return "";
}
