/***********************************
// Function to Check for valid email. User can check multiple email ids
**********************************/
	function isEmail(pmStr, pmMultiple)
	{
		/******************************
		// pmStr = String contain email
		// pmMultiple = TURE or FALSE. Whether this email string contains multiple emails
		******************************/
		vResValidate = false;
		if (pmMultiple)
		{
			aEmailIds = pmStr.split(",")
			vResValidate = true;
			for(vLoopEmail = 0; vLoopEmail < aEmailIds.length; vLoopEmail++)
			{
				if (!isEmailOne(aEmailIds[vLoopEmail]))
				{
					vResValidate = false;
					break ;
				}
			}
		}
		else
			vResValidate = isEmailOne(pmStr)	
		
		return vResValidate;
	} //#-- close of isEmail()
	
	
	function isEmailOne(pmStr)
	{
		/******************************
		// @pmStr = String contain email
		******************************/
		//#-- trim the string
			pmStr = trim(pmStr);
		
		//#-- is regular expressions supported
			if (!isRegExpSupported()) 
				return (pmStr.indexOf(".") > 2) && (pmStr.indexOf("@") > 0);
	
		//#-- if regular expresson supported
			var vR1 = new RegExp("(@.*@)|(\\.\\.)|(@\\.)|(^\\.)");
			var vR2 = new RegExp("^.+\\@(\\[?)[a-zA-Z0-9\\-\\.]+\\.([a-zA-Z]{2,3}|[0-9]{1,3})(\\]?)$");
		
		//#-- return staus
			return (!vR1.test(pmStr) && vR2.test(pmStr));
	}
	function isRegExpSupported()
	{
		//#-- are regular expressions supported?
			if (window.RegExp)
			{
				//#-- assign expression
					var vTempStr = "a";
					var vTempReg = new RegExp(vTempStr);
				
				//#-- return status
					return (vTempReg.test(vTempStr));
			}
		
		//#-- return status
			return (false);
	} //#-- close of isRegExpSupported()

/************************************************
// Function to remove complete white spaces string
************************************************/
	function trim(pmStr)
	{
		/*****************************
		// @pmStr = String to be trimed
		*****************************/

		//#-- is regular expressions supported and return string with removed spaces
			if (isRegExpSupported()) 
				return pmStr.replace( /^ +/, "").replace( / +$/, "");
		
		//#-- check all the string for white space	
			var vI = 0, vJ = pmStr.length - 1;
			while (pmStr.charAt(vI) == ' ') vI++;
			while (pmStr.charAt(vJ) == ' ') vJ--;
			vJ++;
		
		//#-- return string with removed spaces
			return pmStr.substring(vI, vJ);
	} //#-- close of trim()
