clean up the sharing ajax calls, add mail notification class

Cleaning up the ajax calls for sharing and moved the code to send mail notifications to a separate class.