function ScrollToAnchor(window, anchorname)
{
  with (window.document) {
    for (var Index = 0; Index < anchors.length; Index++) {
      if (anchors[Index].name == anchorname)
        window.scrollTo(anchors[Index].x, anchors[Index].y);
    }
  }
}

Anchors     = ['0', '11', '26', '36'];
Explanation = '<table align="center", cellpadding="8" cellspacing="0" border="0">' +
'<tr><td valign=top nowrap><b>0 - 10</b></td>' +
'<td valign=top><a name="0"></a>Both you and your organization could stand to use some help in building your agility competency.  Organizations scoring in this range are typically working in reactive mode, dealing with changes only as they become problems in the moment.  In groups such as this you may see difficulties in how people cope with the demands placed on them either externally or internally.  Resistance to changing the status quo may be high, and physician groups and other clinical staff may be mired in finding short-term solutions to protect their own self-interests.  Communication is limited and trust and accountability is lacking.  Physician leaders scoring in this category may find that they constantly are bumping up against resistance to any new ideas, and struggle to create and effectively communicate sustainable plans of action. </td></tr>' + 
'<tr><td valign=top nowrap><b>11 - 25</b></td>' +
'<td valign=top><a name="11"></a>There may be some areas that you or your organization are doing fairly well, but there are still significant areas for improvement to ensure that both you and your group have the flexibility and responsiveness that it takes to remain competitive and ahead of the game, the goal of agility.  Here is an opportunity for you to identify the trouble spots that may be limiting your agility capability, and to take steps to correct things that are not working at this time.</td></tr>' + 
'<tr><td valign=top nowrap><b>26 - 35</b>&nbsp;</td>' +
'<td valign=top><a name="26"></a>You and your organization are definitely on the right track!  Now is the time to assess any challenge areas and address them with actionable plans, as well as capitalize on all of the things that you are doing well.  Continue to build your agility competency by reinforcing the behaviors that foster accountability, trust, effective communication, and proactive approaches to change.  You are on your way.</td></tr>' +
'<tr><td valign=top nowrap><b>36 - 40</b>&nbsp;</td>' +
'<td valign=top><a name="36"></a>Congratulations! There are very few physician leaders and health organizations that can say that they are at this level of agility. Share what is working within your groups and the outcomes that your high degree of competency creates for you. However, do not give in to the temptation to rest on your laurels - challenges can still arise, even in the most agile of organizations or individuals, and it is important to continually re-assess and recalibrate your approach as needed. </td></tr>' +
'</table>';

function Score() {
  // Calculate the score
  var Result = 0;
  for (var Index = 0; Index < document.Quiz.elements.length; Index++)
    if (document.Quiz.elements[Index].type == 'radio' &&
        document.Quiz.elements[Index].checked)
      Result += Number( document.Quiz.elements[Index].value );

  // Calculate its anchor
  var Index;
  for (Index = 0; Index < Anchors.length; Index++) {
    if (Result == Number(Anchors[Index]) || Index+1 == Anchors.length || Result < Number(Anchors[Index+1])) break;
  }
  var Anchor = Anchors[Index];

  // Highlight the right section
  var re = new RegExp('(valign=top><a name="' + Anchor + '">)', '');
  var thisExplanation = Explanation.replace(re, 'bgcolor="#ECECC4" $1' );

  // Build the score window
  var newWindow = window.open('', 'score_window', 'width=650,height=550,scrollbars=yes');
  with (newWindow.document) {
    open();
    write('<html><head><title>Your Score</title></head>',
          '<frameset rows="70,*" border=0>',
          '<frame name="Score"       src="about:blank" marginheight=4 marginwidth=4 scrolling="none" >',
          '<frame name="Explanation" src="about:blank" marginheight=4 marginwidth=4 scrolling="auto">',
          '</frameset></html>');
    close();
  }
  newWindow.focus();
  with (newWindow.Score.document) {
    open();
    write('<html><head><link href="stylesheet.css" rel="stylesheet" type="text/css"></head><body class="bg-ltblue">\n',
          '<h2 align="center"><span class="quiz-h2">Your score is ', Result, '</span><br><span class="quiz-h3">on a scale of 0 - 40</span></h2>\n',
          '</body></html>');
    close();
  }
  with (newWindow.Explanation.document) {
    open();
    writeln('<html><head><link href="stylesheet.css" rel="stylesheet" type="text/css"></head><body class="bg-ltblue2"><body bgcolor=white>\n', thisExplanation, '</body></html>');
    close();
  }

  // Scroll it to the right explanation
  ScrollToAnchor(newWindow.Explanation, Anchor);
}
