function trim(str) {

	return str.replace(/^\s+|\s+$/g, '');

}


function validateMandatory(str) {

	if (str == "" || str == "undefined") {
		return false;
	} else return true;
}

	
function validateEmail (email, mandatory){

	if (mandatory) {
		if (email == "" || email == "undefined") {
			return false;
		}
	}
	
	var cleanEmail = trim(email);  // value of field with whitespace trimmed off
  	var emailTest = /^[^@]+@[^@.]+\.[^@]*\w\w$/  ;
	
	if (emailTest.test(cleanEmail)) return true;
	
	return false;

}// JavaScript Document
