
// Tally Coaching Quiz

function calculate(){ 
	var total= 0;
	var subtotal1=0;
	var subtotal2=0;
	var subtotal3=0;
	var subtotal4=0;
	var subtotal5=0;
	var subtotal6=0;
	var subtotal7=0;
	var subtotal8=0;
	var subtotal9=0;
	var subtotal10=0;
	var errorMsg='';
	
	// Subtotal for Question 1
	for(var i = 0; i < document.quiz.q1.length; i++){	
		if (document.quiz.q1[i].checked) {
		subtotal1 = eval(document.quiz.q1[i].value);
			}
		}
		
	// Subtotal for Question 2
	for(var i = 0; i < document.quiz.q2.length; i++){	
		if (document.quiz.q2[i].checked) {
		subtotal2 = eval(document.quiz.q2[i].value);
			}
		}	
			
	// Subtotal for Question 3
	for(var i = 0; i < document.quiz.q3.length; i++){	
		if (document.quiz.q3[i].checked) {
		subtotal3 = eval(document.quiz.q3[i].value);
			}
		}	
		
	// Subtotal for Question 4
	for(var i = 0; i < document.quiz.q4.length; i++){	
		if (document.quiz.q4[i].checked) {
		subtotal4 = eval(document.quiz.q4[i].value);
			}
		}				
		
	// Subtotal for Question 5
	for(var i = 0; i < document.quiz.q5.length; i++){	
		if (document.quiz.q5[i].checked) {
		subtotal5 = eval(document.quiz.q5[i].value);
			}
		}		
	
	// Subtotal for Question 6
	for(var i = 0; i < document.quiz.q6.length; i++){	
		if (document.quiz.q6[i].checked) {
		subtotal6 = eval(document.quiz.q6[i].value);
			}
		}		
		
	// Subtotal for Question 7
	for(var i = 0; i < document.quiz.q7.length; i++){	
		if (document.quiz.q7[i].checked) {
		subtotal7 = eval(document.quiz.q7[i].value);
			}
		}			
		
	// Subtotal for Question 8
	for(var i = 0; i < document.quiz.q8.length; i++){	
		if (document.quiz.q8[i].checked) {
		subtotal8 = eval(document.quiz.q8[i].value);
			}
		}			
		
	// Subtotal for Question 9
	for(var i = 0; i < document.quiz.q9.length; i++){	
		if (document.quiz.q9[i].checked) {
		subtotal9 = eval(document.quiz.q9[i].value);
			}
		}			
		
	// Subtotal for Question 10
	for(var i = 0; i < document.quiz.q10.length; i++){	
		if (document.quiz.q10[i].checked) {
		subtotal10 = eval(document.quiz.q10[i].value);
			}
		}	
		
	// Ensure all questions are answered
	if (subtotal1 < 1 || subtotal2 < 1 || subtotal3 < 1 || subtotal4 < 1 || subtotal5 < 1 || subtotal6 < 1 || subtotal7 < 1 || subtotal8 < 1 || subtotal9 < 1 || subtotal10 < 1) {
	window.alert("Please make sure you've answered all questions.");
	return false;
	}
		
	// Display Total			
	total = eval(subtotal1) + eval(subtotal2) + eval(subtotal3) + eval(subtotal4) + eval(subtotal5) + eval(subtotal6) + eval(subtotal7) + eval(subtotal8) + eval(subtotal9) + eval(subtotal10);		
	document.quiz.score.value = total;
	
	// Display Explanation Text	
	if (total < 21){
	document.quiz.results.value = " Not coachable, but only right now.";
	}
	
	if (total > 20 && total < 31){
	document.quiz.results.value = " Coachable, but make sure ground rules are honored!";
	}
	
	if (total > 30 && total < 41){
	document.quiz.results.value = " Coachable";
	}

	if (total > 40 && total < 51){
	document.quiz.results.value = " Very coachable; ask the coach to ask a lot from you!";
	}	
		
}