<!--
// Form validation functions
		
// Returns true if string varStr iswhitespace characters only.
function isWhitespace(varStr){
	var whitespace = " \t\n\r\f\v\b";
	for (var i = 0; i < varStr.length; i++){
		var c = "" + varStr.charAt(i);
		if (whitespace.indexOf(c) == -1){
			return false;
		}
	}
	return true;
}

// Returns true if string varStr has any non-numeric characters
function notaNumber(varStr){
	var numericChars = " 0123456789";
	var theResult = false;
	for (var i = 0; i < varStr.length; i++){
		var c = varStr.charAt(i);
		if (numericChars.indexOf(c) == -1){
			theResult = true;
		}
	}
	return theResult;
}
		
// Removes the string strRemove from strField
function grabName(strField,strRemove){
	var theResult=strField.replace(strRemove,"");
	return theResult;
}

// Returns true if a radio button or checkbox has been checked
function isChecked(theButton){
	var theResult=false;
	for (var j=0; j<theButton.length ; j++){
		if (theButton[j].checked){
		 theResult = true;
		}
	}
	return theResult;
}

// Returns the index of the first occurrence of search string in list
// If search string is not found, -1 is returned
function findIt(strList,strSearch){
	var i=strList.indexOf(strSearch);
	return i;
}

//Comments validation function
function validateComments(theForm) {
	var theResult=true;
	var strEmptyFields="";
	var strReqFields="txtName,txtEmail,txtTitle,txtComments";
	for (var i=0; i<theForm.length; i++){
		var e=theForm.elements[i];
		if ((e.type=="text"||e.type=="textarea")&&findIt(strReqFields,e.name)!=-1){
			if (isWhitespace(e.value)){
				var strField=grabName(e.name,"txt");
				strEmptyFields=strEmptyFields + "\n" + strField;
			}
		}
	}
	if (strEmptyFields.length>0){
		strEmptyFields="The following fields must be filled in:" + strEmptyFields;
		alert(strEmptyFields);
		theResult=false;
	}
	return theResult;
}

//Contact Us validation function
function validateContact(theForm) {
	var theResult=true;

	var strEmptyFields="";
	var strReqFields="txtEmail,txtFeedback";
	for (var i=0; i<theForm.length; i++){
		var e=theForm.elements[i];
		if ((e.type=="text"||e.type=="textarea")&&findIt(strReqFields,e.name)!=-1){
			if (isWhitespace(e.value)){
				var strField=grabName(e.name,"txt");
				strEmptyFields=strEmptyFields + "\n" + strField;
			}
		}
	}
	if (strEmptyFields.length>0){
		strEmptyFields="The following fields must be filled in:" + strEmptyFields;
		alert(strEmptyFields);
		theResult=false;
	}
	return theResult;
}


//search validation function
function validateSearch(theForm) {
	var theResult=true;

	var strEmptyFields="";
	var strReqFields="Criteria";
	for (var i=0; i<theForm.length; i++){
		var e=theForm.elements[i];
		if ((e.type=="text")&&findIt(strReqFields,e.name)!=-1){
			if (isWhitespace(e.value)){
				var strField=grabName(e.name,"txt");
				strEmptyFields=strEmptyFields + "\n" + strField;
			}
		}
	}
	if (strEmptyFields.length>0){
		strEmptyFields="Please Enter Search Criteria";
		alert(strEmptyFields);
		theResult=false;
	}
	return theResult;
}

//-->
