Added AJAX data calls -- significantly cleaned up JavaScript code