function doFieldInfo(FieldID) {
	var new_win;
	fieldInfoWin = window.open('/includes/field_info.cfm?getIt=' + FieldID, 'FieldInfoWindow', 'toolbar=no,width=400,height=225,status=no,scrollbars=no,resizable=yes,menubar=no,location=no');
	fieldInfoWin.focus();
}

// this function is here to check to see that the password is at least 4 characters long
function _at_least_4_char(obj) {
	if (obj.value.length < 4)
		return false;
	else
		return true;
}

function _CF_onError(form_object, input_object, object_value, error_message) {
	alert(error_message);
	return false;
}

function _CF_hasValue(obj, obj_type) {
if (obj_type == "TEXT") {
	if (obj.value.length == 0)
		return false;
	else
		return true;
	} else if (obj_type == "SELECT") {
	for (i=0; i < obj.length; i++) {
		if (obj.options[obj.selectedIndex].value == "--")
			return false;
		}
		return true;
	}
}

function _CF_checkinteger(object_value) {
//Returns true if value is a number or is NULL
//otherwise returns false

if (object_value.length == 0)
	return true;

//Returns true if value is an integer defined as
//   having an optional leading + or -.
//   otherwise containing only the characters 0-9.
var decimal_format = ".";
var check_char;

//The first character can be + -  blank or a digit.
check_char = object_value.indexOf(decimal_format)
//Was it a decimal?
if (check_char < 1)
	return _CF_checknumber(object_value);
else
	return false;
}


function _CF_numberrange(object_value, min_value, max_value) {
// check minimum
if (min_value != null) {
	if (object_value < min_value)
	return false;
}

// check maximum
if (max_value != null) {
	if (object_value > max_value)
		return false;
}

//All tests passed, so...
return true;
}


function _CF_checknumber(object_value) {
//Returns true if value is a number or is NULL
//otherwise returns false

if (object_value.length == 0)
	return true;

//Returns true if value is a number defined as
//   having an optional leading + or -.
//   having at most 1 decimal point.
//   otherwise containing only the characters 0-9.
var start_format = " .+-0123456789";
var number_format = " .0123456789";
var check_char;
var decimal = false;
var trailing_blank = false;
var digits = false;

//The first character can be + - .  blank or a digit.
check_char = start_format.indexOf(object_value.charAt(0))
//Was it a decimal?
if (check_char == 1)
	decimal = true;
else if (check_char < 1)
	return false;

//Remaining characters can be only . or a digit, but only one decimal.
for (var i = 1; i < object_value.length; i++) {
	check_char = number_format.indexOf(object_value.charAt(i))
	if (check_char < 0)
		return false;
	else if (check_char == 1) {
		if (decimal)		// Second decimal.
		return false;
		else
			decimal = true;
	} else if (check_char == 0) {
		if (decimal || digits)
			trailing_blank = true;

	// ignore leading blanks
	} else if (trailing_blank)
		return false;
	else
		digits = true;
}
//All tests passed, so...
return true
}


function _CF_checkrange(object_value, min_value, max_value) {
//if value is in range then return true else return false
if (object_value.length == 0)
	return true;

if (!_CF_checknumber(object_value)) {
	return false;
} else {
	return (_CF_numberrange((eval(object_value)), min_value, max_value));
}

//All tests passed, so...
return true;
}


function _CF_checkphone(object_value) {
if (object_value.length == 0)
	return true;

if (object_value.length != 12)
	return false;

// check if first 3 characters represent a valid area code
if (!_CF_checknumber(object_value.substring(0,3)))
	return false;
else
if (!_CF_numberrange((eval(object_value.substring(0,3))), 100, 1000))
	return false;

// check if area code/exchange separator is either a'-' or ' '
if (object_value.charAt(3) != "-" && object_value.charAt(3) != " ")
	return false

// check if  characters 5 - 7 represent a valid exchange
if (!_CF_checknumber(object_value.substring(4,7)))
	return false;
else
if (!_CF_numberrange((eval(object_value.substring(4,7))), 100, 1000))
	return false;

// check if exchange/number separator is either a'-' or ' '
if (object_value.charAt(7) != "-" && object_value.charAt(7) != " ")
	return false;

// make sure last for digits are a valid integer
if (object_value.charAt(8) == "-" || object_value.charAt(8) == "+")
	return false;
else
{
	return (_CF_checkinteger(object_value.substring(8,12)));
}
}

// main form check when submitting new profile info
function checkmyForm(theForm) {
	if (!_CF_hasValue(theForm.School_Addy, "TEXT" )) {
		if (!_CF_onError(theForm, theForm.School_Addy, theForm.School_Addy.value, "You must enter your STREET ADDRESS to continue.")) {
			theForm.School_Addy.focus();
			return false;
		}
	}
	
	if (!_CF_hasValue(theForm.School_City, "TEXT" )) {
		if (!_CF_onError(theForm, theForm.School_City, theForm.School_City.value, "You must enter your CITY to continue.")) {
			theForm.School_City.focus();
			return false;
		}
	}
	
	if (!_CF_hasValue(theForm.School_Zip, "TEXT" )) {
		if (!_CF_onError(theForm, theForm.School_Zip, theForm.School_Zip.value, "You must enter your ZIP CODE to continue.")) {
			theForm.School_Zip.focus();
			return false;
		}
	}
	
	if (!_CF_hasValue(theForm.FirstName, "TEXT" )) {
		if (!_CF_onError(theForm, theForm.FirstName, theForm.FirstName.value, "You must enter your FIRST NAME to continue.")) {
			theForm.FirstName.focus();
			return false;
		}
	}
	
	if (!_CF_hasValue(theForm.LastName, "TEXT" )) {
		if (!_CF_onError(theForm, theForm.LastName, theForm.LastName.value, "You must enter your LAST NAME to continue.")) {
			theForm.LastName.focus();
			return false;
		}
	}
	
	if (!_CF_checkphone(theForm.Phone.value)) {
		if (!_CF_onError(theForm, theForm.Phone, theForm.Phone.value, "You must enter your PHONE NUMBER, including area code, in the following format\n\n     888-555-1234")) {
			theForm.Phone.focus();
			return false;
		}
	}
	
	if (!_CF_checkinteger(theForm.HowMany.value)) {
		theForm.HowMany.value = 15;
	}
	
	if (!_CF_hasValue(theForm.JobTitle, "SELECT" )) {
		if (!_CF_onError(theForm, theForm.JobTitle, theForm.JobTitle.value, "Please select your JOB TITLE from the pop-up menu.")) {
			theForm.JobTitle.focus();
			return false;
		}
	}
	
	if (!_CF_hasValue(theForm.SubjectArea, "SELECT" )) {
		if (!_CF_onError(theForm, theForm.SubjectArea, theForm.SubjectArea.value, "Please select your SUBJECT AREA from the pop-up menu.")) {
			theForm.SubjectArea.focus();
			return false;
		}
	}
	
	return true;
}
