function checkFields() {
missinginfo = "";
if (document.quiz_form.name.value == "") {
missinginfo += "\n     -  Name";
}
if ((document.quiz_form.email.value == "") || 
(document.quiz_form.email.value.indexOf('@') == -1) || 
(document.quiz_form.email.value.indexOf('.') == -1)) {
missinginfo += "\n     -  Email address";
}

if (missinginfo != "") {
missinginfo ="\n" +
"You failed to correctly fill in your:\n" +
missinginfo + "\n" +
"\nPlease re-enter and submit again!";
alert(missinginfo);
return false;
}
else return true;
}

function CheckChoice(whichbox)
     {
          with (whichbox.form)
          {
               if (whichbox.type == "radio")
               {
                         if (whichbox.name == "references")
                         {
                              hiddentotal.value = eval(hiddentotal.value) - eval(hiddenpriorradio.value);
                              hiddenpriorradio.value = eval(whichbox.amount);
                              hiddentotal.value = eval(hiddentotal.value) + eval(whichbox.amount);
                         }
                         else if (whichbox.name == "short")
                         {
                              hiddentotal.value = eval(hiddentotal.value) - eval(hiddenpriorradio2.value);
                              hiddenpriorradio2.value = eval(whichbox.amount);
                              hiddentotal.value = eval(hiddentotal.value) + eval(whichbox.amount);
                         }
						 else if (whichbox.name == "time")
                         {
                              hiddentotal.value = eval(hiddentotal.value) - eval(hiddenpriorradio3.value);
                              hiddenpriorradio3.value = eval(whichbox.amount);
                              hiddentotal.value = eval(hiddentotal.value) + eval(whichbox.amount);
                         }
						 else if (whichbox.name == "sit")
                         {
                              hiddentotal.value = eval(hiddentotal.value) - eval(hiddenpriorradio4.value);
                              hiddenpriorradio4.value = eval(whichbox.amount);
                              hiddentotal.value = eval(hiddentotal.value) + eval(whichbox.amount);
                         }
						 else if (whichbox.name == "talking")
                         {
                              hiddentotal.value = eval(hiddentotal.value) - eval(hiddenpriorradio5.value);
                              hiddenpriorradio5.value = eval(whichbox.amount);
                              hiddentotal.value = eval(hiddentotal.value) + eval(whichbox.amount);
                         }
						 else if (whichbox.name == "questions")
                         {
                              hiddentotal.value = eval(hiddentotal.value) - eval(hiddenpriorradio6.value);
                              hiddenpriorradio6.value = eval(whichbox.amount);
                              hiddentotal.value = eval(hiddentotal.value) + eval(whichbox.amount);
                         }
						 else if (whichbox.name == "ask")
                         {
                              hiddentotal.value = eval(hiddentotal.value) - eval(hiddenpriorradio7.value);
                              hiddenpriorradio7.value = eval(whichbox.amount);
                              hiddentotal.value = eval(hiddentotal.value) + eval(whichbox.amount);
                         }
						 else if (whichbox.name == "explain")
                         {
                              hiddentotal.value = eval(hiddentotal.value) - eval(hiddenpriorradio8.value);
                              hiddenpriorradio8.value = eval(whichbox.amount);
                              hiddentotal.value = eval(hiddentotal.value) + eval(whichbox.amount);
                         }
						 else if (whichbox.name == "prepare")
                         {
                              hiddentotal.value = eval(hiddentotal.value) - eval(hiddenpriorradio9.value);
                              hiddenpriorradio9.value = eval(whichbox.amount);
                              hiddentotal.value = eval(hiddentotal.value) + eval(whichbox.amount);
                         }
						 else if (whichbox.name == "hire")
                         {
                              hiddentotal.value = eval(hiddentotal.value) - eval(hiddenpriorradio10.value);
                              hiddenpriorradio10.value = eval(whichbox.amount);
                              hiddentotal.value = eval(hiddentotal.value) + eval(whichbox.amount);
                         }
               }
               else
               {
                    if (whichbox.checked == false)
                         { hiddentotal.value = eval(hiddentotal.value) - eval(whichbox.value); }
                    else      { hiddentotal.value = eval(hiddentotal.value) + eval(whichbox.value); }
               }
               if (hiddentotal.value < 0)
                    {
                    UnitForm();
                    }
               return(formatAmount(hiddentotal.value));
          }
     }
     function formatAmount(num)
     {
          num = num.toString().replace(/\$|\,/g,'');
          if(isNaN(num))
             num = "0";
          sign = (num == (num = Math.abs(num)));
          num = Math.floor(num*100+0.50000000001);
          cents = num%100;
          num = Math.floor(num/100).toString();
          if(cents<10)
              cents = "0" + cents;
          for (var i = 0; i < Math.floor((num.length-(1+i))/3); i++)
              num = num.substring(0,num.length-(4*i+3))+','+
                    num.substring(num.length-(4*i+3));
           return (((sign)?'':'-')+ num);
     }

     function UnitForm()
          {
          document.quiz_form.total.value='0';
          document.quiz_form.hiddentotal.value=0;
          document.quiz_form.hiddenpriorradio.value=0;
          document.quiz_form.hiddenpriorradio2.value=0;
		  document.quiz_form.hiddenpriorradio3.value=0;
		  document.quiz_form.hiddenpriorradio4.value=0;
		  document.quiz_form.hiddenpriorradio5.value=0;
		  document.quiz_form.hiddenpriorradio6.value=0;
		  document.quiz_form.hiddenpriorradio7.value=0;
		  document.quiz_form.hiddenpriorradio8.value=0;
		  document.quiz_form.hiddenpriorradio9.value=0;
		  document.quiz_form.hiddenpriorradio10.value=0;
		  
          for (xx=0; xx < document.quiz_form.elements.length; xx++)
          {
             if (document.quiz_form.elements[xx].type == 'checkbox' | document.quiz_form.elements[xx].type == 'radio')
               {
               document.quiz_form.elements[xx].checked = false;
               }
          }
     }
	 


