/* validate client email */
function ClientEmailValidate(oSrc, args)
{
	try
	{
		//check if the emailID is valid
		//alert(args.Value);

		if(checkEmail(args.Value))
		{
			args.IsValid = true;
		}
		else
		{
			args.IsValid = false;
		}
	}
	catch(e)
	{
	
	}	
}    

/* Validate Client Contact Preferences */
function ClientPreferenceValidate(oSrc, args)
{
	try
	{
		//check if one of the chek
		
		if(checkEmail(args.Value))
		{
			args.IsValid = true;
		}
		else
		{
			args.IsValid = false;
		}
	}
	catch(e)
	{
	
	}	
} 

/* Check email address format */
function checkEmail(emailID) 
{
	emailID = trim(emailID);
	//if (/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/.test(emailID))
	if (/^\w+([-+.']\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*$/.test(emailID))
	{
		return (true)
	}
return (false)
}

/* User Comment validations */
function ClientCommentValidate(oSrc, args)
{
	try
	{
		args.IsValid = true;
	}
	catch(e)
	{
	
	}	
}    

/* trim the leading, trailing spaces */
function trim(s) {
  while (s.substring(0,1) == ' ') {
    s = s.substring(1,s.length);
  }
  while (s.substring(s.length-1,s.length) == ' ') {
    s = s.substring(0,s.length-1);
  }
  return s;
}
