	// Check whether string s is empty.
	function isEmpty(s)
	{ return ((s == null) || (s.length == 0)) }
	
	/****************************************************************/
	// whitespace characters
	var whitespace = " \t\n\r";

      function isWhitespace (s)
      {
           var i;

           // Is s empty?
           if (isEmpty(s)) return true;

           // Search through string's characters one by one
           // until we find a non-whitespace character.
           // When we do, return false; if we don't, return true.

           for (i = 0; i < s.length; i++)
           {
                // Check that current character isn't whitespace.
                var c = s.charAt(i);
                if (whitespace.indexOf(c) == -1) return false;
           }
           // All characters are whitespace.
           return true;
      }
	  
		var numb = '0123456789';
		var lwr = 'abcdefghijklmnopqrstuvwxyz';
		var upr = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ';
		
		function isValid(parm,val) {
			if (parm == "") return true;
			for (i=0; i<parm.length; i++) 
				{
				if (val.indexOf(parm.charAt(i),0) == -1) return false;
				}
			return true;
			}
		
		function isNum(parm) {return isValid(parm,numb);}
		function isLower(parm) {return isValid(parm,lwr);}
		function isUpper(parm) {return isValid(parm,upr);}
		function isAlpha(parm) {return isValid(parm,lwr+upr);}
		function isAlphanum(parm) {return isValid(parm,lwr+upr+numb);}
		
		function isValidDate(dateStr) {
		// Date validation function courtesty of 
		// Sandeep V. Tamhankar (stamhankar@hotmail.com) -->
		
		// Checks for the following valid date formats:
		// MM/DD/YY   MM/DD/YYYY   MM-DD-YY   MM-DD-YYYY
		
		var datePat = /^(\d{1,2})(\/|-)(\d{1,2})\2(\d{4})$/; // requires 4 digit year
		
		var matchArray = dateStr.match(datePat); // is the format ok?
		if (matchArray == null) 
		{
		alert(dateStr + " is not in a valid date format.")
		return false;
		}
		month = matchArray[1]; // parse date into variables
		day = matchArray[3];
		year = matchArray[4];
		if (month < 1 || month > 12) 
			{ // check month range
			alert("Month must be between 1 and 12.");
			return false;
			}
		if (day < 1 || day > 31) 
			{
			alert("Day must be between 1 and 31.");
			return false;
			}
		if ((month==4 || month==6 || month==9 || month==11) && day==31) 
			{
			alert("Month "+month+" doesn't have 31 days!")
			return false;
			}
		if (month == 2) 
			{ // check for february 29th
			var isleap = (year % 4 == 0 && (year % 100 != 0 || year % 400 == 0));
			if (day>29 || (day==29 && !isleap)) 
				{
				alert("February " + year + " doesn't have " + day + " days!");
				return false;
				}
			}
		return true;
		}
			
		function isValidTime(timeStr) {
		// Time validation function courtesty of 
		// Sandeep V. Tamhankar (stamhankar@hotmail.com) -->
		
		// Checks if time is in HH:MM:SS AM/PM format.
		// The seconds and AM/PM are optional.
		
		var timePat = /^(\d{1,2}):(\d{2})(:(\d{2}))?(\s?(AM|am|PM|pm))?$/;
		
		var matchArray = timeStr.match(timePat);
		if (matchArray == null) {
		alert("Time is not in a valid format.");
		return false;
		}
		hour = matchArray[1];
		minute = matchArray[2];
		second = matchArray[4];
		ampm = matchArray[6];
		
		if (second=="") { second = null; }
		if (ampm=="") { ampm = null }
		
		if (hour < 0  || hour > 23) {
		alert("Hour must be between 1 and 12. (or 0 and 23 for military time)");
		return false;
		}
		if (hour <= 12 && ampm == null) {
		if (confirm("Please indicate which time format you are using.  OK = Standard Time, CANCEL = Military Time")) {
		alert("You must specify AM or PM.");
		return false;
		   }
		}
		if  (hour > 12 && ampm != null) {
		alert("You can't specify AM or PM for military time.");
		return false;
		}
		if (minute < 0 || minute > 59) {
		alert ("Minute must be between 0 and 59.");
		return false;
		}
		if (second != null && (second < 0 || second > 59)) {
		alert ("Second must be between 0 and 59.");
		return false;
		}
		return true;
		}

function submitCoachRequestForm()
{	

	if ( isWhitespace(coachRequestForm.Coachfirstname.value)) 
	{
		coachRequestForm.Coachfirstname.focus();

		alert('Please enter a value for the first name.');
		return false;
	}

	if ( isWhitespace(coachRequestForm.Coachlastname.value)) 
	{
		coachRequestForm.Coachlastname.focus();
		alert('Please enter a value for the last name.');
		return false;
	}

	if ( isWhitespace(coachRequestForm.Coachphoneareacode.value)) 
	{
		coachRequestForm.Coachphoneareacode.focus();
		alert('Please enter a value for the area code.');
		return false;
	}

	if ( isWhitespace(coachRequestForm.Coachphoneprefix.value)) 
	{
		coachRequestForm.Coachphoneprefix.focus();
		alert('Please enter a value for the phone prefix.');
		return false;
	}

	if ( isWhitespace(coachRequestForm.Coachphonesuffix.value)) 
	{
		coachRequestForm.Coachphonesuffix.focus();
		alert('Please enter a value for the phone suffix.');
		return false;
	}
	

	if ( isWhitespace(coachRequestForm.Coachemailaddress.value)) 
	{
		coachRequestForm.Coachemailaddress.focus();
		alert('Please enter a value for the email address.');
		return false;
	}

	// All is well, submit the form
	return true;
}


