
//Enter total number of questions:
var totalquestions=10;



function gradeit() {

totalscore = 0;


// go through the questions
for (q=1;q<=totalquestions;q++){

	// specify question
	var thequestion=eval("document.myquiz.question"+q);
	
	// go through the values to see which radio button was checked and add to totalscore
	for (c=0;c<thequestion.length;c++){
		if (thequestion[c].checked==true) {
		totalscore += parseInt(thequestion[c].value);
		}
		
	}
		

}

getresults(totalscore);

}


// figure out where to send the visitor depending on score results
function getresults(x)  {

if (x <= 20) {
	window.location="page1.html?score="+x;
	}
	
else if ((x > 20) && (x <= 30)) {
	window.location="page2.html?score="+x;
	}
	
else if (x > 30) {
	window.location="page3.html?score="+x;
	}

}


// getQueryVariable function courtesy of Pete Freitag - pete@cfdev.com

function getQueryVariable(variable) {
  var query = window.location.search.substring(1);
  var vars = query.split("&");
  for (var i=0;i<vars.length;i++) {
    var pair = vars[i].split("=");
    if (pair[0] == variable) {
      return pair[1];
    }
  } 
  
}