﻿// not animated collapse/expand
function togglePannelStatus(content)
{
    var expand = (content.style.display=="none");
    content.style.display = (expand ? "block" : "none");
    toggleChevronIcon(content);
}

// current animated collapsible panel content
var currentContent = null;

function togglePannelAnimatedStatus(content, interval, step)
{
    // wait for another animated expand/collapse action to end
    if (currentContent==null)
    {
        currentContent = content;
        
        //alert(content.style);
        
        if(content.style == null)
        {
            content = content.nextSibling
            //alert(content.style);
        }
        

        //alert(content.style);
        var expand = (content.style.display=="none");
        if (expand)
            content.style.display = "block";
        var max_height = content.offsetHeight;

        var step_height = step + (expand ? 0 : -max_height);
        toggleChevronIcon(content);
                
        // schedule first animated collapse/expand event
        content.style.height = Math.abs(step_height) + "px";
        setTimeout("togglePannelAnimatingStatus("
            + interval + "," + step
            + "," + max_height + "," + step_height + ")", interval);
       
    }
}

function togglePannelAnimatingStatus(interval,
    step, max_height, step_height)
{
    var step_height_abs = Math.abs(step_height);

    // schedule next animated collapse/expand event
    if (step_height_abs>=step && step_height_abs<=(max_height-step))
    {
        step_height += step;
        currentContent.style.height = Math.abs(step_height) + "px";
        setTimeout("togglePannelAnimatingStatus("
            + interval + "," + step
            + "," + max_height + "," + step_height + ")", interval);
    }
    // animated expand/collapse done
    else
    {
        if (step_height_abs<step)
            currentContent.style.display = "none";
        currentContent.style.height = "";
        currentContent = null;
    }
}

// change chevron icon into either collapse or expand
function toggleChevronIcon(content)
{
    
    //Find chevron on left
    var chevron = content.parentNode.firstChild.firstChild.childNodes[0];   
    
    //if not on left look to the right
    if(chevron.src == null)
    {
        chevron = content.parentNode.firstChild.childNodes[1].childNodes[0];
    } 
    
    var expand = (chevron.src.indexOf("expand.gif")>0);
    chevron.src = chevron.src
        .split(expand ? "expand.gif" : "collapse.gif")
        .join(expand ? "collapse.gif" : "expand.gif");
}

function MouseOverBG(header)
{
    header.className= (header.className == "squareboxgradientcaption" ? "squareboxgradientcaption_over" : "squareboxgradientcaption")
}




function addEvent(o,n,f,l){var a='addEventListener',h='on'+n,b='',s='';if(o[a]&&!l)return o[a](n,f,false);o._c|=0;if(o[h]){b='_f'+o._c++;o[b]=o[h]}s='_f'+o._c++;o[s]=f;o[h]=function(e){e=e||window.event;var r=true;if(b)r=o[b](e)!=false&&r;r=o[s](e)!=false&&r;return r}}

function expandCurrentNav()
{
    var nav = document.getElementById('navContainer');
    var lnks = nav.getElementsByTagName('a');
    
    var currentUrl = window.location.href;
    var currentFile = parseFilename(currentUrl);
    
    for(var i=0; i<lnks.length; i++)
    {
    
        //if(parseFilename(lnks[i].href) == currentFile)
        if(lnks[i].href == currentUrl)
        {
            //alert(lnks[i].parentNode.parentNode.parentNode.parentNode.className);
            
            ;
            
            if(lnks[i].parentNode.parentNode.parentNode.parentNode != null)
            {
                if(lnks[i].parentNode.parentNode.parentNode.parentNode.className == 'squareboxcontent')
                {
                    //alert(lnks[i].parentNode.parentNode.parentNode.parentNode.id);
                    togglePannelAnimatedStatus(lnks[i].parentNode.parentNode.parentNode.parentNode,50,50);
                    lnks[i].parentNode.style.display = 'block';
                }
                else
                {
                    if(lnks[i].parentNode.className == 'squareboxcontent')
                    {
                        togglePannelAnimatedStatus(lnks[i].parentNode,50,50);
                    }
                }
            }
            else
            {
                if(lnks[i].parentNode.className == 'squareboxcontent')
                {
                    togglePannelAnimatedStatus(lnks[i].parentNode,50,50);
                }
            }  
        }
    }
}

function parseFilename(url)
{   
    return url.substring(url.lastIndexOf('/')+1);
}


addEvent(window, 'load', new Function('expandCurrentNav();'));









function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}

