﻿// FAQ Javascript - 20081010

function addOnclickHandler()
{
    var allAnchors;
    var anchorCount;
    var i = 0;
    var theId = "";
    allAnchors = document.getElementsByTagName("a");
    anchorCount = allAnchors.length;
    
    if (anchorCount > 0)
    {
        for (i=0; i<=anchorCount-1; i++)
        {
            if (document.getElementsByTagName("a")[i].id.substring(0,4) == 'lnk_')
            {
                theId = document.getElementsByTagName("a")[i].id;
                document.getElementsByTagName("a")[i].onclick = function() { swapDiv(this.id); }
                document.getElementsByTagName("a")[i].className = "arrowTextLink"; 
                document.getElementsByTagName("a")[i].href = "javascript:;";         
            }  
        }
    }  
}


function hideAnswers()
{
    if (document.getElementById)
    {
        var theDiv;
        var divCount;
        var i = 0;
        
        theDiv = document.getElementsByTagName("div");
        divCount = theDiv.length;
        
        if (divCount > 0)
        {
            for (i=0; i<=divCount-1; i++)
            {
                if (document.getElementsByTagName("div")[i].className.toLowerCase() == 'answercontainer')
                {
                   document.getElementsByTagName("div")[i].style.display = "none";
                }          
            }       
        }
    
    }
}

function swapDiv(callingId)
{
    var divName = "";
    
    if (callingId != "" && callingId != null)
    {
        if (callingId.substring(0,4) == 'lnk_')
        {
            if (document.getElementById(callingId))
            {
                divName = 'div_' + callingId.substring(4);
                if (document.getElementById(divName))
                {
                    if (document.getElementById(divName).style.display != 'block')
                    {
                        document.getElementById(divName).style.display = 'block';
                    }
                    else
                    {
                        document.getElementById(divName).style.display = 'none';
                    }                
                }
            }
        }
    }
    
    return false;
}

function setupFAQ()
{
    hideAnswers();
    addOnclickHandler();
}

window.onload = function() { setupFAQ(); }