function ProcessEmailValidationResult(response,obj)
{
    if (response!="VALID")
    {
       alert ("There is a problem with the email address. There should be no spaces, < > ? & etc.\n\nLetters, numbers,+ . _ and - are allowed, followed by @ and the domain name of your service provider.");
      obj.IsValid=false;                    
    }
    else
    {
       obj.IsValid=true;                    
     }
}

function tcmEmailValidation (path,async)
{   
   this.DefaultPath=path; 
   ajaxRequest = tcmXHR.createRequest();
   this.IsValid=false;
   this.email="";
   this.async=async;
   this.checkEmail=function (email) 
   {
        this.email=email;
        if (this.async)
        {
           ajaxRequest.onreadystatechange = function()
           {
               if(ajaxRequest.readyState == 4)
               {
                   if (ajaxRequest.status == 200)
                   { 
                      ProcessEmailValidationResult(ajaxRequest.responseText,this);
                   }
                   else
                   {
                       this.IsValid=false;                    
                      // alert("Unable to get response!: " + ajaxRequest.responseText);
                   }
               }
           }
        }
        ajaxpath=this.DefaultPath+"chkEmail.php?email=" + encodeURIComponent(this.email);
        ajaxRequest.open("GET", ajaxpath,this.async);
        ajaxRequest.send(null);
        if (!this.async) 
        {
           ProcessEmailValidationResult(ajaxRequest.responseText,this);
           return this.IsValid;
        }
        else
           return false;
   };
}

