var ERROR;
var FinalError;
var Result
var theScore
var theRecip

ERROR = false;
FinalError = "";
Result = ""
theScore = ""
theRecip = ""

function SubmitResults()
{
 checkInfo(); 
 if(!ERROR){
	 	copyFlds();
 		chkCompleted();
	}
  if(!ERROR){
	  	return chkQuiz();
	}
 if(ERROR) {
 ErrorHandler()
 }
}

function checkInfo()
{
	if(document.CR_SampleTest.txtName.value.length < 1)
    	ErrorBuilder("Please provide your Name.");
	if(document.CR_SampleTest.txtEmail.value.length < 1)
		ErrorBuilder("Please provide your Email Address.");
	if(document.CR_SampleTest.txtEmail.value.length > 0){
		if ( document.CR_SampleTest.txtEmail.value.indexOf("@")==-1 || document.CR_SampleTest.txtEmail.value.indexOf(".")==-1 || document.CR_SampleTest.txtEmail.value.indexOf(" ")!=-1 || document.CR_SampleTest.txtEmail.value.length < 6 ){
		ErrorBuilder("You must provide a valid email address.\n                 example: someone@somewhere.com");}}
}

function setText() {
	if(document.CR_SampleTest.chkContact.checked) {
		document.CR_SampleTest.SendTo.value = document.CR_SampleTest.txtEmail.value
		document.CR_SampleTest.SendTo2.value = "drivecrossroads@comcast.net"
	}
	if(!document.CR_SampleTest.chkContact.checked) {
		document.CR_SampleTest.SendTo.value = document.CR_SampleTest.txtEmail.value
		document.CR_SampleTest.SendTo2.value = ""
	}
}

function copyFlds() {
	
		document.CR_SampleTest.theName.value = document.CR_SampleTest.txtName.value
		document.CR_SampleTest.theEmail.value = document.CR_SampleTest.txtEmail.value
		document.CR_SampleTest.theCity.value = document.CR_SampleTest.txtCity.value
		document.CR_SampleTest.theState.value = document.CR_SampleTest.selState.value
		document.CR_SampleTest.theZip.value = document.CR_SampleTest.txtZip.value
		document.CR_SampleTest.theTele.value = document.CR_SampleTest.txtTele.value
}

function chkCompleted() {
	var theForm = document.CR_SampleTest
	if(setChkIndx(theForm.radCR1) == "*") {
		ErrorBuilder("Please provide an answer to question #1") }
	if(setChkIndx(theForm.radCR2) == "*") {
		ErrorBuilder("Please provide an answer to question #2") }
	if(setChkIndx(theForm.radCR3) == "*") {
		ErrorBuilder("Please provide an answer to question #3") }
	if(setChkIndx(theForm.radCR4) == "*") {
		ErrorBuilder("Please provide an answer to question #4") }
	if(setChkIndx(theForm.radCR5) == "*") {
		ErrorBuilder("Please provide an answer to question #5") }
	if(setChkIndx(theForm.radCR6) == "*") {
		ErrorBuilder("Please provide an answer to question #6") }
	if(setChkIndx(theForm.radCR7) == "*") {
		ErrorBuilder("Please provide an answer to question #7") }
	if(setChkIndx(theForm.radCR8) == "*") {
		ErrorBuilder("Please provide an answer to question #8") }
	if(setChkIndx(theForm.radCR9) == "*") {
		ErrorBuilder("Please provide an answer to question #9") }
	if(setChkIndx(theForm.radCR10) == "*") {
		ErrorBuilder("Please provide an answer to question #10") }
	if(setChkIndx(theForm.radCR11) == "*") {
		ErrorBuilder("Please provide an answer to question #11") }
	if(setChkIndx(theForm.radCR12) == "*") {
		ErrorBuilder("Please provide an answer to question #12") }
	if(setChkIndx(theForm.radCR13) == "*") {
		ErrorBuilder("Please provide an answer to question #13") }
	if(setChkIndx(theForm.radCR14) == "*") {
		ErrorBuilder("Please provide an answer to question #14") }
	if(setChkIndx(theForm.radCR15) == "*") {
		ErrorBuilder("Please provide an answer to question #15") }
	if(setChkIndx(theForm.radCR16) == "*") {
		ErrorBuilder("Please provide an answer to question #16") }
	if(setChkIndx(theForm.radCR17) == "*") {
		ErrorBuilder("Please provide an answer to question #17") }
	if(setChkIndx(theForm.radCR18) == "*") {
		ErrorBuilder("Please provide an answer to question #18") }
	if(setChkIndx(theForm.radCR19) == "*") {
		ErrorBuilder("Please provide an answer to question #19") }
	if(setChkIndx(theForm.radCR20) == "*") {
		ErrorBuilder("Please provide an answer to question #20") }
	if(setChkIndx(theForm.radCR21) == "*") {
		ErrorBuilder("Please provide an answer to question #21") }
	if(setChkIndx(theForm.radCR22) == "*") {
		ErrorBuilder("Please provide an answer to question #22") }
	if(setChkIndx(theForm.radCR23) == "*") {
		ErrorBuilder("Please provide an answer to question #23") }
	if(setChkIndx(theForm.radCR24) == "*") {
		ErrorBuilder("Please provide an answer to question #24") }
	if(setChkIndx(theForm.radCR25) == "*") {
		ErrorBuilder("Please provide an answer to question #25") }
	if(setChkIndx(theForm.radCR26) == "*") {
		ErrorBuilder("Please provide an answer to question #26") }
	if(setChkIndx(theForm.radCR27) == "*") {
		ErrorBuilder("Please provide an answer to question #27") }
	if(setChkIndx(theForm.radCR28) == "*") {
		ErrorBuilder("Please provide an answer to question #28") }
	if(setChkIndx(theForm.radCR29) == "*") {
		ErrorBuilder("Please provide an answer to question #29") }
	if(setChkIndx(theForm.radCR30) == "*") {
		ErrorBuilder("Please provide an answer to question #30") }
	if(setChkIndx(theForm.radCR31) == "*") {
		ErrorBuilder("Please provide an answer to question #31") }
	if(setChkIndx(theForm.radCR32) == "*") {
		ErrorBuilder("Please provide an answer to question #32") }
	if(setChkIndx(theForm.radCR33) == "*") {
		ErrorBuilder("Please provide an answer to question #33") }
	if(setChkIndx(theForm.radCR34) == "*") {
		ErrorBuilder("Please provide an answer to question #34") }
	if(setChkIndx(theForm.radCR35) == "*") {
		ErrorBuilder("Please provide an answer to question #35") }
	if(setChkIndx(theForm.radCR36) == "*") {
		ErrorBuilder("Please provide an answer to question #36") }
	if(setChkIndx(theForm.radCR37) == "*") {
		ErrorBuilder("Please provide an answer to question #37") }
	if(setChkIndx(theForm.radCR38) == "*") {
		ErrorBuilder("Please provide an answer to question #38") }
	if(setChkIndx(theForm.radCR39) == "*") {
		ErrorBuilder("Please provide an answer to question #39") }
	if(setChkIndx(theForm.radCR40) == "*") {
		ErrorBuilder("Please provide an answer to question #40") }
	if(setChkIndx(theForm.radCR41) == "*") {
		ErrorBuilder("Please provide an answer to question #41") }
	if(setChkIndx(theForm.radCR42) == "*") {
		ErrorBuilder("Please provide an answer to question #42") }
	if(setChkIndx(theForm.radCR43) == "*") {
		ErrorBuilder("Please provide an answer to question #43") }
	if(setChkIndx(theForm.radCR44) == "*") {
		ErrorBuilder("Please provide an answer to question #44") }
	if(setChkIndx(theForm.radCR45) == "*") {
		ErrorBuilder("Please provide an answer to question #45") }
	if(setChkIndx(theForm.radCR46) == "*") {
		ErrorBuilder("Please provide an answer to question #46") }
	if(setChkIndx(theForm.radCR47) == "*") {
		ErrorBuilder("Please provide an answer to question #47") }
	if(setChkIndx(theForm.radCR48) == "*") {
		ErrorBuilder("Please provide an answer to question #48") }
	if(setChkIndx(theForm.radCR49) == "*") {
		ErrorBuilder("Please provide an answer to question #49") }
	if(setChkIndx(theForm.radCR50) == "*") {
		ErrorBuilder("Please provide an answer to question #50") }
}

function chkQuiz() {
	var theForm = document.CR_SampleTest
	Result = "<br><br>Your test results are as follows:<br><br>"
	
	if(setChkIndx(theForm.radCR1) != "A") {
		Result += "<font color='red'>1) Incorrect: Your answer was " + setChkIndx(theForm.radCR1) + " and the correct answer is A.</font>\n";
		theForm.score_1.value = "0" }
	else {
		Result += "<font color='green'>1) Correct! The answer is A.</font>\n"; 
		theForm.score_1.value = "1" }
	if(setChkIndx(theForm.radCR2) != "C") {
		Result += "<br><br><font color='red'>2) Incorrect: Your answer was " + setChkIndx(theForm.radCR2) + " and the correct answer is C.</font>\n"; 
		theForm.score_2.value = "0" }
	else {
		Result += "<br><br><font color='green'>2) Correct! The answer is C.</font>\n"; 
		theForm.score_2.value = "1" }
	if(setChkIndx(theForm.radCR3) != "A") {
		Result += "<br><br><font color='red'>3) Incorrect: Your answer was " + setChkIndx(theForm.radCR3) + " and the correct answer is A.</font>\n"; 
		theForm.score_3.value = "0" }
	else {
		Result += "<br><br><font color='green'>3) Correct! The answer is A.</font>\n"; 
		theForm.score_3.value = "1" }
	if(setChkIndx(theForm.radCR4) != "B") {
		Result += "<br><br><font color='red'>4) Incorrect: Your answer was " + setChkIndx(theForm.radCR4) + " and the correct answer is B.</font>\n"; 
		theForm.score_4.value = "0" }
	else {
		Result += "<br><br><font color='green'>4) Correct! The answer is B.</font>\n"; 
		theForm.score_4.value = "1" }
	if(setChkIndx(theForm.radCR5) != "A") {
		Result += "<br><br><font color='red'>5) Incorrect: Your answer was " + setChkIndx(theForm.radCR5) + " and the correct answer is A.</font>\n"; 
		theForm.score_5.value = "0" }
	else {
		Result += "<br><br><font color='green'>5) Correct! The answer is A.</font>\n"; 
		theForm.score_5.value = "1" }
	if(setChkIndx(theForm.radCR6) != "D") {
		Result += "<br><br><font color='red'>6) Incorrect: Your answer was " + setChkIndx(theForm.radCR6) + " and the correct answer is D.</font>\n"; 
		theForm.score_6.value = "0" }
	else {
		Result += "<br><br><font color='green'>6) Correct! The answer is D.</font>\n"; 
		theForm.score_6.value = "1" }
	if(setChkIndx(theForm.radCR7) != "C") {
		Result += "<br><br><font color='red'>7) Incorrect: Your answer was " + setChkIndx(theForm.radCR7) + " and the correct answer is C.</font>\n"; 
		theForm.score_7.value = "0" }
	else {
		Result += "<br><br><font color='green'>7) Correct! The answer is C.</font>\n"; 
		theForm.score_7.value = "1" }
	if(setChkIndx(theForm.radCR8) != "D") {
		Result += "<br><br><font color='red'>8) Incorrect: Your answer was " + setChkIndx(theForm.radCR8) + " and the correct answer is D.</font>\n"; 
		theForm.score_8.value = "0" }
	else {
		Result += "<br><br><font color='green'>8) Correct! The answer is D.</font>\n"; 
		theForm.score_8.value = "1" }
	if(setChkIndx(theForm.radCR9) != "C") {
		Result += "<br><br><font color='red'>9) Incorrect: Your answer was " + setChkIndx(theForm.radCR9) + " and the correct answer is C.</font>\n";
		theForm.score_9.value = "0"  }
	else {
		Result += "<br><br><font color='green'>9) Correct! The answer is C.</font>\n"; 
		theForm.score_9.value = "1" }
	if(setChkIndx(theForm.radCR10) != "B") {
		Result += "<br><br><font color='red'>10) Incorrect: Your answer was " + setChkIndx(theForm.radCR10) + " and the correct answer is B.</font>\n"; 
		theForm.score_10.value = "0" }
	else {
		Result += "<br><br><font color='green'>10) Correct! The answer is B.</font>\n"; 
		theForm.score_10.value = "1" }
	if(setChkIndx(theForm.radCR11) != "A") {
		Result += "<br><br><font color='red'>11) Incorrect: Your answer was " + setChkIndx(theForm.radCR11) + " and the correct answer is A.</font>\n"; 
		theForm.score_11.value = "0" }
	else {
		Result += "<br><br><font color='green'>11) Correct! The answer is A.</font>\n"; 
		theForm.score_11.value = "1" }
	if(setChkIndx(theForm.radCR12) != "C") {
		Result += "<br><br><font color='red'>12) Incorrect: Your answer was " + setChkIndx(theForm.radCR12) + " and the correct answer is C.</font>\n"; 
		theForm.score_12.value = "0" }
	else {
		Result += "<br><br><font color='green'>12) Correct! The answer is C.</font>\n"; 
		theForm.score_12.value = "1" }
	if(setChkIndx(theForm.radCR13) != "D") {
		Result += "<br><br><font color='red'>13) Incorrect: Your answer was " + setChkIndx(theForm.radCR13) + " and the correct answer is D.</font>\n"; 
		theForm.score_13.value = "0" }
	else {
		Result += "<br><br><font color='green'>13) Correct! The answer is D.</font>\n"; 
		theForm.score_13.value = "1" }
	if(setChkIndx(theForm.radCR14) != "B") {
		Result += "<br><br><font color='red'>14) Incorrect: Your answer was " + setChkIndx(theForm.radCR14) + " and the correct answer is B.</font>\n"; 
		theForm.score_14.value = "0" }
	else {
		Result += "<br><br><font color='green'>14) Correct! The answer is B.</font>\n"; 
		theForm.score_14.value = "1" }
	if(setChkIndx(theForm.radCR15) != "C") {
		Result += "<br><br><font color='red'>15) Incorrect: Your answer was " + setChkIndx(theForm.radCR15) + " and the correct answer is C.</font>\n"; 
		theForm.score_15.value = "0" }
	else {
		Result += "<br><br><font color='green'>15) Correct! The answer is C.</font>\n"; 
		theForm.score_15.value = "1" }
	if(setChkIndx(theForm.radCR16) != "D") {
		Result += "<br><br><font color='red'>16) Incorrect: Your answer was " + setChkIndx(theForm.radCR16) + " and the correct answer is D.</font>\n"; 
		theForm.score_16.value = "0" }
	else {
		Result += "<br><br><font color='green'>16) Correct! The answer is D.</font>\n"; 
		theForm.score_16.value = "1" }
	if(setChkIndx(theForm.radCR17) != "C") {
		Result += "<br><br><font color='red'>17) Incorrect: Your answer was " + setChkIndx(theForm.radCR17) + " and the correct answer is C.</font>\n"; 
		theForm.score_17.value = "0" }
	else {
		Result += "<br><br><font color='green'>17) Correct! The answer is C.</font>\n"; 
		theForm.score_17.value = "1" }
	if(setChkIndx(theForm.radCR18) != "C") {
		Result += "<br><br><font color='red'>18) Incorrect: Your answer was " + setChkIndx(theForm.radCR18) + " and the correct answer is C.</font>\n"; 
		theForm.score_18.value = "0" }
	else {
		Result += "<br><br><font color='green'>18) Correct! The answer is C.</font>\n"; 
		theForm.score_18.value = "1" }
	if(setChkIndx(theForm.radCR19) != "D") {
		Result += "<br><br><font color='red'>19) Incorrect: Your answer was " + setChkIndx(theForm.radCR19) + " and the correct answer is D.</font>\n"; 
		theForm.score_19.value = "0" }
	else {
		Result += "<br><br><font color='green'>19) Correct! The answer is D.</font>\n"; 
		theForm.score_19.value = "1" }
	if(setChkIndx(theForm.radCR20) != "A") {
		Result += "<br><br><font color='red'>20) Incorrect: Your answer was " + setChkIndx(theForm.radCR20) + " and the correct answer is A.</font>\n"; 
		theForm.score_20.value = "0" }
	else {
		Result += "<br><br><font color='green'>20) Correct! The answer is A.</font>\n"; 
		theForm.score_20.value = "1" }
	if(setChkIndx(theForm.radCR21) != "C") {
		Result += "<br><br><font color='red'>21) Incorrect: Your answer was " + setChkIndx(theForm.radCR21) + " and the correct answer is C.</font>\n"; 
		theForm.score_21.value = "0" }
	else {
		Result += "<br><br><font color='green'>21) Correct! The answer is C.</font>\n"; 
		theForm.score_21.value = "1" }
	if(setChkIndx(theForm.radCR22) != "D") {
		Result += "<br><br><font color='red'>22) Incorrect: Your answer was " + setChkIndx(theForm.radCR22) + " and the correct answer is D.</font>\n"; 
		theForm.score_22.value = "0" }
	else {
		Result += "<br><br><font color='green'>22) Correct! The answer is D.</font>\n"; 
		theForm.score_22.value = "1" }
	if(setChkIndx(theForm.radCR23) != "C") {
		Result += "<br><br><font color='red'>23) Incorrect: Your answer was " + setChkIndx(theForm.radCR23) + " and the correct answer is C.</font>\n"; 
		theForm.score_23.value = "0" }
	else {
		Result += "<br><br><font color='green'>23) Correct! The answer is C.</font>\n"; 
		theForm.score_23.value = "1" }
	if(setChkIndx(theForm.radCR24) != "A") {
		Result += "<br><br><font color='red'>24) Incorrect: Your answer was " + setChkIndx(theForm.radCR24) + " and the correct answer is A.</font>\n"; 
		theForm.score_24.value = "0" }
	else {
		Result += "<br><br><font color='green'>24) Correct! The answer is A.</font>\n"; 
		theForm.score_24.value = "1" }
	if(setChkIndx(theForm.radCR25) != "D") {
		Result += "<br><br><font color='red'>25) Incorrect: Your answer was " + setChkIndx(theForm.radCR25) + " and the correct answer is D.</font>\n"; 
		theForm.score_25.value = "0" }
	else {
		Result += "<br><br><font color='green'>25) Correct! The answer is D.</font>\n"; 
		theForm.score_25.value = "1" }
	if(setChkIndx(theForm.radCR26) != "A") {
		Result += "<br><br><font color='red'>26) Incorrect: Your answer was " + setChkIndx(theForm.radCR26) + " and the correct answer is A.</font>\n"; 
		theForm.score_26.value = "0" }
	else {
		Result += "<br><br><font color='green'>26) Correct! The answer is A.</font>\n"; 
		theForm.score_26.value = "1" }
	if(setChkIndx(theForm.radCR27) != "D") {
		Result += "<br><br><font color='red'>27) Incorrect: Your answer was " + setChkIndx(theForm.radCR27) + " and the correct answer is D.</font>\n"; 
		theForm.score_27.value = "0" }
	else {
		Result += "<br><br><font color='green'>27) Correct! The answer is D.</font>\n"; 
		theForm.score_27.value = "1" }
	if(setChkIndx(theForm.radCR28) != "A") {
		Result += "<br><br><font color='red'>28) Incorrect: Your answer was " + setChkIndx(theForm.radCR28) + " and the correct answer is A.</font>\n"; 
		theForm.score_28.value = "0" }
	else {
		Result += "<br><br><font color='green'>28) Correct! The answer is A.</font>\n"; 
		theForm.score_28.value = "1" }
	if(setChkIndx(theForm.radCR29) != "D") {
		Result += "<br><br><font color='red'>29) Incorrect: Your answer was " + setChkIndx(theForm.radCR29) + " and the correct answer is D.</font>\n"; 
		theForm.score_29.value = "0" }
	else {
		Result += "<br><br><font color='green'>29) Correct! The answer is D.</font>\n"; 
		theForm.score_29.value = "1" }
	if(setChkIndx(theForm.radCR30) != "B") {
		Result += "<br><br><font color='red'>30) Incorrect: Your answer was " + setChkIndx(theForm.radCR30) + " and the correct answer is B.</font>\n"; 
		theForm.score_30.value = "0" }
	else {
		Result += "<br><br><font color='green'>30) Correct! The answer is B.</font>\n"; 
		theForm.score_30.value = "1" }
	if(setChkIndx(theForm.radCR31) != "C") {
		Result += "<br><br><font color='red'>31) Incorrect: Your answer was " + setChkIndx(theForm.radCR31) + " and the correct answer is C.</font>\n"; 
		theForm.score_31.value = "0" }
	else {
		Result += "<br><br><font color='green'>31) Correct! The answer is C.</font>\n"; 
		theForm.score_31.value = "1" }
	if(setChkIndx(theForm.radCR32) != "C") {
		Result += "<br><br><font color='red'>32) Incorrect: Your answer was " + setChkIndx(theForm.radCR32) + " and the correct answer is C.</font>\n"; 
		theForm.score_32.value = "0" }
	else {
		Result += "<br><br><font color='green'>32) Correct! The answer is C.</font>\n"; 
		theForm.score_32.value = "1" }
	if(setChkIndx(theForm.radCR33) != "A") {
		Result += "<br><br><font color='red'>33) Incorrect: Your answer was " + setChkIndx(theForm.radCR33) + " and the correct answer is A.</font>\n"; 
		theForm.score_33.value = "0" }
	else {
		Result += "<br><br><font color='green'>33) Correct! The answer is A.</font>\n"; 
		theForm.score_33.value = "1" }
	if(setChkIndx(theForm.radCR34) != "D") {
		Result += "<br><br><font color='red'>34) Incorrect: Your answer was " + setChkIndx(theForm.radCR34) + " and the correct answer is D.</font>\n"; 
		theForm.score_34.value = "0" }
	else {
		Result += "<br><br><font color='green'>34) Correct! The answer is D.</font>\n"; 
		theForm.score_34.value = "1" }
	if(setChkIndx(theForm.radCR35) != "B") {
		Result += "<br><br><font color='red'>35) Incorrect: Your answer was " + setChkIndx(theForm.radCR35) + " and the correct answer is B.</font>\n"; 
		theForm.score_35.value = "0" }
	else {
		Result += "<br><br><font color='green'>35) Correct! The answer is B.</font>\n"; 
		theForm.score_35.value = "1" }
	if(setChkIndx(theForm.radCR36) != "C") {
		Result += "<br><br><font color='red'>36) Incorrect: Your answer was " + setChkIndx(theForm.radCR36) + " and the correct answer is C.</font>\n"; 
		theForm.score_36.value = "0" }
	else {
		Result += "<br><br><font color='green'>36) Correct! The answer is C.</font>\n"; 
		theForm.score_36.value = "1" }
	if(setChkIndx(theForm.radCR37) != "C") {
		Result += "<br><br><font color='red'>37) Incorrect: Your answer was " + setChkIndx(theForm.radCR37) + " and the correct answer is C.</font>\n"; 
		theForm.score_37.value = "0" }
	else {
		Result += "<br><br><font color='green'>37) Correct! The answer is C.</font>\n"; 
		theForm.score_37.value = "1" }
	if(setChkIndx(theForm.radCR38) != "D") {
		Result += "<br><br><font color='red'>38) Incorrect: Your answer was " + setChkIndx(theForm.radCR38) + " and the correct answer is D.</font>\n"; 
		theForm.score_38.value = "0" }
	else {
		Result += "<br><br><font color='green'>38) Correct! The answer is D.</font>\n"; 
		theForm.score_38.value = "1" }
	if(setChkIndx(theForm.radCR39) != "C") {
		Result += "<br><br><font color='red'>39) Incorrect: Your answer was " + setChkIndx(theForm.radCR39) + " and the correct answer is C.</font>\n"; 
		theForm.score_39.value = "0" }
	else {
		Result += "<br><br><font color='green'>39) Correct! The answer is C.</font>\n"; 
		theForm.score_39.value = "1" }
	if(setChkIndx(theForm.radCR40) != "D") {
		Result += "<br><br><font color='red'>40) Incorrect: Your answer was " + setChkIndx(theForm.radCR40) + " and the correct answer is D.</font>\n"; 
		theForm.score_40.value = "0" }
	else {
		Result += "<br><br><font color='green'>40) Correct! The answer is D.</font>\n"; 
		theForm.score_40.value = "1" }
	if(setChkIndx(theForm.radCR41) != "C") {
		Result += "<br><br><font color='red'>41) Incorrect: Your answer was " + setChkIndx(theForm.radCR41) + " and the correct answer is C.</font>\n"; 
		theForm.score_41.value = "0" }
	else {
		Result += "<br><br><font color='green'>41) Correct! The answer is C.</font>\n"; 
		theForm.score_41.value = "1" }
	if(setChkIndx(theForm.radCR42) != "A") {
		Result += "<br><br><font color='red'>42) Incorrect: Your answer was " + setChkIndx(theForm.radCR42) + " and the correct answer is A.</font>\n"; 
		theForm.score_42.value = "0" }
	else {
		Result += "<br><br><font color='green'>42) Correct! The answer is A.</font>\n"; 
		theForm.score_42.value = "1" }
	if(setChkIndx(theForm.radCR43) != "D") {
		Result += "<br><br><font color='red'>43) Incorrect: Your answer was " + setChkIndx(theForm.radCR43) + " and the correct answer is D.</font>\n"; 
		theForm.score_43.value = "0" }
	else {
		Result += "<br><br><font color='green'>43) Correct! The answer is D.</font>\n"; 
		theForm.score_43.value = "1" }
	if(setChkIndx(theForm.radCR44) != "B") {
		Result += "<br><br><font color='red'>44) Incorrect: Your answer was " + setChkIndx(theForm.radCR44) + " and the correct answer is B.</font>\n"; 
		theForm.score_44.value = "0" }
	else {
		Result += "<br><br><font color='green'>44) Correct! The answer is B.</font>\n"; 
		theForm.score_44.value = "1" }
	if(setChkIndx(theForm.radCR45) != "C") {
		Result += "<br><br><font color='red'>45) Incorrect: Your answer was " + setChkIndx(theForm.radCR45) + " and the correct answer is C.</font>\n"; 
		theForm.score_45.value = "0" }
	else {
		Result += "<br><br><font color='green'>45) Correct! The answer is C.</font>\n"; 
		theForm.score_45.value = "1" }
	if(setChkIndx(theForm.radCR46) != "A") {
		Result += "<br><br><font color='red'>46) Incorrect: Your answer was " + setChkIndx(theForm.radCR46) + " and the correct answer is A.</font>\n"; 
		theForm.score_46.value = "0" }
	else {
		Result += "<br><br><font color='green'>46) Correct! The answer is A.</font>\n"; 
		theForm.score_46.value = "1" }
	if(setChkIndx(theForm.radCR47) != "B") {
		Result += "<br><br><font color='red'>47) Incorrect: Your answer was " + setChkIndx(theForm.radCR47) + " and the correct answer is B.</font>\n"; 
		theForm.score_47.value = "0" }
	else {
		Result += "<br><br><font color='green'>47) Correct! The answer is B.</font>\n"; 
		theForm.score_47.value = "1" }
	if(setChkIndx(theForm.radCR48) != "D") {
		Result += "<br><br><font color='red'>48) Incorrect: Your answer was " + setChkIndx(theForm.radCR48) + " and the correct answer is D.</font>\n"; 
		theForm.score_48.value = "0" }
	else {
		Result += "<br><br><font color='green'>48) Correct! The answer is D.</font>\n"; 
		theForm.score_48.value = "1" }
	if(setChkIndx(theForm.radCR49) != "D") {
		Result += "<br><br><font color='red'>49) Incorrect: Your answer was " + setChkIndx(theForm.radCR49) + " and the correct answer is D.</font>\n"; 
		theForm.score_49.value = "0" }
	else {
		Result += "<br><br><font color='green'>49) Correct! The answer is D.</font>\n"; 
		theForm.score_49.value = "1" }
	if(setChkIndx(theForm.radCR50) != "D") {
		Result += "<br><br><font color='red'>50) Incorrect: Your answer was " + setChkIndx(theForm.radCR50) + " and the correct answer is D.</font>\n"; 
		theForm.score_50.value = "0" }
	else {
		Result += "<br><br><font color='green'>50) Correct! The answer is D.</font>\n"; 
		theForm.score_50.value = "1" }
	//alert(Result)
	countElements();
		document.CR_SampleTest.txtResult.value = Result
		document.CR_SampleTest.txtScore.value = theScore
	document.CR_SampleTest.submit()
}

function activate()
{
    document.CR_SampleTest.txtName.focus();
}

function setChkIndx(theName) { 
for (var i=0; i < theName.length; i++ ) { 
if (theName[i].checked == true) return theName[i].value; 
} 
return "*"; // One item is always supposed to be checked but... 
}


//----------------- ErrorBuilder(...) -----------------//
//   Displays a passes error message and brings the    //
//   user to that section for correction.              //
//-----------------------------------------------------//
function ErrorBuilder(ErrorMessage)
{
  ERROR = true;

  	FinalError = FinalError + ErrorMessage + "\n";
}

//------------------ ErrorHandler() -------------------//
//   Jump to the appropiate beginning anchor that was  //
//   set and display errors found. Uses the global     //
//   variables setup by ErrorBuilder(...)              //
//-----------------------------------------------------//
function ErrorHandler()
{
  FinalError = "The following errors were detected:\n\n" + FinalError;  
  alert(FinalError);
  FinalError = "";
  ERROR = false;
}

function countElements(){
    var formObj = document.CR_SampleTest;    // Reference to your form
    var startNo=1; // Start index
    var countOne=0;
    while(formObj.elements['score_'+startNo]){ // Loop through elements
        if(formObj.elements['score_'+startNo].value=='1')countOne++;
        startNo++;
    }
    var percentage = countOne/(startNo-1);
    percentage = percentage * 10000;
    percentage = Math.round(percentage);
    percentage = percentage/100;
    theScore = 'Test #1 score is : '+countOne+' out of '+(startNo-1)+' questions correct.\n'+percentage+'% Correct<br><br>'
}


