/*
 * Author: Janus C Midtgaard
 */
// returns true if the string is empty
function isEmpty(str)
{
	if( str == null || str.length == 0 ){ return true; }
	return false;
}
// returns true if the string is a valid email
function isEmail(str){
	if(isEmpty(str)) return false;
	var re = /^[^\s()<>@,;:\/]+@\w[\w\.-]+\.[a-z]{2,}$/i
	return re.test(str);
}
// returns true if the string only contains characters A-Z or a-z
function isAlpha(str)
{
	var re = /[^a-zA-Z]/g
	if (re.test(str)) return false;
	return true;
}
// returns true if the string only contains characters 0-9
function isNumeric(str)
{
	var re = /[\D]/g
	if (re.test(str)) return false;
	return true;
}
// returns true if the string only contains characters A-Z, a-z or 0-9
function isAlphaNumeric(str)
{
	var re = /[^a-zA-Z0-9]/g;
	if( re.test(str) )
		return false;
	return true;
}

function isAlphaNumericAndWhitespaces(value)
{
	var re = /[^a-z0-9ÆØÅ\s]/gi;
	if( re.test( value ) )
		return false;
	return true;
}

function isLength(str, len)
{
	return str.length == len;
}
// returns true if the string's length is between "min" and "max"
function isLengthBetween(str, min, max)
{
	return (str.length >= min)&&(str.length <= max);
}

function isAlphaNumericMinMax( str, min, max )
{
	if(isAlphaNumeric(str))
		return isLengthBetween(str, min, max)
	return false;
}

function isAlphaMinMax(str, min, max)
{
	if(isAlpha(str))
		return isLengthBetween(str, min, max)
	return false;
}

function isNumericMinMax(str, min, max)
{
	if(isNumeric(str))
		return isLengthBetween(str, min, max)
	return false;
}

function isAlphaNumericAndWhitespacesMinMax(str, min, max)
{
	if(isAlphaNumericAndWhitespaces(str))
		return isLengthBetween(str, min, max)
	return false;
}



