

function validateAndSubmit( theForm )
{
	theForm.select.value = "select distinct ";
	if( theForm.cnetwork.checked )
		theForm.select.value = theForm.select.value + "network,";
	if( theForm.cstation.checked )
		theForm.select.value = theForm.select.value + "station,";
	if( theForm.cchannel.checked )
		theForm.select.value = theForm.select.value + "channel,";
	if( theForm.cstartyr.checked )
		theForm.select.value = theForm.select.value + "startyr,";
		// theForm.select.value = theForm.select.value + "to_date(starttime,'MM/DD/YYYY HH24:MI:SS) \"START\",";
	if( theForm.cendyr.checked )
		theForm.select.value = theForm.select.value + "endyr,";
		// theForm.select.value = theForm.select.value + "to_date(endtime,'MM/DD/YYYY HH24:MI:SS') \"END\",";
	if( theForm.cprobstart.checked )
		theForm.select.value = theForm.select.value + "problem_start,";
	if( theForm.cprobend.checked )
		theForm.select.value = theForm.select.value + "problem_end,";
	if( theForm.creported.checked )
		theForm.select.value = theForm.select.value + "reported,";
	if( theForm.cresolved.checked )
		theForm.select.value = theForm.select.value + "resolved,";
	if( theForm.cproblem.checked )
		theForm.select.value = theForm.select.value + "problem,";
	if( theForm.cresolution.checked )
		theForm.select.value = theForm.select.value + "resolution,";
	if( theForm.cstatus.checked )
		theForm.select.value = theForm.select.value + "status,";
	if( theForm.creporter.checked )
		theForm.select.value = theForm.select.value + "reporter,";

	if( theForm.select.value == "select distinct " )
	{
		alert("You have not checked any select fields.");
		return false;
	}

	var strlen = theForm.select.value.length - 1;
	theForm.select.value = theForm.select.value.substring(0,strlen);

	// Check for starttime parameters
	if( (theForm.year1.value == "") || (theForm.year1.value == "YYYY") )
		theForm.starttime.value = "none";
	else
	{
		if( checkyear( theForm.year1 ) == false )          return false;
		else if( checkstartmonth( theForm.month1 ) == false )   return false;
		else if( checkstartday( theForm.day1 ) == false )       return false;
		theForm.starttime.value = 
			theForm.month1.value + "/" + theForm.day1.value + "/" + theForm.year1.value;
	}

	// Check for endtime parameters
	if( (theForm.year2.value == "") || (theForm.year2.value == "YYYY") )
		theForm.endtime.value = "none";
	else
	{
		if( checkyear( theForm.year2 ) == false )          return false;
		else if( checkendmonth( theForm.month2 ) == false )   return false;
		else if( checkendday( theForm.day2 ) == false )       return false;
		theForm.endtime.value = 
			theForm.month2.value + "/" + theForm.day2.value + "/" + theForm.year2.value;
	}
	

	var conjunct = "";

	theForm.parms.value = "";
	var str = theForm.network.value;
	theForm.network.value = str.toUpperCase();
	str = theForm.station.value;
	theForm.station.value = str.toUpperCase();
	str = theForm.channel.value;
	theForm.channel.value = str.toUpperCase();

	
	
	if( ( theForm.parms.value == "" ) 
	 && ( theForm.network.value == "" ) 
	 && ( theForm.station.value == "" ) 
	 && ( theForm.channel.value == "" ) 
	)
	{
		alert("You have not supplied enough search criteria. You must set at least one parameter in the network, station OR channel box" );
		return false;
	}
	
	theForm.submit();
	return true;
}

