<!--
function hasValue(obj)
{
	switch (obj.type)
	{
		case "select-one":
			if (obj[obj.selectedIndex].value != "") return true;
			break;
		case "select-multiple":
			for (i = 0; i < obj.options.length; i++) {
				if (obj.options[i].selected && obj.options[i].value != "") return true;
			}
			break;
		case "text":
		case "textarea":
		case "hidden":
		case "password":
			if (obj.value.length > 0 && obj.value > " ") return true;
			break;
		case "checkbox":
		case "radio":
			if (obj.checked) return true;
			break;
		default:
			//check to see if this is an object array
			if (obj.length >= 0) {
				//check each element of the object array
				for (i = 0; i < obj.length; i++) {
					if (hasValue(obj[i])) return true;
				}
			}
			break;
	}

	//if we made it this far, the object does not have a value
	return false;
}

function getRadioValue(objRadio)
{
	//this function will return the value of the selected radio button
	for (i = 0; i < objRadio.length; i++) {
		if (objRadio[i].checked) return objRadio[i].value;
	}

	//if we made it here, we don't have a selected item so return empty string
	return "";
}

function getSelectValue(objSelect)
{
	//this function will return the value of the selected item in a select-one box
	var selectedItem = objSelect.selectedIndex;
	return objSelect[selectedItem].value;
}

function getSelectText(objSelect)
{
	//this function will return the value of the selected item in a select-one box
	var selectedItem = objSelect.selectedIndex;
	return objSelect[selectedItem].text;
}

function LTrim(objTextBox)
{
	//this function will trim leading spaces from the value of a text or hidden input
	//if not a text or hidden input, do nothing
	if (objTextBox.type == "text" || objTextBox.type == "hidden") {
		while('' + objTextBox.value.charAt(0) == ' ') objTextBox.value = objTextBox.value.substring(1, objTextBox.value.length);
	}
	return true;
}

function RTrim(objTextBox)
{
	//this function will trim trailing spaces from the value of a text or hidden input
	//if not a text or hidden input, do nothing
	if (objTextBox.type == "text" || objTextBox.type == "hidden") {
		while('' + objTextBox.value.charAt(objTextBox.value.length - 1) == ' ') objTextBox.value = objTextBox.value.substring(0, objTextBox.value.length - 1);
	}
	return true;
}

function Trim(objTextBox)
{
	//this function will trim both leading and trailing spaces from value of a text or hidden input
	//first, trim leading spaces using LTrim function
	LTrim(objTextBox);
	//then, trim trailing spaces using RTrim function
	RTrim(objTextBox);
	return true;
}

// is the value an integer
function validNumeric(number)
{
	var nonNumericRegExp = /\D/;

	if (nonNumericRegExp.test(number)) {
		//contains something other than 0-9
		return false;
	} else {
		return true;
	}
}

//does the value contain only letters and/or numbers
function regularChars(checkString)
{
	var regularCharsRegExp = /^[a-zA-Z0-9]+$/;

	if (regularCharsRegExp.test(checkString)) {
		return true;
	} else {
		return false;
	}
}

function validPostal(postalCD, countryCD)
{
	var usRegExp = /^\d{5}$/;
	var caRegExp = /^[a-zA-Z]\d[a-zA-Z] \d[a-zA-Z]\d$/;

	if (countryCD == "CA") {
		if (caRegExp.test(postalCD)) {
			return true;
		} else {
			return false;
		}
	} else {
		if (usRegExp.test(postalCD)) {
			return true;
		} else {
			return false;
		}
	}
}

function validEmail(emailValue)
{
	var emailRegExp = /\w+([-+.]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*/;

	if (emailRegExp.test(emailValue)) {
		return true;
	} else {
		return false;
	}
}
//-->