﻿function CalculateScore()
{
    var nrofcontrols = document.aspnetForm.elements.length;
    var score = 0;
    var myDoc;
    var counter = 0;

    for (var i=0;i < nrofcontrols;i++)
    {	
	    if (document.aspnetForm.elements[i].checked)
		    {
			    score = score + eval(document.aspnetForm.elements[i]. value);
			    counter++;  
		    }
    }
    if (counter != 11)
    {
	    alert("You have answered only " + counter + " questions out of 11!\nFor accuracy please answer all 11 questions.");
	    return false;
    }
    var gt27 = "<html><head><title>Your score was: " + score + " points.</title><link rel='stylesheet' href='../includes/vcStyle.css' type='text/css'></head><body><p class='bodyText'>Great! Your score was <font color='red'>" + score + " </font>points.<br>Based on your responses, you're a good candidate for online learning.  You have a good combination of study skills, equipment, and personal attributes necessary to succeed in an online course.</p></body></html>";
    var lt20 = "<html><head><title>Your score was: " + score + " points.</title><link rel='stylesheet' href='../includes/vcStyle.css' type='text/css'/></head><body><p class='bodyText'>Your score was: <font color='red'>" + score + "</font> points.<br>Online learning is not a good choice for every student, and your skills and interests may fit better in a traditional campus setting.  If you decide to take an online class, consider taking a subject that you really enjoy so you'll be more motivated to do the assignments and participate in class discussions.</p></form></body></html>";
    var other = "<html><head><title>Your score was: " + score + " points.</title><link rel='stylesheet' href='../includes/vcStyle.css' type='text/css'/></head><body><p class='bodyText'>Good! Your score was <font color='red'>" + score + "</font> points.<br>Your responses indicate that you might be a good candidate for online learning.  Perhaps you need to make some adjustments to your study schedule or get comfortable with technology before you register for online classes.</p></body></html>";
    var windowSpecs = "height=300,width=400,top=150,left=250,location=no,scrollbars=yes,toolbar=no,resizable=no";
    if (score > 24)	
    {
	     var newWin = window.open('',"myDoc", windowSpecs);
	     newWin.document.write(gt27);
	     newWin.document.close();
	     newWin.focus();
    }
    else if (score < 17)  
    {
	     var newWin = window.open('',"myDoc", windowSpecs);
	     newWin.document.write(lt20);
	     newWin.document.close();
	     newWin.focus();
    }
    else	
    {
	     var newWin = window.open('',"myDoc", windowSpecs);
	     newWin.document.write(other);
	     newWin.document.close();
	     newWin.focus();
    }
}
	