function gradeanswers()
{
var correctans=0
if (document.checker.variable.value!="1") {
document.checker.variable.value=1;
var tempans1=document.quiz.question1.value;
var tempans2=document.quiz.question2.value;
var tempans3=document.quiz.question3.value;
if(index1>1)
	{
	var exponent1=document.quiz.exponent1.value;
	}
var exponent2=document.quiz.exponent2.value;
var exponent3=document.quiz.exponent3.value;
if(tempans1=="")
	{
	var tempans1="-----";
	}
if(tempans2=="")
	{
	var tempans2="-----";
	}
if(tempans3=="")
	{
	var tempans3="-----";
	}
if(index1>1)
	{
	if(exponent1=="")
	{
	var exponent1="-----";
	}
	}
if(exponent2=="")
	{
	var exponent2="-----";
	}
if(exponent3=="")
	{
	var exponent3="-----";
	}
var msg=open("","DisplayWindow");
msg.document.write("<head>");
msg.document.write("<STYLE TYPE='text/css'>" 
+"<!--"+
"BODY    {font-family: Arial, sans-serif}"+
"P       {font-family: Arial, sans-serif}"+
"TD      {font-family: Arial, sans-serif}"+
"UL      {font-family: Arial, sans-serif}"+
"OL      {font-family: Arial, sans-serif}"+
"DL      {font-family: Arial, sans-serif}"+
"H1      {font-family: Arial, sans-serif}"+
"H2      {font-family: Arial, sans-serif}"+
"H3      {font-family: Arial, sans-serif}"+
"H4      {font-family: Arial, sans-serif}"+
"H5      {font-family: Arial, sans-serif}"+
"H6      {font-family: Arial, sans-serif}"+
"-->"+
"</STYLE>"+
"</head>");

msg.document.write("<BODY  bgcolor='#FFFFFF'><HR noshade><b>Your results:</b>");
msg.document.writeln("<hr><br><p>Problem 1.</p>");

if(index1<2)
	{
	if(tempans1==truevalue1[index1] || tempans1==closevalue1[index1])
		{
		var outcome="correct";
		correctans++;
		}
	else{
		var outcome="incorrect";
		}
msg.document.write('<p>Your answer of <B>' + tempans1 + '</B> is <B>' + outcome + '</B>.</p>');
if(outcome=="incorrect")
	{
	msg.document.writeln('<p>The correct answer is <b>' + truevalue1[index1] + '</b>.</p>');
	}
	}
else{
	if(tempans1==truevalue1[index1] && exponent1==exp1[index1])
		{
		var outcome="correct";
		correctans++;
		}
	else{
		var outcome="incorrect";
		}
msg.document.write('<p>Your answer of <B>' + tempans1 + ' x 10<SUP>' + exponent1 + '</SUP></B> is <B>' + outcome + '</B>.</p>');
if(outcome=="incorrect")
	{
	msg.document.writeln('<p>The correct answer is <b>' + truevalue1[index1] + ' x 10<SUP>' +  exp1[index1] + '</SUP></b>.</p>');
	}
	}
	
msg.document.writeln("<hr><br><p>Problem 2.</p>");
if(tempans2==truevalue2[index2] && exponent2==exp2[index2])
	{
	var outcome="correct";
	correctans++;
	}
else{
	var outcome="incorrect";
	}
msg.document.write('<p>Your answer of <B>' + tempans2 + ' x 10<SUP>' + exponent2 + '</SUP></B> is <B>' + outcome + '</B>.</p>');
if(outcome=="incorrect")
	{
	msg.document.writeln('<p>The correct answer is <b>' + truevalue2[index2] + 'x 10<SUP>' + exp2[index2] + '</SUP></b>.</p>');
	}

msg.document.writeln("<hr><br><p>Problem 3.</p>");
if(tempans3==truevalue3[index3] && exponent3==exp3[index3])
	{
	var outcome="correct";
	correctans++;
	}
else{
	var outcome="incorrect";
	}
msg.document.write('<p>Your answer of <B>' + tempans3 + ' x 10<SUP>' + exponent3 + '</SUP></B> is <B>' + outcome + '</B>.</p>');
if(outcome=="incorrect")
	{
	msg.document.writeln('<p>The correct answer is <b>' + truevalue3[index3] + 'x 10<SUP>' + exp3[index3] + '</SUP></b>.</p>');
	}

msg.document.writeln("<hr><br><p>Your Total score is: <font color='#FF0000'><b>" + correctans + "</b></font> out of 3.</p>");
msg.document.close();

} else {
	alert("Sorry, you cannot resubmit your answers. Click \"Start\" at the top of the page to start over.");
}
}
