var reSpecialChars = /[\'\"]/g;      //matches any occurence of single quote or double quote
var reInitialWhitespace = /^\s+/g;   //matches one or more whitespace char at start of string
var reTermialWhitespace = /\s+$/g;   //matches one or more whitespace char at end of string
var reBackSlash = /%5C/gi;
var reSemiColon = /\;/gi;
var reForwardSlash = /[\\]/g;
var reOpenBrackets= /[\{\<]/g;
var reCloseBrackets= /[\}\>]/g;


// These methods below are not necessary but are included as sample library functions that are used in the example
function validateNotEmpty( strValue ) {
	/************************************************
	DESCRIPTION: Validates that a string is not all
	blank (whitespace) characters.

	PARAMETERS:
	strValue - String to be tested for validity

	RETURNS:
	True if not empty, otherwise false.
	*************************************************/
	var strTemp = strValue;
	strTemp = trimAll(strTemp);
	if(strTemp.length > 0){
		return true;
	}
	return false;
}

//Description       : Removes spaces from the start and end of the string. Spaces in the middle are not removed.
//Input Parameters  : s - String
//Output            : String sOutStr
function trim (s)
{
	return stripCharacters(stripCharacters (s, reInitialWhitespace),reTermialWhitespace);
}

function trimAll( strValue ) {
/************************************************
DESCRIPTION: Removes leading and trailing spaces.

PARAMETERS: Source string from which spaces will
be removed;

RETURNS: Source string with whitespaces removed.
*************************************************/
	var objRegExp = /^(\s*)$/;

		//check for all spaces
		if(objRegExp.test(strValue)) {
		strValue = strValue.replace(objRegExp, '');
		if( strValue.length == 0)
			return strValue;
		}

	//check for leading & trailing spaces
	objRegExp = /^(\s*)([\W\w]*)(\b\s*$)/;
	if(objRegExp.test(strValue)) {
		//remove leading and trailing whitespace characters
		strValue = strValue.replace(objRegExp, '$2');
	}
	return strValue;
}

//Description       : Strip character in passed reBag (valid RegExp expression) from passed String
//                  ; Note that reBag must be a valid RegExp which matches sigle characters in isolation
//                  ; and make sure the 'g' modifier is appended for global search & replace.
//Input Parameters  : s - String
//Output            : String with designated (reBag) characters removed
function stripCharacters(s, reBag)
{
	return s.replace(reBag, '')
}

var testresults
function checkemail(email){
	var str=email
	var filter=/^(("[\w-\s]+")|([\w-]+(?:\.[\w-]+)*)|("[\w-\s]+")([\w-]+(?:\.[\w-]+)*))(@((?:[\w-]+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$)|(@\[?((25[0-5]\.|2[0-4][0-9]\.|1[0-9]{2}\.|[0-9]{1,2}\.))((25[0-5]|2[0-4][0-9]|1[0-9]{2}|[0-9]{1,2})\.){2}(25[0-5]|2[0-4][0-9]|1[0-9]{2}|[0-9]{1,2})\]?$)/i
	if (filter.test(str))
		testresults=true
	else{
		alert("Please input a valid email address!")
		testresults=false
	}
	return (testresults)
}

