/* TOC.JS */
var framesTop = parent.parent;
//var L_LoadingMsg_HTMLText = "Loading, click to cancel..."; 

var LoadDiv = '<DIV ONCLICK="loadFrame(true);" CLASS="clsLoadMsg">';
L_LoadingMsg_HTMLText = LoadDiv + L_LoadingMsg_HTMLText + "</DIV>";

function caps(){
    var UA = navigator.userAgent;
    if(UA.indexOf("MSIE") != -1)
    {
        this.ie = true;
        this.v = UA.charAt(UA.indexOf("MSIE") + 5);
        if( this.v == 2 ) this.ie2 = true;
        else if( this.v == 3 ) this.ie3 = true;
        else if( this.v == 4 ) this.ie4 = true;
        else if( this.v == 5 ) this.ie5 = true;
    }
    else if(UA.indexOf("Mozilla") != -1 && UA.indexOf("compatible") == -1)
    {
        this.nav = true;
        var v = UA.charAt(UA.indexOf("Mozilla") + 8);
        if(v == 2 ) this.nav2 = true;
        else if(v == 3 ) this.nav3 = true;
        else if(v == 4 ) this.nav4 = true;
    }
    if(UA.indexOf("Windows 95") != -1 || UA.indexOf("Win95") != -1 || UA.indexOf("Win98") != -1 || UA.indexOf("Windows 98") != -1 || UA.indexOf("Windows NT") != -1) this.win32 = true;
    else if(UA.indexOf("Windows 3.1") != -1 || UA.indexOf("Win16") != -1) this.win16 = true;
    else if(UA.indexOf("Mac") != -1) this.anymac = true;
    else if(UA.indexOf("SunOS") != -1 || UA.indexOf("HP-UX") != -1 || UA.indexOf("X11") != -1) this.unix = true;
    else if(UA.indexOf("Windows CE") != -1) this.wince = true;
}

var bc = new caps();

//////////////////////////////////////////// 
// Not sure why this is here, it puts a scrollbar up when none is needed 
// if("object" == typeof(parent.document.all.fraPaneToc)) parent.document.all.fraPaneToc.scrolling = "yes"; 
//////////////////////////////////////////// 

var eSynchedNode = null;
var eCurrentUL = null;
var eCurrentLI = null;
var bLoading = false;

function loadFrame( bStopLoad )
{
    if( "object" == typeof( eCurrentUL ) && eCurrentUL && !bStopLoad )
    {
      eCurrentUL.innerHTML = hiddenframe.chunk.innerHTML;
      eCurrentUL = null;
      bLoading = false;
    }
    else if( "object" == typeof( eCurrentUL ) && eCurrentUL )
    {
      eCurrentUL.parentElement.children[1].className = "";
      eCurrentUL.parentElement.children[0].src = "bs.gif";
      eCurrentUL.parentElement.className = "kid";
      eCurrentUL.className = "clsHidden";
      eCurrentUL.innerHTML="";
      eCurrentUL = null;
      bLoading = false;
    }
    else
    {
      bLoading = false;
    }
    return;
}

function GetNextUL(eSrc)
{
    var eRef = eSrc;
    for(var i = eRef.sourceIndex + 1; i < document.all.length; i++)
    {
        if( "UL" == document.all[ i ].tagName )
        {
            return document.all[ i ];
        }
        else if( "LI" == document.all[ i ].tagName )
        {
            break;
        }
    }
    return false;
}

function MarkSync(eSrc)
{
    if("object" == typeof(aNodeTree)) aNodeTree = null;
    if("LI" == eSrc.tagName.toUpperCase() && eSrc.children[1] && eSynchedNode != eSrc )
    {
        UnmarkSync();
        eSrc.children[1].style.fontWeight = "bold";
        eSynchedNode = eSrc;
    }
}

function UnmarkSync()
{
    if("object" == typeof(eSynchedNode) && eSynchedNode )
    {
        eSynchedNode.children[1].style.fontWeight = "normal";
        eSynchedNode = null;
    }
}

function MarkActive(eLI)
{
    if( "object" == typeof( eLI ) && eLI && "LI" == eLI.tagName.toUpperCase() && eLI.children[1] && eLI != eCurrentLI )
    {
        MarkInActive();
        window.eCurrentLI = eLI;
        window.eCurrentLI.children[1].className = "clsCurrentLI";
    }
}

function MarkInActive()
{
    if( "object" == typeof( eCurrentLI ) && eCurrentLI )
    {
        window.eCurrentLI.children[1].className = "";
        window.eCurrentLI = null;
    }
}

function LoadChildren( eLink )
{
    var strLoc = "loadtree.asp" + eLink.href.substring( eLink.href.indexOf( "?" ) );
    document.frames["hiddenframe"].location.replace(strLoc);
}

function Navigate_URL( eSrc )
{
    var eLink = eSrc.parentElement.children[1];
    urlIdx = eLink.href.indexOf( "URL=" );
    if("object" == typeof(framesTop.fraTopic) && eLink && "A" == eLink.tagName && urlIdx != -1 )
    {
        if(eLink.target=="fraTopic"||eLink.target=="_top"){
            framesTop.fraTopic.location.href = eSrc.parentElement.children[1].href.substring( urlIdx + 4 );
        }else{
            window.open(eSrc.parentElement.children[1].href,eLink.target);
        }
        MarkSync(eSrc.parentElement);
    }
    else if("object" == typeof(framesTop.fraTopic) && eLink && "A" == eLink.tagName  && eLink.href.indexOf( "tocPath=" ) == -1 && eLink.href.indexOf( "javascript:" ) == -1 )
    {
        if(eLink.target=="fraTopic")
        {
            framesTop.fraTopic.location.href = eSrc.parentElement.children[1].href;
        }
        else if( eLink.target=="_top" )
        {
            top.location = eLink.href;
            return;
        }
        else
        {
            window.open(eSrc.parentElement.children[1].href,eLink.target);
        }
        MarkSync(eSrc.parentElement);
    }
    else if( eSynchedNode != eSrc.parentElement && ( urlIdx != -1 || ( eLink.href.indexOf( "javascript:" ) == -1 && eLink.href.indexOf( "tocPath=" ) == -1 ) ) )
    {
        MarkSync( eSrc.parentElement );
    }
}

function Image_Click( eSrc , bLeaveOpen )
{
    var eLink = eSrc.parentElement.children[1];
    if("noHand" != eSrc.className)
    {
        eLI = eSrc.parentElement;
        MarkActive(eLI);
        var eUL = GetNextUL(eLI);
        if(eUL && "kidShown" == eLI.className)
        {
            // hide on-page kids 
            if( !bLeaveOpen )
            {
                eLI.className = "kid";
                eUL.className = "clsHidden";
                eSrc.src = "bs.gif";
            }
        }
        else if(eUL && eUL.all.length)
        {
            // show on-page kids 
            eLI.className = "kidShown";
            eUL.className = "clsShown";
            eSrc.src = "bo.gif";
        }
        else if("kid" == eLI.className)
        {
            // load off-page kids 
            if( !bLoading )
            {
                bLoading = true;
                eLI.className = "kidShown";
                eUL.className = "clsShown";
                window.eCurrentUL = eUL;
                eSrc.src = "bo.gif";
                eUL.innerHTML = L_LoadingMsg_HTMLText;
                LoadChildren( eLink );
            }
        }
    }
}

function Toc_click()
{
    var eSrc = window.event.srcElement;
    event.returnValue = false;

    if("A" == eSrc.tagName.toUpperCase() && "LI" == eSrc.parentElement.tagName)
    {
        var eImg = eSrc.parentElement.children[0];
        if(eImg) eImg.click();
    }
    else if("SPAN" == eSrc.tagName && "LI" == eSrc.parentElement.tagName)
    {
        var eImg = eSrc.parentElement.children[0];
        if(eImg) eImg.click();
    }
    else if("IMG" == eSrc.tagName)
    {
        Image_Click( eSrc , false );
        Navigate_URL( eSrc );
    }
    return event.returnValue;
}

function Toc_dblclick()
{
    return;
}

function window_load()
{
    if( self == top ) location.replace( "default.asp" );
    var objStyle = null;
    if( bc.win32 && ( bc.ie4 || bc.ie5 ) && "object" == typeof ( ulRoot ) && "object" == typeof( objStyle = document.styleSheets[0] ) && "object" == typeof( objStyle.addRule ) )
    {
        window.eSynchedNode = document.all["eSynchedNode"];
        objStyle.addRule( "UL.clsHidden" , "display:none" , 0 );
        objStyle.addRule( "UL.hdn" , "display:none" , 0 );
        ulRoot.onclick=Toc_click;
        ulRoot.ondblclick=Toc_dblclick;
        if( window.eSynchedNode )
        {
            MarkActive(window.eSynchedNode);
            window.eSynchedNode.all.tags( "B" )[0].outerHTML = eSynchedNode.all.tags("B")[0].innerHTML;
            window.scrollTo(0,window.eSynchedNode.offsetTop-(document.body.clientHeight/2));
        }
        else
        {
            MarkActive(document.all.tags( "LI" )[0]);
        }
    }
}

window.onload = window_load;