// JavaScript Document

function CheckQuestion(form) {
	var reltype = 0;
	var reltype2 = 1;
	var text = "";
	var radio = "";
	var strTier2 = false;
	var radiocount = new Array(0, 5, 3, 6, 3, 3, 2, 3, 3, 3, 9)
	var ratecount = new Array("a", "b", "c", "d", "e", "f", "g", "h")


	// Verifies the user answered questions 1 - 10
	for (var i = 1; i < 11; i++){
		for (var e = 0; e < radiocount[i]; e++){
			radio = "Q" + i
			if (document.form1[radio][e].checked){
				if (i == 2 && document.form1[radio][e].value == "No"){strTier2 = true;}
				reltype = 1;
			}
		}
		if (reltype != 1){text += "\nQuestion " + i;}
		reltype = 0;
	}
	
	// 2nd quesiton has an additional choice, this verifies that the user answered the follow-up question
	if (strTier2 == true) {
		for (var e = 0; e < 5; e++){
			if (document.form1.Q2a[e].checked){
				reltype = 1;
			}
		}
		if (reltype != 1){text += "\nSecond part on Question 2";}
		reltype = 0;
	}
	
	// Verifies all questions have been answered on question 11	
	for (var i = 1; i < 7; i++){
		for (var e = 0; e < 6; e++){
			radio = "Q11" + ratecount[i]
			if (document.form1[radio][e].checked){reltype = 1;}
		}
		if (reltype != 1){reltype2 = 0}
		reltype = 0;
	}
	if (reltype2 != 1){text += "\nPlease complete Question 11.";}
	reltype = 0
	
	// Verifies the name and phone
	if (document.form1.Name.value.length < 2)
		text += "\nName is required";
	if (document.form1.Phone.value.length < 2)
		text += "\nPhone Number is required";
	if (document.form1.Sky.value.length < 2)
		text += "\nValidation Code is required";
	
	if (document.form1.Sky.value.length > 2){
		if(document.form1.Code.value == "1" && document.form1.Sky.value == "sHKe")
			reltype = 1;
		if(document.form1.Code.value == "2" && document.form1.Sky.value == "Leudu7")
			reltype = 1;
		if(document.form1.Code.value == "3" && document.form1.Sky.value == "yMBzu")
			reltype = 1;
		if(document.form1.Code.value == "4" && document.form1.Sky.value == "85pH")
			reltype = 1;
		if(document.form1.Code.value == "5" && document.form1.Sky.value == "B257A")
			reltype = 1;
			
		if (reltype != 1){text += "\nValidation Code is incorrect";}
	}
	


	if (text != ""){
			text = "Please correct the following:\n" + text
			alert(text);	
			return false;
		}
		else{
			return true;
		}
}