<!--

function radioquestioncheck(radiogroup)
{
  var numradios = radiogroup.length;
  var vanswer = "NULL";
  for (var i = 0; i < numradios; i++)
  {
    if(radiogroup[i].checked)
      { 
        vanswer = radiogroup[i].value;
        break;
      }
  }
  return vanswer;
}

function boxquestioncheck(checkboxgroup)
{
  var numboxes = checkboxgroup.length;
  var vanswer = "NULL";
  for (var i = 0; i < numboxes; i++)
  {
    if(checkboxgroup[i].checked)
      { 
        if (vanswer == "NULL")
             vanswer = checkboxgroup[i].value;
        else
             vanswer = vanswer+", "+checkboxgroup[i].value;
      }
  }
  return vanswer;
}


function checkdata()
{
  var j = 0;         //element count - 'numformelements' elements in form
  var i = 0;         //question count - 'quiznumquestions' questions in quiz
  var wordscorrect = 0;         //counts number of correct answers
  var useranswer = "";         //users answers
  var questionid = "";         //used to iterate through the questions

  for ( j = 0; j < numformelements; j++)
    {
       if (document.quizform.elements[j].id != questionid)
         {
            //determine the object id of the element to pass to the radiogroup/checkboxgroup check functions
            questionobjectid = eval('document.quizform.'+document.quizform.elements[j].id);  

            if ( document.quizform.elements[j].type == "radio") 
  		useranswer = radioquestioncheck(questionobjectid);
            else
  		useranswer = boxquestioncheck(questionobjectid);

            if (quizanswers[i] == useranswer) 
                wordscorrect++;
            else
              if (confirm('Would you like the correct answer to question '+(i+1)+'?'))
                alert(quizanswers[i]);

            questionid = document.quizform.elements[j].id;
            i = i + 1;           //question counter
          }
    }
  document.quizform.answertxt.value = wordscorrect;
  if (wordscorrect == quiznumquestions )
    alert('Congratulations you have completed the entire quiz correctly!!!!!!');
}


//-->
