function checkLen(o, next) {
	if ( o.value.length == o.size ) next.focus();
	return true;
}

var validateMsg = "";
var validateCount = 0;
var petRadioClicked = false;
var gateRadioClicked = false;

function allReqVars(fs) {
	var msg = "";
	var len = fs.length;

	for ( var i = 0; i < len; i++ ) {
		msg += fs.elements[i].name + ": " + fs.elements[i].value + "\n";
//		msg += eval(fs + ".elements[" + i + "].name") + ": " + eval(fs + ".elements[" + i + "].value") + "\n";
	}
	return msg;
}

function formatPhoneNumber(n) {

	var s = "";

// Get digits from phone number

	for ( var i = 0; i < n.value.length; i++ ) {
		if ( n.value.charAt(i) >= '0' && n.value.charAt(i) <= '9' ) {
			s = s.concat(n.value.charAt(i));
		}
	}

// If 10 digits long, format (npa) nxx-line

	if ( s.length == 10 ) {
/*		n.value = "(" + s.substr(0,3) + ") " + s.substr(3,3) + "-" + s.substr(6); */
		n.value = s.substr(0,3) + "-" + s.substr(3,3) + "-" + s.substr(6);
	}
}

function validateRequest(f) {
	var pattern = "";
	validateMsg = "";
	validateCount = 0;
	focusSet = 0;

// Check that all fields are populated correctly
	
	if ( f.name.value == "" ) {
		validateMsg = "    Name\n";
		validateCount += 1;
		f.name.focus();
		focusSet = 1;
	}
	if ( f.phone.value == "" ) {
		validateMsg += "    Phone\n";
		validateCount += 1;
		if ( ! focusSet ) {
			f.phone.focus();
			focusSet = 1;
		}
	}
	if ( f.captcha_code.value == "" ) {
		validateMsg += "    Security Code\n";
		validateCount += 1;
		if ( ! focusSet ) {
			f.captcha_code.focus();
			focusSet = 1;
		}
	}

// Announce any missing fields

	if ( validateCount > 0 ) {
		var instructions = "Please complete the following field";
		if ( validateCount > 1 ) {
			instructions += "s:\n";
		}
		else {
			instructions += ":\n";
		}
		alert( instructions + validateMsg );
		return false;
	}

	return true;
}

