//this script does stuff to the faqs

function hideAllAnswers() {
  var answers = getElementsByClass("answer");
  for (var i=0; i<answers.length; i++) {
    var answer = answers[i];
    answer.className="hidden answer";
  } //end for
} //end function

function hideOthers(titleId) {
  //alert ("answer_"+titleId.replace("question_",""));
  var questions = getElementsByClass("question");
  for (var i=0; i<questions.length; i++) {
    var question = questions[i];
	if (question.id!=titleId) {
      question.onclick = function () { return showAnswer(this.id); }
	} //end if
  } //end for
  var answers = getElementsByClass("answer");
  for (var i=0; i<answers.length; i++) {
    var answer = answers[i];
	if (answer.id!="answer_"+titleId.replace("question_","")) {
      answer.className="hidden answer";
	} //end if
  } //end for
} //end function

function showAnswer(titleId) {
  //hideOthers(titleId);
  document.getElementById(titleId).onclick = function () { return hideAnswer(this.id); }
  document.getElementById(titleId).className="question hide_answer"
  answerToShow=document.getElementById("answer_"+titleId.replace("question_",""));
  answerToShow.className="answer";
  return false;
} //end function

function hideAnswer(titleId) {
  //hideOthers(titleId);
  document.getElementById(titleId).onclick = function () { return showAnswer(this.id); }
  document.getElementById(titleId).className="question reveal_answer"
  answerToShow=document.getElementById("answer_"+titleId.replace("question_",""));
  answerToShow.className="hidden answer";
  return false;
} //end function

function initiateQA() {
  hideAllAnswers();
  var questions = getElementsByClass("question");
  if (questions.length<1) { return; }
  for (var i=0; i<questions.length; i++) {
    var question = questions[i];
    question.onclick = function () { return showAnswer(this.id); }
    question.className="question reveal_answer"
	//question.style.color = "#f00";
  } //end for
} //end function
addLoadEvent(initiateQA);