// JavaScript should be made compatible with libraries other than jQuery by
// wrapping it with an "anonymous closure". See:
// - https://drupal.org/node/1446420
// - http://www.adequatelygood.com/2010/3/JavaScript-Module-Pattern-In-Depth

/**
 * @file
 * Feedback form
 *
 * Adds functionality to scroll down the page and open feedback form
 */
(function ($, Drupal, window, document) {
  'use strict';
  
  $( document ).ready(function() {
    if ($("#block-website-feedback-form").length){
   
      $('.nv-h-l-i a[href="mailto:311supervisors@boston.gov"]').attr('id', '311-feedback');
      var feedbackform_old = document.getElementById("311-feedback");
      var feedbackform_new = feedbackform_old.cloneNode(true);
      feedbackform_old.parentNode.replaceChild(feedbackform_new, feedbackform_old);
    
      $('#311-feedback').click(function(ev) {
        ev.preventDefault()
        $('html, body').animate({scrollTop:$(document).height()}, 'slow');
      })
    }
    else { }
  })
 
    
})(jQuery, Drupal, this, this.document);