


function FrontPage_Form1_Validator(theVal)
{
	var checkboxSelected = false;
	var checkboxCount = 0;
	for (i = 0; i < document.theForm.loc.length; i++) 
	{ 
		if (document.theForm.loc[i].checked) {
			checkboxSelected = true; 
			checkboxCount ++;
		}
	} 
	  
	var check_choice = false;
	// Loop from zero to the one minus the number of check boxes selections
	for (counter = 0; counter < document.theForm.Year.length; counter++)
	{
	if (document.theForm.Year[counter].checked)
	check_choice = true; 
	}
	
	 
	// set var radio_choice to false
	var radio_choice = false;
	
	// Loop from zero to the one minus the number of radio button selections
	for (counter = 0; counter < document.theForm.trial.length; counter++)
	{
	// If a radio button has been selected it will return true
	// (If not it will return false)
	if (document.theForm.trial[counter].checked)
	radio_choice = true; 
	}
	
	if ((!radio_choice) || (!check_choice) || (!checkboxSelected))
	{
		if (!check_choice)
		{
		// If there were no selections made display an alert box 
		alert("Please select a Year.")
		}
		if (!radio_choice)
		{
		// If there were no selections made display an alert box 
		alert("Please select a Trial.")
		}
		if (!checkboxSelected) {
			 alert("Please choose a Location.");
		}	
		return (false);
	}
	
	if ((checkboxCount > 1) && (document.theForm.top10.value > 0)) {
		alert("Please choose just one Location when requesting Top Rankings.");
		return (false);
	}

	if (theVal == 'n'){
		document.theForm.action="soybeanresults.cfm";
	} else if (theVal == 'c') {
		document.theForm.action="soybeansearch2.cfm";
	} else {
		document.theForm.target="_self";
		document.theForm.action="soybeansearch.cfm";
	}
	if (theVal == 's'){
		document.theForm.submit();
	} else {
		document.theForm.target="_self"; 
		var a = window.setTimeout("document.theForm.submit();",50);
	}
	return (true);
}
