function showReports(reportSelectObj) {
  for (i = reportSelectObj.options.length - 1; i > 0; i-- ) {
    document.getElementById(reportSelectObj.options[i].value).style.display = 'none';
  }
  if (reportSelectObj.options[reportSelectObj.options.selectedIndex].value != 0) {
    document.getElementById(reportSelectObj.options[reportSelectObj.options.selectedIndex].value).style.display = 'inline';
  }
}
function openPageDescription(pageId) {
  var pageStyleObj = document.getElementById(pageId);
  var imgId = pageId + "_img";
  var imgObj = document.getElementById(imgId);
  if (pageStyleObj.style.display == 'inline') {
    pageStyleObj.style.display = 'none';
    imgObj.src = "http://www.reece.com.au/new/images/stats/open.jpg";
  }
  else {
    pageStyleObj.style.display = 'inline';
    imgObj.src = "http://www.reece.com.au/new/images/stats/close.jpg";
  }
}
function getScore(id) {
  var score = 0;
  currentQuestion = document.test['q'+id];
  for(i=0;i<currentQuestion.length;i++) {
    if(currentQuestion[i].checked) {
      score = parseInt(currentQuestion[i].value);
      return score;
    }
  }
  return 0;
}
function feedback(score) {
  var theirScore = document.getElementById("theirScore");
  var yes = document.getElementById("yes");
  var maybe = document.getElementById("maybe");
  var no = document.getElementById("no");
  yes.style.display = "block";
  maybe.style.display = "block";
  no.style.display = "block";
  yes.innerHTML = 'If you had scored 30-40:<br />You sound like a real Reece person and we&#8217;d love to talk to you.';
  maybe.innerHTML = 'If you had scored 20-29:<br />Let&#8217;s have a chat about what&#8217;s important to you in a career and see where it leads.';
  no.innerHTML = 'If you had scored less than 19:<br />Maybe look at the career in amateur theatre.';
  if(score > 29) {
    document.getElementById("encouragement").innerHTML = 'Well done';
    yes.style.display = "none";
    theirScore.innerHTML = 'You sound like a real Reece person and we&#8217;d love to talk to you.';
  }
  else if(score > 19) {
    document.getElementById("encouragement").innerHTML = 'Well done';
    maybe.style.display = "none";
    theirScore.innerHTML = 'Let&#8217;s have a chat about what&#8217;s important to you in a career and see where it leads.';
  }
  else {
    document.getElementById("encouragement").innerHTML = 'Nice try';
    no.style.display = "none";
    theirScore.innerHTML = 'Maybe look at the career in amateur theatre.';
  }
}
function getSelection(id) {
  currentQuestion = document.test['q'+id];
  for(i=0;i<currentQuestion.length;i++) {
    if(currentQuestion[i].checked) {
      return i;
    }
  }
}
function formReset() {
  document.getElementById("block").style.display = "none";
}
function show() {
  var total = 0;
  document.getElementById("block").style.display = "block";
  for(j = 1; j <= 10; j++) {
    displayScore = document.getElementById('question'+j);
    score = getScore(j);
    if(score == 0) {
      displayScore.innerHTML = 'Not answered';
    }
    else {
      displayScore.innerHTML = score;
    }
    displayTotal = document.getElementById('total');
    total += score;
    displayTotal.innerHTML = total;
    selection = getSelection(j);
    if(selection >= 0) {
      selection++;
      selectedAns = document.getElementById('selection_'+j+'_'+selection);
      for(i = 1; i <= 4; i++) {
        clearClass = document.getElementById('selection_'+j+'_'+i);
        clearClass.setAttribute('className', '');
      }
      selectedAns.setAttribute('className', 'selected');
      selectedAns.setAttribute('class', 'selected');
    }
  }
  feedback(total);
}