/**
* ScrollTo
* - event.data.scrollTarget
*   The element to scroll to, passed in with the event object
* - Acquia object is created if it doesn't exist and a theme object built or referenced
*   if it exists to store the functions for this theme.
*/
var Acquia = Acquia || {};
Acquia.theme = Acquia.theme || {}; 

Acquia.theme.scrollTo = function (event) {
  event.preventDefault(); // Keep the page from jumping to the hash target
  
  var targetOffset = event.data.scrollTarget.offset().top;
  jQuery('html,body')
  .animate({scrollTop: targetOffset}, 1000);
}

/**
* Document ready handler.
*
*/
jQuery(document).ready(function () {
  var addCommentTrigger = jQuery('.comment_add');
  var addCommentForm = jQuery('#comment-new');
  
  if (addCommentForm.size() > 0) { // Add only if the comment form exists on the page.
    addCommentTrigger.bind('click', {scrollTarget: addCommentForm}, Acquia.theme.scrollTo); // Bind click event handlers to all .comment_add links
  }
});
;

