function FSV_isAlphaNumeric(str)
{
	var r = new RegExp(/^[\sa-zA-Z0-9._-]+$/);
	return r.test(str);
}

function FSV_isNumeric(str)
{
	var r = new RegExp(/^[0-9]+$/);
	return r.test(str);
}

function FSV_isEmail(str)
{
	var r = new RegExp(/^([a-zA-Z0-9_\-])+(\.([a-zA-Z0-9_\-])+)*@((\[(((([0-1])?([0-9])?[0-9])|(2[0-4][0-9])|(2[0-5][0-5])))\.(((([0-1])?([0-9])?[0-9])|(2[0-4][0-9])|(2[0-5][0-5])))\.(((([0-1])?([0-9])?[0-9])|(2[0-4][0-9])|(2[0-5][0-5])))\.(((([0-1])?([0-9])?[0-9])|(2[0-4][0-9])|(2[0-5][0-5]))\]))|((([a-zA-Z0-9])+(([\-])+([a-zA-Z0-9])+)*\.)+([a-zA-Z])+(([\-])+([a-zA-Z0-9])+)*))$/);
	return r.test(str);
}

function FSV_isNotBlank(str)
{
	var r = new RegExp(/^\s*$/);
	return !r.test(str);
}

// Removes leading whitespaces
function FSV_LTrim( str )
{	
	var r = new RegExp(/\s*((\S+\s*)*)/);
	return str.replace(r, "$1");
}

// Removes ending whitespaces
function FSV_RTrim( str )
{	
	var r = new RegExp(/((\s*\S+)*)\s*/);
	return str.replace(r, "$1");
}

// Removes leading and ending whitespaces
function FSV_trim( value )
{
	return FSV_LTrim(FSV_RTrim(value));
}

//Check if a select menu has an option selected
function FSV_hasSelectedOption(selectItem)
{
	return (selectItem.selectedIndex != 0);
}

//Constructor for the FormValidation object
function FormValidation()
{
	this.isNotBlank = FSV_isNotBlank;
	this.isEmail = FSV_isEmail;
	this.isAlphaNumeric = FSV_isAlphaNumeric;
	this.isNumeric = FSV_isNumeric;
	this.ltrim = FSV_LTrim;
	this.rtrim = FSV_RTrim;
	this.trim = FSV_trim;
	this.hasSelectedOption = FSV_hasSelectedOption;
}