// JavaScript Document

// return TRUE if the email is valid or if the email is empty
function emailValidOrBlank(elem){
	var emailExp = /^[\w\-\.\+]+\@[a-zA-Z0-9\.\-]+\.[a-zA-z0-9]{2,4}$/;
	if(elem.value.match(emailExp)){
		return true;
	}else{
		if(elem.value.length == 0){
			return true;
		}else{
			elem.focus();
			return false;
		}
	}
}

function isEmpty(elem){
	if(elem.value.length == 0){
		elem.focus(); // set the focus to this input
		return true;
	}
	return false;
}

function isNumeric(elem){
	var numericExpression = /^[0-9]+$/;
	if(elem.value.match(numericExpression)){
		return true;
	}else{
		elem.focus();
		return false;
	}
}

function isAlphabet(elem){
	var alphaExp = /^[a-zA-Z]+$/;
	if(elem.value.match(alphaExp)){
		return true;
	}else{
		elem.focus();
		return false;
	}
}

// alphabetic characters and spaces allowed
function isAlphabetSpaces(elem){
	var alphaExp = /^[a-zA-Z][a-zA-Z ]*$/;
	if(elem.value.match(alphaExp)){
		return true;
	}else{
		elem.focus();
		return false;
	}
}

function isAlphaNumeric(elem, helperMsg){
	var alphaExp = /^[0-9a-zA-Z]+$/;
	if(elem.value.match(alphaExp)){
		return true;
	}else{
		elem.focus();
		return false;
	}
}

function isAlphaNumericSpaces(elem){
	var alphaExp = /^[0-9a-zA-Z][0-9a-zA-Z ]*$/;
	if(elem.value.match(alphaExp)){
		return true;
	}else{
		elem.focus();
		return false;
	}
}


function emailValidator(elem){
	var emailExp = /^[\w\-\.\+]+\@[a-zA-Z0-9\.\-]+\.[a-zA-z0-9]{2,4}$/;
	if(elem.value.match(emailExp)){
		return true;
	}else{
		elem.focus();
		return false;
	}
}
