// JavaScript Document
function getRadioValue(radioset){
		//Is the radio Collection valid? If not, return an empty string.
		if(!radioset){
			return "";
		}
		
		var radioLength = radioset.length;
		if(radioLength == undefined){
			if(radioset.checked){
				return radioset.value;
			}else{
				return "";
			}
		}

		for(var i = 0; i < radioLength; i++) {
			if(radioset[i].checked) {
				return radioset[i].value;
			}
		}
		return "";
	}

function  _CF_checkCFForm_1(_CF_this) {
	if  (!_CF_hasValue(_CF_this.NameFirst, "TEXT" )) {
		if  (!_CF_onError(_CF_this, _CF_this.NameFirst, _CF_this.NameFirst.value, "First Name is required.")) {
			return false;
		}
	}
	if  (!_CF_hasValue(_CF_this.NameLast, "TEXT" )) {
		if  (!_CF_onError(_CF_this, _CF_this.NameLast, _CF_this.NameLast.value, "Last Name is required.")) {
			return false;
		}
	}
	if  (!_CF_hasValue(_CF_this.Address1, "TEXT" )) {
		if  (!_CF_onError(_CF_this, _CF_this.Address1, _CF_this.Address1.value, "Address is required.")) {
			return false;
		}
	}
	if  (!_CF_hasValue(_CF_this.Country, "TEXT" )) {
		if  (!_CF_onError(_CF_this, _CF_this.Country, _CF_this.Country.value, "Country is required.")) {
			return false;
		}
	}
	if  (!_CF_hasValue(_CF_this.City, "TEXT" )) {
		if  (!_CF_onError(_CF_this, _CF_this.City, _CF_this.City.value, "City is required.")) {
			return false;
		}
	}
	if(document.getElementById("Country").value == 'US' || document.getElementById("Country").value == 'CA' || document.getElementById("Country").value == 'UK'){
		if  (!_CF_hasValue(_CF_this.State, "TEXT" )) {
			if  (!_CF_onError(_CF_this, _CF_this.State, _CF_this.State.value, "State is required.")) {
				return false;
			}
		}
	}
	if  (!_CF_hasValue(_CF_this.Zip, "TEXT" )) {
		if  (!_CF_onError(_CF_this, _CF_this.Zip, _CF_this.Zip.value, "Valid postal code is required.")) {
			return false;
		}
	}
	if(document.getElementById("Country").value == 'US'){
		if(document.getElementById("Zip").value.length != 5 && document.getElementById("Zip").value.length != 9){
			alert("Valid 5 or 9 digit postal code is required for US addresses.");
			return false;
		}
	}
	if  (!_CF_hasValue(_CF_this.PhoneAreaCode, "TEXT" )) {
		if  (!_CF_onError(_CF_this, _CF_this.PhoneAreaCode, _CF_this.PhoneAreaCode.value, "Valid 3 digit numeric area code is required for phone number.")) {
			return false;
		}
	}
	if  (!_CF_checkinteger(_CF_this.PhoneAreaCode.value)) {
		if  (!_CF_onError(_CF_this, _CF_this.PhoneAreaCode, _CF_this.PhoneAreaCode.value, "Valid 3 digit numeric area code is required for phone number.")) {
			return false;
		}
	}
	if  (!_CF_hasValue(_CF_this.PhoneExchangeCode, "TEXT" )) {
		if  (!_CF_onError(_CF_this, _CF_this.PhoneExchangeCode, _CF_this.PhoneExchangeCode.value, "Valid 3 digit numeric exchange code is required for phone number.")) {
			return false;
		}
	}
	if  (!_CF_checkinteger(_CF_this.PhoneExchangeCode.value)) {
		if  (!_CF_onError(_CF_this, _CF_this.PhoneExchangeCode, _CF_this.PhoneExchangeCode.value, "Valid 3 digit numeric exchange code is required for phone number.")) {
			return false;
		}
	}
	if  (!_CF_hasValue(_CF_this.PhoneLastFour, "TEXT" )) {
		if  (!_CF_onError(_CF_this, _CF_this.PhoneLastFour, _CF_this.PhoneLastFour.value, "Valid last 4 numeric digits is required for phone number.")) {
			return false;
		}
	}
	if  (!_CF_checkinteger(_CF_this.PhoneLastFour.value)) {
		if  (!_CF_onError(_CF_this, _CF_this.PhoneLastFour, _CF_this.PhoneLastFour.value, "Valid last 4 numeric digits is required for phone number.")) {
			return false;
		}
	}
	if  (!_CF_hasValue(_CF_this.Email, "TEXT" )) {
		if  (!_CF_onError(_CF_this, _CF_this.Email, _CF_this.Email.value, "Valid Email address is required.")) {
			return false;
		}
	}
	if  (!_CF_checkregex(_CF_this.Email.value, /[A-Za-z0-9_-]+@[A-Za-z0-9_-]+\.[A-Za-z]+/)) {
		if  (!_CF_onError(_CF_this, _CF_this.Email, _CF_this.Email.value, "Valid Email address is required.")) {
			return false;
		}
	}
	if  (!_CF_hasValue(_CF_this.Password, "PASSWORD" )) {
		if  (!_CF_onError(_CF_this, _CF_this.Password, _CF_this.Password.value, "Password is required.")) {
			return false;
		}
	}
	if  (!_CF_hasValue(_CF_this.children, "TEXT" )) {
		if  (!_CF_onError(_CF_this, _CF_this.children, _CF_this.children.value, "Providing number of children is required.")) {
			return false;
		}
	}
	if  (!_CF_hasValue(_CF_this.Contact, "RADIO" )) {
		if  (!_CF_onError(_CF_this, _CF_this.Contact, _CF_this.Contact.value, "Contact preference is required.")) {
			return false;
		}
	}
	if  (!_CF_hasValue(_CF_this.use_nw_1_gallon, "RADIO" )) {
		if  (!_CF_onError(_CF_this, _CF_this.use_nw_1_gallon, _CF_this.use_nw_1_gallon.value, "Do you currently use Nursery Water 1-gallon?")) {
			return false;
		}
	}
	if(getRadioValue(document.forms["CFForm_1"].elements["use_nw_1_gallon"]) == "1" && document.forms["CFForm_1"].elements["num_nw_1_gallons_used"].value == ""){
			alert("Approximately how many gallons do you use per week?");
			return false;
	}
	if  (!_CF_hasValue(_CF_this.use_nw_ss_multipacks, "RADIO" )) {
		if  (!_CF_onError(_CF_this, _CF_this.use_nw_ss_multipacks, _CF_this.use_nw_ss_multipacks.value, "Do you currently use Nursery Water Sesame Street multi-packs?")) {
			return false;
		}
	}
	if(getRadioValue(document.forms["CFForm_1"].elements["use_nw_ss_multipacks"]) == "1" && document.forms["CFForm_1"].elements["num_nw_ss_multipacks_used"].value == ""){
			alert("Approximately how many multi-packs do you use per week?");
			return false;
	}
	if(getRadioValue(document.forms["CFForm_1"].elements["use_nw_1_gallon"]) == "1" && document.forms["CFForm_1"].elements["num_nw_1_gallons_bought_each_time"].value == ""){
			alert("Approximately how many gallons do you purchase at a time?");
			return false;
	}
	if(getRadioValue(document.forms["CFForm_1"].elements["use_nw_ss_multipacks"]) == "1" && document.forms["CFForm_1"].elements["num_nw_ss_multipacks_bought_each_time"].value == ""){
			alert("Approximately how many multi-packs do you purchase at a time?");
			return false;
	}
	if(document.forms["CFForm_1"].elements["how_use_nw"].value == ""){
			alert("How do you use Nursery Water?");
			return false;
	}
	if(document.forms["CFForm_1"].elements["why_purchase_nw"].value == ""){
			alert("Why do you purchase Nursery Water?");
			return false;
	}
	return true;
}

function PCase(STRING) {
	var strReturn_Value = "";
	var iTemp = STRING.length;
	if(iTemp==0) {
		return"";
	}
	var UcaseNext = false;
	strReturn_Value += STRING.charAt(0).toUpperCase();
	for(var iCounter=1;iCounter < iTemp;iCounter++) {
		if(UcaseNext == true) {
			strReturn_Value += STRING.charAt(iCounter).toUpperCase();
		}
		else {
			strReturn_Value += STRING.charAt(iCounter).toLowerCase();
		}
		var iChar = STRING.charCodeAt(iCounter);
		if(iChar == 32 || iChar == 45 || iChar == 46) {
			UcaseNext = true;
		}
		else {
			UcaseNext = false
		}
		if(iChar == 99 || iChar == 67) {
			if(STRING.charCodeAt(iCounter-1)==77 || STRING.charCodeAt(iCounter-1)==109) {
				UcaseNext = true;
			}
		}
	} //End For
	return strReturn_Value;
} //End Function