function setTopMenu(iIndex, iTry)
{
    if(typeof(iTry) == 'undefined')
    {
        iTry = 1;
    }

    try
    {
        top.topMenuFrame.selectMenu(iIndex);
    }
    catch(E)
    {
        if(iTry < 10)
        {
            window.setTimeout('setTopMenu(' + iIndex + ', ' + (iTry + 1) + ');', 250);
        }
    }
}

function setMenu(iIndex, iTry)
{
    if(typeof(iTry) == 'undefined')
    {
        iTry = 1;
    }

    try
    {
        top.menuFrame.Menu_OnPageLoadHandler(iIndex);
    }
    catch(E)
    {
        if(iTry < 10)
        {
            window.setTimeout('setMenu(' + iIndex + ', ' + (iTry + 1) + ');', 250);
        }
    }
}

function loadSubMenu(iFirstLevelIndex, iIndex, iTry)
{
    if(typeof(iTry) == 'undefined')
    {
        iTry = 1;
    }

    try
    {
        if(!top.menuFrame)
        {
            if(iTry < 10)
            {
                window.setTimeout('loadSubMenu(' + iFirstLevelIndex + ', ' + (iTry + 1) + ');', 250);
            }

            return;
        }

        window.open('http://www.horizont-noe.at/menuFrame_' + displayMenu + '.htm?firstLevelIndex=' + iFirstLevelIndex + '&menuitemindex=' + iIndex, 'menuFrame');
    }
    catch(E)
    {
        if(iTry < 10)
        {
            window.setTimeout('loadSubMenu(' + iFirstLevelIndex + ', ' + iIndex + ',' + (iTry + 1) + ');', 250);
        }
    }
}

var iLastFirstLevelIndex = -1;

function onLcContentPageLoaded_completeHandler(strActionImageUrl, strActionBannerNumber, strActionHeadlineText, strActionLongtextUrl, iMenuItemIndex, strMenuName, iMenuItemLevel)
{
    if(strMenuName == 'Menü Deutsch' || strMenuName == 'Menü Kroatisch' || strMenuName == 'Menü Türkisch')
    {
        var iTopIndex = -1;
        var iSubIndex = -1;

        for(var i = 0; i < LCSiteMenus.length; i++)
        {
            if(LCSiteMenus[i][0] == 0 && LCSiteMenus[i][3] == strMenuName)
            {
                var iFirstLevelIndex = -1;
                var bCountSecondLevelIndex = (iMenuItemLevel > 1);

                for(var j = i + 1 + iMenuItemIndex; j > i; j--)
                {
                    if(LCSiteMenus[j][0] == 1)
                    {
                        iFirstLevelIndex++;
                        bCountSecondLevelIndex = false;
                    }
                    else if(bCountSecondLevelIndex && LCSiteMenus[j][0] > 1)
                    {
                        iSubIndex++;
                    }

                }

                iTopIndex = iFirstLevelIndex;

                break;
            }
        }

        if(iTopIndex != iLastFirstLevelIndex)
        {
            iLastFirstLevelIndex = iTopIndex;
            loadSubMenu(iTopIndex, iSubIndex);
        }
        else
        {
            setMenu(iSubIndex);
        }

        setTopMenu(iTopIndex);
    }
}

