<!-- Hide this script from old browsers.

// Copyright 2006 Jason Cheever. All rights reserved.

//---------------------------------------------------------------------------------------------------------
//
// jdc_tally_results();
//
//   Validates the quiz answers, reports the results, and recommends a course of action.
//
//---------------------------------------------------------------------------------------------------------

function jdc_tally_results() {

  var index_total;
  var index_question;
  var index_answer;
  var valid_answer;
  var element_name;
  var number_answers;
  var totals = new Array( 3 );
  var message;
  var new_tally_message;
  var tally_element;
  
  // Initialization.
  for ( index_total = 0; index_total < totals.length; index_total++ ) {
    totals[ index_total ] = 0;
  }

  // Make sure the user answered all the questions.
  
  // Loop thru each question.
  for ( index_question = 0; index_question < 10; index_question++ ) {
 
    // Determine the number of answers for this question.
    element_name = "question_" + ( index_question + 1 );
    number_answers = document.forms[ 0 ].elements[ element_name ].length

    // Loop thru each answer.
    valid_answer = false;
    for ( index_answer = 0; index_answer < number_answers; index_answer++ ) {
      if ( document.forms[ 0 ].elements[ element_name ][ index_answer ].checked == true ) {
        valid_answer = true;
        totals[ index_answer ]++;
        break;
      }
    }
     
    // If none of the radio buttons was checked, then we have a problem.
    if ( valid_answer == false ) {
      alert( "No haz contestado la pregunta #" + ( index_question + 1 ) + "." );
      return;
    }
  }
  
  // Write the quiz results.
  new_tally_message = document.createTextNode( totals[ 0 ] );
  tally_element = document.getElementById( "quiz_tally_y" );
  tally_element.replaceChild( new_tally_message, tally_element.firstChild );
  if ( totals[ 0  ] == 1 ) {
    new_tally_message = document.createTextNode( "" );
    tally_element = document.getElementById( "quiz_tally_plural" );
    tally_element.replaceChild( new_tally_message, tally_element.firstChild );
  }
  
  // Make the results visible (and the Tally button invisible).
  document.getElementById( "quiz_tally_button" ).style.display = "none";
  document.getElementById( "quiz_results_div" ).style.display = "block";

  return;
}


  
// End of hiding script from old browsers. -->
