function submitForm(questionType) {
var counter = 0;
//alert(questionType);
switch (questionType)
{
case 1: //radio
for (i=0;i<document.submitQuestion.elements.length;i++) {
	if ((document.submitQuestion.elements[i].type == "radio") && (document.submitQuestion.elements[i].checked == true)) {
		var counter = counter + 1;
		}
	 }
 if (counter < 1) {
	alert("Please select an answer before continuing");
	//return false; 
	} else {
	document.submitQuestion.submit();
	}
break;

case 3: //True / False
for (i=0;i<document.submitQuestion.elements.length;i++) {
	if ((document.submitQuestion.elements[i].type == "radio") && (document.submitQuestion.elements[i].checked == true)) {
		var counter = counter + 1;
		}
	 }
 if (counter < 1) {
	alert("Please select an answer before continuing");
	//return false; 
	} else {
	document.submitQuestion.submit();
	}
break;

case "skip": //skip the question
	//document.submitQuestion.skip.value = "yes";
	document.submitQuestion.submit();
break;

case "next": //move forward
	
	document.submitQuestion.submit();
break;

case "back": //back button
	document.submitQuestion.go_back.value = "yes";
	document.submitQuestion.submit();
break;

default: //checkbox and survey
for (i=0;i<document.submitQuestion.elements.length;i++) {
	if ((document.submitQuestion.elements[i].type == "checkbox") && (document.submitQuestion.elements[i].checked == true)) {
		var counter = counter + 1;
		}
	 }
 if (counter < 1) {
	alert("Please select an answer before continuing ");
	//return false; 
	} else {
	document.submitQuestion.submit();
	}
break;
 }
 
}

function submitFormCustom (answers) {
	document.submitQuestion.go_back.value = "yes_loop";
	document.submitQuestion.custom_question.value = answers;
	//alert(document.submitQuestion.custom_question.value);
	//alert(document.submitQuestion.go_back.value);
	document.submitQuestion.submit();
}

function makeSurvey () {
	if (window.location.href.search("survey") > -1) {
		var urlStr = window.location.href.search("survey") - 1;
		window.location.href = window.location.href.substring(0,urlStr);
	} else {
		window.location.href = window.location.href+"&survey=1";
	}
}

function makeMMC () {
if (window.location.href.search("mmc") > -1) {
		var urlStr = window.location.href.search("mmc") - 1;
		window.location.href = window.location.href.substring(0,urlStr);
	} else {
		window.location.href = window.location.href+"&mmc=1";
	}
}

function clearMe (screen) {//simple clear of radio and checkbox buttons
for (i=0;i<document.submitQuestion.elements.length;i++) {
	if ((document.submitQuestion.elements[i].type == "radio") || (document.submitQuestion.elements[i].type == "checkbox")) 
		{
		if (screen != 47) {
			document.submitQuestion.elements[i].checked = false;
		} else {
			document.submitQuestion.elements[i].enabled = true;
			alert(document.submitQuestions.elements[i].onclick.value);
			}
		} 
	}
	//document.submitQuestion.custom_question.value = '';
  } 
 /*
function checkExam(totalQuestions) {  
//alert(totalQuestions);
var totalQuestions = totalQuestions+1;
var questionPrefix = 'fq';
var formName = 'document.finalExam.';
var counter = 0;
//var testArray = new Array ("for");
//testArray = testArray.push(questionPrefix.concat('4'));
//alert(testArray[0]);
var finalQuestions = new Array();
for (i=1; i<totalQuestions; i++) {
	finalQuestions[i] = questionPrefix.concat(i);
	}
//alert(finalQuestions.length);

for (i=1; i<finalQuestions.length; i++) { 
	alert("index for question loop: "+i);
	//var count = formName.concat(finalQuestions[i]);
	//alert(count);
	alert(thisVal);
	var thisVal = formName.concat(finalQuestions[i].concat('[a].checked'));
	//for (a=1; a<5; i++) {
			alert(thisVal);
			if (eval(thisVal) != true) {
			//alert(eval(thisVal));
			var counter = counter + 1;
			}
	 	}
	 }
alert("counter: "+counter);
alert(finalQuestions.length);
if (counter > 0) {
	alert("You have left a question unanswered.");
	}
}
	//
	*/
	
function valEval () {
alert(document.evaluationForm.elements.length);

var totalQuestions = 0;
var totalBlank = 0;
for (i=0;i<document.evaluationForm.elements.length;i++) {
	alert(document.evaluationForm.elements[i].type);
	//alert(document.evaluationForm.elements[i].type);
	if (document.evaluationForm.elements[i].type == "radio") {
		var totalQuestions = totalQuestions + 1;
		for (x=0; x<document.evaluationForm.elements[i].name.length; x++) {
			//alert(document.evaluationForm.elements[x].checked);
		if (document.evaluationForm.elements[x].checked == false) {
			var totalBlank = totalBlank + 1;
			}
		  }
		  if (document.evaluationForm.elements[i].name.length <= totalBlank - 1) {
		  alert(totalQuestions+" "+totalBlank);
		  	alert('You have left a question unanswered');
			break;
	    }
		//for (x=0; x<document.evaluationForm.elements[x].length; x++) {
		//	if (document.evaluationForm.elements[i][x]
	//	alert(document.evaluationForm.elements[i].length);
		//var totalQuestions = totalQuestions + 1; 
		}
	}
}
//Used to trim phone field value in reg form. This should be universalized.
function Trim(field,sData) {
//alert(field+" "+sData);
var sTrimmed = String(sData);
  sTrimmed = sTrimmed.replace(/(^\s+)|(\s+$)/g, '');
switch (field) {
	case "email":
		document.register.email.value = sTrimmed;
	break;
	case "confirm_email":
		document.register.confirm_email.value = sTrimmed;
	break;
	case "phone":
		document.register.phone.value = sTrimmed;
	break;
	case "zip":
		document.register.zip.value = sTrimmed;
	break;
	}
}

function valUserID (field) {
	if (field.search(/\W/) != -1) {
		alert("You have entered an invalid userID. No spaces or symbols are allowed.");
		document.register.userID.value="";
		document.register.userID.focus();
		}
}
