    
function trim(inputString) {
	if (typeof inputString != "string") { return inputString; }
	var retValue = inputString;
	var ch = retValue.substring(0, 1);
	while (ch == " ") 
	{ // Check for spaces at the beginning of the string
		retValue = retValue.substring(1, retValue.length);
		ch = retValue.substring(0, 1);
	}
	ch = retValue.substring(retValue.length-1, retValue.length);
	while (ch == " ") 
	{ // Check for spaces at the end of the string
		retValue = retValue.substring(0, retValue.length-1);
		ch = retValue.substring(retValue.length-1, retValue.length);
	}
	while (retValue.indexOf("  ") != -1) 
	{ // Note that there are two spaces in the string - look for multiple spaces within the string
		retValue = retValue.substring(0, retValue.indexOf("  ")) + retValue.substring(retValue.indexOf("  ")+1, retValue.length); // Again, there are two spaces in each of the strings
	}
	return retValue; // Return the trimmed string back to the user
}



//form validation
	function isEmail(elm) {
		if (elm.value.indexOf("@")!=-1 && elm.value.indexOf(".")!= "-1" && elm.value !="")
		return true;
		else return false;
	}
	
	function trim(inputString) {
		if (typeof inputString != "string") { return inputString; }
			var retValue = inputString;
			var ch = retValue.substring(0, 1);
			while (ch == " ") { // Check for spaces at the beginning of the string
				retValue = retValue.substring(1, retValue.length);
				ch = retValue.substring(0, 1);
			}
			ch = retValue.substring(retValue.length-1, retValue.length);
			while (ch == " ") { // Check for spaces at the end of the string
				retValue = retValue.substring(0, retValue.length-1);
				ch = retValue.substring(retValue.length-1, retValue.length);
			}
			while (retValue.indexOf("  ") != -1) { // Note that there are two spaces in the string - look for multiple spaces within the string
				retValue = retValue.substring(0, retValue.indexOf("  ")) + retValue.substring(retValue.indexOf("  ")+1, retValue.length); // Again, there are two spaces in each of the strings
			}
		return retValue; // Return the trimmed string back to the user
	} // Ends the "trim" function
	
	
	
	function check(pogo_form) {
			
		if (trim(pogo_form.fname.value).length == 0) {
		alert ("Please enter your first name.");
	    	pogo_form.fname.focus();
	    	return false;
		}

		if (trim(pogo_form.lname.value).length == 0) {
		alert ("Please enter your last name.");
		    pogo_form.lname.focus();
		    return false;
		}

		if (trim(pogo_form.email_address.value).length == 0) {
		alert ("Please enter an e-mail address.");
		    pogo_form.email_address.focus();
		    return false;
		}

		if (!isEmail(pogo_form.email_address)) {
			alert ("Invalid email address?\nPlease make sure your e-mail address was entered correctly.");
			pogo_form.email_address.focus();
			return false;
		}


		if (trim(pogo_form.address_1.value).length == 0) {
		alert ("Please enter your address.");
		    pogo_form.address_1.focus();
		    return false;
		}


		if (trim(pogo_form.city.value).length == 0) {
		alert ("Please enter your city.");
		    pogo_form.city.focus();
		    return false;
		}


		if (trim(pogo_form.state.value).length == 0) {
		alert ("Please enter your state.");
		    pogo_form.state.focus();
		    return false;
		}

		if (trim(pogo_form.zip.value).length == 0) {
		alert ("Please enter your zip code.");
		    pogo_form.zip.focus();
		    return false;
		}

		if (trim(pogo_form.phone.value).length == 0) {
		alert ("Please enter your phone number.");
		    pogo_form.phone.focus();
		    return false;
		}

		return true;

	}

	function checkServices(pogo_form) {
	
		var cboxes=document.getElementById('field_1').getElementsByTagName('input');
		for (j=0; j<cboxes.length; j++) {
			if (cboxes[j].checked==true) return true;
		}

		alert ("Please select one or more services that interest you.");
		return false;
	}
	
	function checkAdultFam(pogo_form) {

		if (trim(pogo_form.email_address.value).length == 0) {
			alert ("Please enter an e-mail address.");
		    	pogo_form.email_address.focus();
		    	return false;
		}

		if (!isEmail(pogo_form.email_address)) {
			alert ("Invalid email address?\nPlease make sure your e-mail address was entered correctly.");
			pogo_form.email_address.focus();
			return false;
		}

		return checkServices(pogo_form);

	}

	function checkProf(pogo_form) {

		if (trim(pogo_form.fname.value).length == 0) {
		alert ("Please enter your first name.");
	    pogo_form.fname.focus();
	    return false;
		}

		if (trim(pogo_form.lname.value).length == 0) {
		alert ("Please enter your last name.");
	    pogo_form.lname.focus();
	    return false;
		}

		if (trim(pogo_form.address_1.value).length == 0) {
		alert ("Please enter your address.");
	    pogo_form.address_1.focus();
	    return false;
		}

		if (trim(pogo_form.city.value).length == 0) {
		alert ("Please enter your city.");
	    pogo_form.city.focus();
	    return false;
		}

		if (trim(pogo_form.state.value).length == 0) {
		alert ("Please enter your state.");
	    pogo_form.state.focus();
	    return false;
		}

		if (trim(pogo_form.zip.value).length == 0) {
		alert ("Please enter your zip.");
	    pogo_form.zip.focus();
	    return false;
		}

		/*if (trim(pogo_form.email.value).length == 0) {
		alert ("Please enter an e-mail address.");
	    pogo_form.email.focus();
	    return false;
		}

		if (!isEmail(pogo_form.email)) {
			alert ("Invalid email address?\nPlease make sure your e-mail address was entered correctly.");
			pogo_form.email.focus();
			return false;
		}
		*/
		return checkServices(pogo_form);

	}