var OnLoadFunctions = new Array();
var OnLoadFunctionsEx = new Array();
function AddOnLoadFunction(OnLoadFunction, OnLoadFunctionEx)
{
    OnLoadFunctions.push(OnLoadFunction);
    OnLoadFunctionsEx.push(OnLoadFunctionEx);
}

window.onload = OnBodyLoad;
function OnBodyLoad()
{
    for (var i = 0; i < OnLoadFunctions.length; i++)
    {
        var cfunction = OnLoadFunctions[i];
        var cfunctionex = OnLoadFunctionsEx[i];
        eval("if (window." + cfunction + ") { " + cfunctionex + "; }");
    }
}

var TabsSelectedAnchor = new Array();
var TabsSelectedContainer = new Array();
function OnClickTab(TabGroup, NewAnchorId, NewContainerId, OtherFunction)
{
    var NewAnchor = document.getElementById(NewAnchorId);
    
    if (TabsSelectedAnchor[TabGroup] && NewAnchor && TabsSelectedAnchor[TabGroup] != NewAnchor)
    {
        TabsSelectedAnchor[TabGroup].className = "";
        if (NewAnchor)
        {
            NewAnchor.className = "aSelected";
            TabsSelectedAnchor[TabGroup] = NewAnchor;
        }
        
        if (TabsSelectedContainer[TabGroup])
        {
            TabsSelectedContainer[TabGroup].style.display = "none";
        }
        var NewContainer = document.getElementById(NewContainerId);
        if (NewContainer)
        {
            NewContainer.style.display = "block";
            TabsSelectedContainer[TabGroup] = NewContainer;
        }
        
        eval(OtherFunction);
    }
    else if (!TabsSelectedAnchor[TabGroup])
    {
        if (NewAnchor)
        {
            NewAnchor.className = "aSelected";
            TabsSelectedAnchor[TabGroup] = NewAnchor;
        }
        var NewContainer = document.getElementById(NewContainerId);
        if (NewContainer)
        {
            NewContainer.style.display = "block";
            TabsSelectedContainer[TabGroup] = NewContainer;
        }
        
        eval(OtherFunction);
    }
}

function SetTab(TabGroup, NewAnchorId, NewContainerId)
{
    var NewAnchor = document.getElementById(NewAnchorId);
    if (NewAnchor)
    {
        TabsSelectedAnchor[TabGroup] = NewAnchor;
    }
    
    var NewContainer = document.getElementById(NewContainerId);
    if (NewContainer)
    {
        TabsSelectedContainer[TabGroup] = NewContainer;
    }
}