
<!--
//************************************************************************
//  Form Validation Routines
//************************************************************************


function isEmpty( inp ) {
//	alert( inp.type );
	if (inp.type == "text") {
		if (inp.value == "" || inp.value == null) return true;
		else return false;
	}
	if (inp.type == "select-one") {
		if (inp.selectedIndex < 1) return true;
		else return false;
	}
	return false;
}

function errMsg( msg, inp ) {
	alert( msg );
	inp.focus();
}

//function valForm1(form) { alert(form.name); return false;}
function valForm(form) {
	var theString = "";

		if ( isEmpty(form.contact) ) {
			errMsg("Error : Please enter name.", form.contact);
			return false;
		}


		if ( isEmpty(form.phone) ) {
			errMsg("Error : Please enter a phone number.", form.phone);
			return false;
		}		

		if ( isEmpty(form.email) ) {
			errMsg("Error : Please enter the email.", form.email);
			return false;
		}
		else {
			if ( ! isValidEMail(form.email.value) ) {
				errMsg("Error : Invalid email address (the format is someone@somewhere.com).", form.email);
				return false;
			}
		}


	return true;

}

//*** Is this a valid numeric string?
function isNumericString ( text ) {

	for ( var i=0; i < text.length; i++ ) {
		if ( text.charAt(i) < "0" || text.charAt(i) > "9" ) {
			return false;
		}
	}

	return true;

}


//*** Is this a valid Zip code?
function isValidZip ( inpv ) {

	var zcode = "";
	var zfour = "";

   if (inpv.length != 5 && inpv.length != 10) { return false; }

   if (inpv.length == 10) {
		zcode = inpv.substr(0, 5);
		zfour = inpv.substr(6, 4);
	   if (! isNumericString (zfour) ) { return false; }
   }
   else {
		zcode = ""+inpv;
   }

   if (! isNumericString (zcode) ) { return false; }

   return true;

} // end of is valid zip

//*** Is this a valid Email address?
function isValidEMail ( inpv ) {

var Temp     = inpv;
var AtSym    = Temp.indexOf('@')
var Period   = Temp.lastIndexOf('.')
var Space    = Temp.indexOf(' ')
var Length   = Temp.length - 1   // Array is from 0 to length-1

	if ((AtSym < 1) ||                     // '@' cannot be in first position
		(Period <= AtSym + 1) ||           // Must be at least one valid char btwn '@' and '.'
		(Period == Length ) ||             // Must be at least one valid char after '.'
		(Space  != - 1))                   // No empty spaces permitted
   {  
//      EmailOk = false
//		alert('Please enter a valid e-mail address.\n\n It is important that you provide us with a valid email addres so that we can respond to submission.')
//		Temp.focus()
		return false;
   }
	return true;

}


//-->


