// Check whether string s is empty.

function isEmpty(s){
	s = trim(s);
	return ((s == null) || (s.length == 0))
}

function isEmail(email){
	var pattern = /^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/;
	return trim(email).match(pattern);
}

function trim(s) {
	 if (s != null) {
	 	 return s.replace(/^\s+|\s+$/, '');
	 }
	 return "";
}

function isAlphanumeric(s){
	var pattern = /^[a-zA-Z0-9]+$/;
	return s.match(pattern);
}

function isValidZip(s){
	if(isEmpty(s)){
		return false;
	}	
	return s.match(/^[0-9]{5}(|-[0-9]{4})$/);
}

function isValidPostalCode(s){
	if(isEmpty(s)){
		return false;
	}
	return s.match(/^[a-zA-Z][0-9][a-zA-Z](|\s|-)[0-9][a-zA-Z][0-9]$/);
}