var questions = document.getElementsByTagName('dt');
var answers = document.getElementsByTagName('dd');

function toggleNext(element) {
	var next = element.nextSibling;
	while(next.nodeType != 1) next=next.nextSibling; // if it gets to a non-element node, go to the next one
	next.className=((next.className=="hide") ? "show" : "hide");
  element.className=((element.className=="collapsed-arrow") ? "expanded-arrow" : "collapsed-arrow");
}
function toggleParent(element) {
	var next = element.nextSibling;
	while(next.nodeType != 1) next=next.nextSibling; // if it gets to a non-element node, go to the next one
	next.className=((next.className=="collapsed-arrow") ? "expanded-arrow" : "collapsed-arrow");

}        
function displayToggle(){
  for (i=0; i<questions.length; i++) { // loops through the questions 
    questions[i].onclick=function() { // shows the answers onclick
      toggleNext(this);
    }
  }
}
function toggleAllOff(){
  for(var i=0; i<answers.length; i++){
    answers[i].className = 'hide';
    questions[i].className = 'collapsed-arrow';
  }
}
function toggleAllOn(){
  for(var i=0; i<answers.length; i++){
    answers[i].className = 'show';
    questions[i].className = 'expanded-arrow';
  }
}
window.onload=function(){
  toggleAllOff();
  displayToggle();
}