libjsValidateErrorString = "";
libjsValidateErrorField = null;

function _clearError()
	{
	libjsValidateErrorString = "";
	libjsValidateErrorField = null;	
	}
	
function _onError( str, obj )
	{
	libjsValidateErrorString = libjsValidateErrorString + "\n" + str;
	libjsValidateErrorField = obj;
	return false;
	}
function _requiredField( obj, msg, cstate )
	{
	if( obj.value.length == 0 ) return _onError(msg, obj);
	return cstate;
	}
function _requiredLength( obj, msg, minlen, cstate )
	{
	if( obj.value.length < minlen ) return _onError(msg, obj);
	return cstate;
	}
function _validSame( obj1, obj2, msg, cstate )
	{
	if( obj1.value != obj2.value ) return _onError(msg, obj2);
	return cstate;
	}
function _validEmail( obj, msg, cstate )
	{
	if( obj.value.length == 0 )
		{
		return _onError(msg, obj);
		}
	else
		{
		tempmail = "" + (obj.value);
		
		if( (tempmail.indexOf("@") == -1) ||
			(tempmail.indexOf(".") == -1))
				return _onError(msg, obj);
		}		
	return cstate;
	}
function _validDate( objDay, objMonth, objYear, msg, cstate )
	{
	_day   = 0 + objDay.options[objDay.selectedIndex].value;
	_month = objMonth.options[objMonth.selectedIndex].value;
	_year  = 0 + objYear.options[objYear.selectedIndex].value;

	// Validate the date
	if( _month == "Sept" ||
		_month == "Apr" ||
		_month == "Jun" ||
		_month == "Nov" )
		{
		if( _day > 30 )
			return _onError(msg + "\nThere are only 30 days in the selected month!", objDay);
		}
	if( _month == "Feb" )
		{
		//Is it a leap year (modulus 4)
		if( (_year % 4) == 0 )
			{
			if(_day > 29 )
				return _onError(msg + "\nThere are 29 days in February of that year.", objDay);
			}
		else
			{
			if( _day > 28 )
				return _onError(msg + "\nThere are 28 days in February of that year.", objDay);
			}
		}
	return cstate;
	}
function _requiredChecked( obj, msg, cstate)
{
	if (obj.length > 0)
		{
		var ii = 0;
		for (ii=0;ii<=obj.length-1;ii++)
			{
			if (obj[ii].checked)
				return cstate;
			}
		return _onError(msg,obj)
		}
	else
		{
		if (!obj.checked)
			{
			return _onError(msg,obj)
			}
		}
	return cstate;
}
function _getSelectedRadio(obj)
{
var len = obj.length;
for (ii=0;ii<=len-1;ii++)
	{
	if (obj[ii].checked)
		return ii;
	}
return -1;
}
