//Examine the control elements for all required questions.
//If a required question does not have at least one checked control element,
//return false. Else return true.
function check_required_questions(alert_string_1, alert_string_2)
{
	if(!alert_string_1)
		alert_string_1 = "Please enter a response for the question: \"";
	if(!alert_string_2)
		alert_string_2 = "\"";

	//Examine every required question in this page
	for(var i in required_questions)
	{
		if(typeof(required_questions[i]) == 'function')
			continue;
		
		this_qid = required_questions[i];
				
		//We are really only concerned with "single_selection" and "multi_selection" fields;
		//Prototype can handle the rest more efficiently.
		
		if(type_of[this_qid] == "single_selection")
		{
			//In the case of required single_selection questions, the value may not be -1.
			control_elt = document.getElementById('responses_' + this_qid);
			if(control_elt.value == -1)
			{
				alert(alert_string_1 + question_names[this_qid] + alert_string_2);
				return false;
			}
		}
		
		else if(type_of[this_qid] == "multi_selection")
		{
			found_a_selection = false;

			for(var valuekey in values_for[this_qid])
			{
				if(typeof(values_for[this_qid][valuekey]) == 'function')
					continue;
					
				control_elt = document.getElementById('responses_' + this_qid + '_' + valuekey);
				
				if(control_elt.checked && control_elt.checked != "false")
					found_a_selection = true;
			}			
			
			if(!found_a_selection)	
			{
				alert(alert_string_1 + question_names[this_qid] + alert_string_2);
				return false;
			}
		}
	}
		
	//Got here? No required question was without a valid value. Return success.
	return true;
}

function debugArray(arr)
{
	if(!Logger.info)
		return;

	for(var j in arr)
	{
		if(typeof(arr[j]) == 'function')
			continue;
	
		Logger.info(j + " => " + arr[j]);
	}
}
