function kickoff()
	{
		document.search.term.focus();
	}

function validatePaper(thisForm)
{
	var status = true;
	var searchVal = thisForm.term.value;
	var standardMsg = "Please enter at least 3 letters to search paper titles, or 3 numbers for a paper code.";
	if ( searchVal == "") {
		alert( standardMsg );
		status = false;
	} else {
		// Need to check how may '%' chars have been used, if more than one then display error
		// Rather than run through each char, we'll just compare the 1st and last match and
		// if they're the same we've only got one wildcard, so were OK
		var thisLength = searchVal.length;
		var firstIndex = searchVal.indexOf('%');
		var lastIndex = searchVal.lastIndexOf('%');
		if (firstIndex != lastIndex) {
			alert("You can only use one wildcard (%) character in your search term.");
			status = false;
		} else if (firstIndex != -1) {
			// There is a '%' in there somewhere, so subtract one off the string length as
			// we dont want to consider '%' one of the three minimum required characters
			thisLength = thisLength-1;
		}
		if (thisLength < 3) {
			alert( standardMsg );
			status = false;
		}
	}
	thisForm.term.focus();
	return status;
}


function validateSelect(formElement)
{
	var status = false;
	var spacerValue = "";
	for( j = 0; j < formElement.options.length; j++ )
		if( formElement.selectedIndex == j && formElement.options[j].value != spacerValue )
			status = true;
	
	return status;
}

function validateForm( form )
{
	var fieldsCompleted = 0;
	var mustComlete = 2;
	var rv = true;
	
	inputsToValidate = new Array();
	for( i = 0; i < form.elements.length; i++ )
		inputsToValidate[i] = form.elements[i].name;

	// for each form field
	for( i = 0; i < inputsToValidate.length; i++ )
	{
		if (form.elements[i].type == "radio" ) {
			if( (form.elements[i].checked == true) && (form.elements[i].name != 'event_type') )
				fieldsCompleted++;
			}
		else if( form.elements[i].type == "select-one" || form.elements[i].type == "select-multiple") {
			if (validateSelect( form.elements[i]))
				fieldsCompleted++;
		}
	}

	if ( fieldsCompleted < mustComlete ) {
		alert( "Please select any two of Day, Time, Semester or Subject before searching." );
		fieldsCompleted = 0;
		return false;
	}

	return rv;
}
