// Solidworks Course Evaluation Javascript functions



/* Function to validate that a value has been selected in a radio button group */
function validateRadioButton(checkRadio) {

	for (i = checkRadio.length - 1; i > -1; i--) {
		if (checkRadio[i].checked) {
			return true;	
		}
	}
	return false;

}


/* Cycle through the Course Evaluation Questions to make sure all values have been filled in by the user */
function revitarchValidate(){
	
	baselocation = "http://cadmicro.com/courseeval/revitstruc/";
	
	
	if(document.revitstruc_evaluation.student_name.value.length == 0){
		alert("Please enter your name");
		document.revitstruc_evaluation.student_name.focus(); // set the focus to this input
		return false;
	}
	
	if(document.revitstruc_evaluation.student_email.value.length == 0){
		alert("Please enter your email address");
		document.revitstruc_evaluation.student_email.focus(); // set the focus to this input
		return false;
	}
	
	if(document.revitstruc_evaluation.student_company.value.length == 0){
		alert("Please enter your company");
		document.revitstruc_evaluation.student_company.focus(); // set the focus to this input
		return false;
	}
	
	if(document.revitstruc_evaluation.student_phone_number.value.length == 0){
		alert("Please enter your Phone Number");
		document.revitstruc_evaluation.student_phone_number.focus(); // set the focus to this input
		return false;
	}
	
	// Start Checking the Questions
	
	/* Question 1 consists of optional checkboxes*/
	
	if(!validateRadioButton(document.revitstruc_evaluation.revitusergroup)){
		alert("Please anwser question 2");
		window.location = baselocation + "#q2"; // set the focus to this input
		return false;
	}
	
	
	if(!validateRadioButton(document.revitstruc_evaluation.autodesk_products)){
		alert("Please anwser question 3");
		window.location = baselocation + "#q3"; // set the focus to this input
		return false;
	}
	
	if(!validateRadioButton(document.revitstruc_evaluation.autodesk_seats)){
		alert("Please anwser question 4");
		window.location = baselocation + "#q4"; // set the focus to this input
		return false;
	}
	
	if(document.revitstruc_evaluation.primary_cad.value.length == 0){
		alert("Please enter your primary CAD tool");
		document.revitstruc_evaluation.primary_cad.focus(); // set the focus to this input
		return false;
	}
	
	if(!validateRadioButton(document.revitstruc_evaluation.migrate3d_response)){
		alert("Please anwser question 6");
		window.location = baselocation + "#q6"; // set the focus to this input
		return false;
	}
	
	// Check for anwsers to the Revit Questions
	
	if(!validateRadioButton(document.revitstruc_evaluation.revitq1)){
		alert("Please anwser Revit question 1");
		window.location = baselocation + "#revit1"; // set the focus to this input
		return false;
	}
	
	if(!validateRadioButton(document.revitstruc_evaluation.revitq2)){
		alert("Please anwser Revit question 2");
		window.location = baselocation + "#revit2"; // set the focus to this input
		return false;
	}
	
	// Check for awnsers to the File Import / Export Questions
	
	if(!validateRadioButton(document.revitstruc_evaluation.import1)){
		alert("Please anwser Import/Export Question 1");
		window.location = baselocation + "#import1"; // set the focus to this input
		return false;
	}
	
	if(!validateRadioButton(document.revitstruc_evaluation.import2)){
		alert("Please anwser Import/Export Question 2");
		window.location = baselocation + "#import2"; // set the focus to this input
		return false;
	}
	
	if(!validateRadioButton(document.revitstruc_evaluation.import3)){
		alert("Please anwser Import/Export Question 3");
		window.location = baselocation + "#import3"; // set the focus to this input
		return false;
	}
	
	// Check for anwsers to the Team questions
	
	if(!validateRadioButton(document.revitstruc_evaluation.team1)){
		alert("Please anwser Massing Studies / Visual Presentation question 1");
		window.location = baselocation + "#team1"; // set the focus to this input
		return false;
	}
	
	if(!validateRadioButton(document.revitstruc_evaluation.team2)){
		alert("Please anwser Massing Studies / Visual Presentation question 2");
		window.location = baselocation + "#team2"; // set the focus to this input
		return false;
	}
	
	// Check the documentation questions
	
	if(!validateRadioButton(document.revitstruc_evaluation.doc1)){
		alert("Please anwser Documentation and Scheduling question 1");
		window.location = baselocation + "#documentation1"; // set the focus to this input
		return false;
	}
	
	// Submit the response
	document.revitstruc_evaluation.submit();
	
	return true;
}