function checkValidEmail(strEmailAddress) {
var tmpBool; var tmp1; var tmp2;
/* Remove extraneous white space */
strEmailAddress = strEmailAddress.trim();
/* splits the multiple emails into an array*/
var arrEmails = strEmailAddress.split(',');
for(i=0; i<arrEmails.length; i++){
/* Remove extraneous white space */
arrEmails[i] = arrEmails[i].trim();
/* Break the input field into two parts based at the @ sign. The first part 
* is the text to the left of the @ sign in the email address and is the username
* portion of an email address. The second part is the text to the right of the @ 
* sign in the email address and is the domain where the email should be routed.*/
var strTmp = arrEmails[i].split('@');
var strUser = strTmp[0] + "";
var strDomain = strTmp[1] + ""; 
/* Ensure the username is at least one character and that the domain name is 
at least 3 characters. */
tmpBool = (strUser.length > 1) & (strDomain.length > 3);
/* Ensure that the domain does not contain an underscore (_) and that it does
* contain a period (.) that is not the last character of the domain name */
tmp1 = strDomain.indexOf('_') < 0;
tmp2 = strDomain.indexOf('.') > 0 & (strDomain.lastIndexOf('.') + 1 < strDomain.length);
tmpBool = tmp1 & tmp2 & tmpBool;
/* Ensure email address does not contain percentage signs (%) nor semi-colons (;) */
tmp1 = arrEmails[i].indexOf('%') < 0;
tmp2 = arrEmails[i].indexOf(';') < 0;
tmpBool = tmp1 & tmp2 & tmpBool;
/* Ensure email address does not contain spaces ( ) nor single qoutes (`) */
tmp1 = arrEmails[i].indexOf(' ') < 0;
tmp2 = arrEmails[i].indexOf("'") < 0;
tmpBool = tmp1 & tmp2 & tmpBool;
/* Ensure email address does not contain double quotes (") nor spaces ( ) */
tmp1 = arrEmails[i].indexOf('"') < 0;
tmp2 = arrEmails[i].indexOf(' ') < 0;
tmpBool = tmp1 & tmp2 & tmpBool;
/* Ensure email address does not contain back slashes (\) nor forward slashes (/) */
tmp1 = arrEmails[i].indexOf('\\') < 0;
tmp2 = arrEmails[i].indexOf('/') < 0;
tmpBool = tmp1 & tmp2 & tmpBool;
/* Ensure email address does not contain colons (:) nor ampersands (&) */
tmp1 = arrEmails[i].indexOf(':') < 0;
tmp2 = arrEmails[i].indexOf('&') < 0;
tmpBool = tmp1 & tmp2 & tmpBool;
/* Ensure email address does not contain exclamation points (!) nor question marks (?) */
tmp1 = arrEmails[i].indexOf('!') < 0;
tmp2 = arrEmails[i].indexOf('?') < 0;
tmpBool = tmp1 & tmp2 & tmpBool;
/* Ensure email address does not contain asterisks (*) nor pound signs (#) */
tmp1 = arrEmails[i].indexOf('*') < 0;
tmp2 = arrEmails[i].indexOf('#') < 0;
tmpBool = tmp1 & tmp2 & tmpBool;
 }
 return(tmpBool);
}

String.prototype.trim = function() {
// Use a regular expression to replace leading and trailing 
// spaces with the empty string
 return this.replace(/(^\s*)|(\s*$)/g, "");
}

function isBlank(text) { for (var i = 0; i < text.length; i++) { 
if (text.charAt(i) != " ") { return false; } } return true; }

function isValidAttachment(fldVal) { 
var strValue = fldVal.trim(); strValue = strValue.toLowerCase();
 if (isBlank(strValue)){ return true; } else {
 return ( strValue.indexOf('.pdf') > 0 || strValue.indexOf('.doc') > 0 || strValue.indexOf('.ppt') > 0 
 || strValue.indexOf('.xls') > 0 || strValue.indexOf('.txt') > 0 || strValue.indexOf('.zip') > 0 
 || strValue.indexOf('.docx') > 0 || strValue.indexOf('.xlsx') > 0 || strValue.indexOf('.pptx') > 0
 )}
}

function removeChars(strTemp) {
	strTemp = strTemp.replace(/\<|\>|\"|\%|\;|\(|\)|\&|\+/g,"");
	return strTemp;
}




