
function checkForm()
{
	var survey = document.surveyForm;

	var user_input = "";
	errorMsg="";
	
/************************************************************************
*	QUESTION 1
*************************************************************************/	
	radioItem = survey.Q1;
	for (i=0;i<radioItem.length;i++)
	{
		if (radioItem[i].checked)
		{
			user_input = radioItem[i].value;
		}
	}
	if (user_input=="")
	{
		addError("Question 1");
	} 
	else if(user_input=="Yes" && survey.Q1Yes.value.trim()=="")
	{
		addError("Question 1: Yes");
	}
	else if(user_input=="No" && survey.Q1No.value.trim()=="")
	{
		addError("Question 1: No");
	}
	
/************************************************************************
*	QUESTION 2
*************************************************************************/		
	user_input="";
	radioItem = survey.Q2;
	for (i=0;i<radioItem.length;i++)
	{
		if (radioItem[i].checked)
		{
			user_input = radioItem[i].value;
		}
	}
	if (user_input=="")
	{
		addError("Question 2");
	} 
	else if(user_input=="No" && survey.Q2Reason.value.trim()=="")
	{
		addError("Question 2: No");
	}
	
/************************************************************************
*	QUESTION 3
*************************************************************************/		
	user_input="";
	radioItem = survey.Q3;
	for (i=0;i<radioItem.length;i++)
	{
		if (radioItem[i].checked)
		{
			user_input = radioItem[i].value;
		}
	}
	if (user_input=="")
	{
		addError("Question 3");
	} 
	else if(user_input=="Yes" && survey.Q3Reason.value.trim()=="")
	{
		addError("Question 3: Yes");
	}

/************************************************************************
*	QUESTION 4
*************************************************************************/		
	user_input="";
	if (survey.Q4A.checked)
	{
		user_input = "checked";
	}
	else if (survey.Q4B.checked)
	{
		user_input = "checked";
	}
	else if (survey.Q4C.checked)
	{
		user_input = "checked";
	}
	else if (survey.Q4D.checked)
	{
		user_input = "checked";
	}
	else if (survey.Q4E.checked)
	{
		user_input = "checked";
	}
	else if (survey.Q4F.checked)
	{
		user_input = "checked";
	}

	if (user_input=="")
	{
		addError("Question 4");
	} 

/************************************************************************
*	QUESTION 5
*************************************************************************/		
	user_input="";
	if (survey.Q5A.checked)
	{
		user_input = "checked";
	}
	else if (survey.Q5B.checked)
	{
		user_input = "checked";
	}
	else if (survey.Q5C.checked)
	{
		user_input = "checked";
	}
	else if (survey.Q5D.checked)
	{
		user_input = "checked";
	}
	else if (survey.Q5E.checked)
	{
		user_input = "checked";
	}
	else if (survey.Q5F.checked)
	{
		user_input = "checked";
	}

	if (user_input=="")
	{
		addError("Question 5");
	} 
	
/************************************************************************
*	QUESTION 6
*************************************************************************/
	user_input = survey.Q6.value.trim();
	if (user_input=="")
	{
		addError("Question 6");
	} 		

/************************************************************************
*	QUESTION 7
*************************************************************************/		
	user_input="";
	radioItem = survey.Q7;
	for (i=0;i<radioItem.length;i++)
	{
		if (radioItem[i].checked)
		{
			user_input = radioItem[i].value;
		}
	}
	if (user_input=="")
	{
		addError("Question 7");
	} 
	else if(user_input=="Yes" && survey.Q7Reason.value.trim()=="")
	{
		addError("Question 7: Yes. Please tell us how.");
	}
	
/************************************************************************
*	QUESTION 8
*************************************************************************/		
	user_input="";
	radioItem = survey.Q8;
	for (i=0;i<radioItem.length;i++)
	{
		if (radioItem[i].checked)
		{
			user_input = radioItem[i].value;
		}
	}
	if (user_input=="")
	{
		addError("Question 8");
	} 
	else if(user_input=="No" && survey.Q8Reason.value.trim()=="")
	{
		addError("Question 8: No. Please tell us why not.");
	}	
	
/************************************************************************
*	QUESTION 9
*************************************************************************/
	user_input = survey.Q9.value.trim();
	if (user_input=="")
	{
		addError("Question 9");
	} 	
	
/************************************************************************
*	QUESTION 10
*************************************************************************/
	user_input = survey.Q10.value.trim();
	if (user_input=="")
	{
		addError("Question 10");
	} 	
	
/************************************************************************
*	QUESTION 11
*************************************************************************/
	user_input = survey.Q11StudentName.value.trim();
	if (user_input=="")
	{
		addError("Question 11: Please tell us your name");
	} 	
	user_input = survey.Q11TeacherName.value.trim();
	if (user_input=="")
	{
		addError("Question 11: Please tell us your teacher's name");
	} 	
	
	user_input = survey.Q11SchoolName.value.trim();
	if (user_input=="")
	{
		addError("Question 11: Please tell us your name of the school");
	} 	
	
	user_input = survey.Q11City.value.trim();
	if (user_input=="")
	{
		addError("Question 11: City");
	} 	
	
	user_input = survey.Q11State.value.trim();
	if (user_input=="")
	{
		addError("Question 11: State");
	} 	
		
		
	if(errorMsg!="")
	{
		writeError(errorMsg,"ErrorMsg");
		document.location="#error";
	}
	else
	{
		survey.action="processStudent.asp";
		survey.submit();
	}	
	
}


function checkRadioOther(radioBut, butValue)
{
	for (i=0;i<radioBut.length;i++)
	{
		if (radioBut[i].value==butValue)
		{
			radioBut[i].checked = true;
		}
	}
}
function checkBoxOther(checkBox,tField)
{
	if(tField.value.trim()!="")
	{
		checkBox.checked = true;
	}
}
