var helpContainerParent;
var hContainer;
function help_displayHelpData(e)
{
    var sourceElement = app.browser().getSourceElement(e);
    var thePage = app.getPages().getPage(sourceElement.innerHTML, 2);
    if(app.getCurrentPage().helpText != null)
    {
        var helpText = thePage.helpText;
        if(helpText == null){ return; }
        var innerHTML =  helpText.replace("+"," ");
        var parentContainer = document.getElementById(g_helpSection);
        if(parentContainer != null)
        {
            hContainer = new ScrollingDiv(g_helpControlName);
            hContainer.addInnerHtml(parentContainer, unescape(innerHTML));
        }
    }
}

function help_restoreHelpData()
{
    //alert(app.getCurrentPage().helpText);
    if(app.getCurrentPage() != null)
    {
        if(app.getCurrentPage().helpText != null)
        {
            //alert(app.getCurrentPage().helpText);
            var helpText = app.getCurrentPage().helpText;
            if(helpText == null){ return; }
            var innerHTML =  helpText.replace("+"," ");
            var parentContainer = document.getElementById(g_helpSection);
            if(parentContainer != null)
            {
                hContainer = new ScrollingDiv(g_helpControlName);
                hContainer.addInnerHtml(parentContainer, unescape(innerHTML));
            }
        }
    }
    //alert("help_restoreHelpData");
}

function help_initHelp()
{
    //Dependencies:  scrollingDiv.js
    helpContainerParent = document.getElementById(g_helpSection);
    if(helpContainerParent != null)
    {
        hContainer = new ScrollingDiv(g_helpControlName);
        hContainer.setHeaderTitle("Help");
        hContainer.setFooterText("help is loading...");
        var helpText = app.getCurrentPage().helpText;
        hContainer.setWidth(200);
        if(helpText != null)
            hContainer.addInnerHtml(helpContainerParent, unescape(helpText));
        else
            hContainer.addInnerHtml(helpContainerParent,"");
    }
    //alert("done initializing help!");
}

function help_showDiv(the_id)
{
    var container = app.getIframe().contentWindow.document.getElementById(the_id);
    //alert(container.innerHTML);
    if(container != null)
    {
        if(container.style.visibility == "hidden")
        {
            container.style.visibility = "visible";
            container.style.overflow = "visible";
            container.style.height = "auto";
        }
        else
        {
            container.style.visibility = "hidden";
            container.style.overflow = "hidden";
            container.style.height = "2px";
        }
    }
}
