﻿// JScript File
function ToggleCategory(pos)
{
    var index = 1;
    
    var questions = document.getElementById("questions" + index);
    var arrow = document.getElementById("arrow" + index);
    
    while ((questions != null) && (arrow != null))
    {             
        if ((index == pos) && (questions.style.display == "none"))
        {     
            questions.style.display = "block";
            arrow.style.backgroundPosition = "-11px 0";
        }
        else
        {       
            questions.style.display = "none";
            arrow.style.backgroundPosition = "0 0";
        }
        
        // Calling this function with a pos of 0 will close all questions
        ToggleQuestion(index, 0);

        index++;

        questions = document.getElementById("questions" + index);
        arrow = document.getElementById("arrow" + index);
    }
}

function ToggleQuestion(section, pos)
{
    var index = 1;

    var question = document.getElementById("questions" + section + "question" + index);
    var answer = document.getElementById("questions" + section + "answer" + index);
    
    while ((question != null) && (answer != null))
    {             
        if ((index == pos) && (answer.style.display == "none"))
        {     
            question.style.display = "none";
            answer.style.display = "block";
        }
        else
        {       
            question.style.display = "block";
            answer.style.display = "none";
        }

        index++;

        question = document.getElementById("questions" + section + "question" + index);
        answer = document.getElementById("questions" + section + "answer" + index);
    }
}

