var ticlField = "";
var ticlFieldPrev = "";

function TICLValidateEmpty(field)
{
	result = (field.value.length == 0);

	ticlFieldPrev = ticlField;
	ticlField = field;

	return result;
}

function TICLValidateNonEmpty(field)
{
	result = (field.value.length != 0);

	ticlFieldPrev = ticlField;
	ticlField = field;

	return result;
}

/**
 * compare to another field.
 */
function TICLValidateEquals(field, fieldTo)
{
	value = field.value;
	if (field.type == "radio" || field.type == "checkbox" )
	{
		value = field.checked + "";
	}
	if (field.type == "select" || field.type == "select-one" )
	{
		value = field.options[field.selectedIndex].text;
	}

	result = (value.toLowerCase() == fieldTo.toLowerCase());

	ticlFieldPrev = ticlField;
	ticlField = field;

	return result;
}

/**
 * compare to an array of string literals.
 */
function TICLValidateEqualsA(field, strArray)
{
	result = false;
	value = field.value;

	if (field.type == "radio" || field.type == "checkbox" )
	{
		value = field.checked + "";
	}
	if (field.type == "select" || field.type == "select-one" )
	{
		value = getOptionItemByIndex(field.name, field.selectedIndex).data;
	}

	for (i = 0; i < strArray.length; i++)
	{
		if (value.toLowerCase() == strArray[i].toLowerCase())
		{
			result = true;
			break;
		}
	}

	ticlFieldPrev = ticlField;
	ticlField = field;

	return result;
}

/**
 * evaluate the regexp against the field.
 */
function TICLValidateMatches(field, regexp)
{
	re = new RegExp(regexp);
	result = re.test(field.value);

	ticlFieldPrev = ticlField;
	ticlField = field;

	return result;
}