// create object
function FormValidator()
{
	// set up object methods
	this.isEmpty = isEmpty;	
	this.isNumber = isNumber;	
	this.isAlphabetic = isAlphabetic;	
	this.isAlphaNumeric = isAlphaNumeric;	
	this.isWithinRange = isWithinRange;	
	this.isEmailAddress = isEmailAddress;	
	this.isChecked = isChecked;	

	this.raiseError = raiseError;	
}

// check to see if input is whitespace only or empty
function isEmpty(val, msg)
{
	if (val.match(/^s+$/) || val == "")
	{
		this.raiseError(msg);
		return true;
	}
	else
	{
		return false;
	}	
}

// check to see if input is number
function isNumber(val, msg)
{
	if (isNaN(val))
	{
		return false;
	}
	else
	{
		this.raiseError(msg);
		return true;
	}	
}

// check to see if input is alphabetic
function isAlphabetic(val, msg)
{
	if (val.match(/^[a-zA-Z]+$/))
	{
		return true;
	}
	else
	{
		this.raiseError(msg);
		return false;
	}	
}

// check to see if input is alphanumeric
function isAlphaNumeric(val, msg)
{
	if (val.match(/^[a-zA-Z0-9]+$/))
	{
		return true;
	}
	else
	{
		this.raiseError(msg);
		return false;
	}	
}

// check to see if value is within range
function isWithinRange(val, msg, min, max)
{
	if (val >= min && val <= max)
	{
		return true;
	}
	else
	{
		this.raiseError(msg);
		return false;
	}	
}

// check to see if input is a valid email address
function isEmailAddress(val, msg)
{
	if (val.match(/^([a-zA-Z0-9])+([.a-zA-Z0-9_-])*@([a-zA-Z0-9_-])+(.[a-zA-Z0-9_-]+)+/))
	{
		return true;
	}
	else
	{
		this.raiseError(msg);
		return false;
	}	
}

// check to see if form value is checked
function isChecked(obj, msg)
{
	if (obj.checked)
	{
		return true;
	}
	else
	{
		this.raiseError(msg);
		return false;
	}	
}

// add an error to error list
function raiseError(msg)
{
	alert(msg);
}

// end object

