// JavaScript Document for validating input fields
function validateFields(formField){
	//establish the variable field arrays for each of the pages that require validation
	var errors = 'No';
	var found = false;
	//see if the email check error is present
	if(document.getElementById('errormsg')){
		document.getElementById('errormsg').style.display = 'none';
	}
	//field names based on the page variable
	var fieldArray = new Array(
							'Convenience',
							'Appointment',
							'Promptness',
							'Thoroughness',
							'Clarity',
							'Doctor_Friendliness',
							'Staff_Friendliness',
							'Satisfaction',
							'Returning',
							'Recommend'
							);
	//loop through the various fields to make sure that they are actually there
	for(i=0; i<fieldArray.length; i++){
		if(document[formField].elements[fieldArray[i]]){
			for(y=0;y<document[formField].elements[fieldArray[i]].length;y++){
				found = false;
				if(document[formField].elements[fieldArray[i]][y].checked){
					found = true;
					break;
				}
			}
			if(found == false){
				errors = 'Yes';	
				break;
			}
		}

	}
	//decide what to do after all errors have been located
	if(errors == 'No'){
			document.getElementById(formField).submit();
	}else{
		if(document.getElementById('errormsg')){
			document.getElementById('errormsg').style.display = 'block';
		}
	}
}
//function to change the color or a field not filled out correctly
function changeFieldColor(field){
	if(document.getElementById(field)){
		document.getElementById(field).style.backgroundColor = '#FFFF99';
	}
}
	

