

EmailHandler =
{

    processInput : function( p_doc )
    {
        var fullName_ = p_doc.getElementsByName( "full_name" )[ 0 ].value;
        var email_    = p_doc.getElementsByName( "email"    )[ 0 ].value;
        var message_  = p_doc.getElementsByName( "message"  )[ 0 ].value;
        
        
        if (  fullName_.length == 0  ||  email_.length == 0  ||  message_.length == 0  )
            return "Blank input";
        
        
        if (  ! this.checkForInvalidChars( fullName_ )  ||
              ! this.checkForInvalidChars( email_    )  )
           return "Invalid characters";

        
        try
        {
            var xmlHttpReq_ = new XMLHttpRequest(); 

            if ( xmlHttpReq_ )
            {
                xmlHttpReq_.open( 'POST', '/php/email_processor.php', false );
                xmlHttpReq_.setRequestHeader( 'Content-type', 'application/x-www-form-urlencoded' )
                xmlHttpReq_.send(  encodeURI( 'full_name=' + fullName_ + '&email=' + email_ + '&message=' + message_ )  );
                
                return xmlHttpReq_.responseText;
            }  
        }
        
        catch ( p_e )
        {
            return "Unidentified error";
        }
    },
    
    
    
    checkForInvalidChars : function( p_input )
    {      
        return (  p_input.indexOf( "\"" ) < 0  );       
    }


}


