PLM.init(function(){
  // Submit form via ajax to either follow or unfollow another member.
  function submitFollowForm(e) {
    e.stop();
    var form = e.element().up('form');
    var all_forms = 'form[action='+form.action+']';
    all_forms = all_forms.replace(/http:\/\/[^\/]+/,'');    
    $$(all_forms).each(function(f) {      
      f.down('.prompt').replace('<span class="helptext">Please wait&hellip;</span>');
    })
    new PLM.Ajax.ReplaceAll(all_forms, form.action, {
      method: form.method,
      parameters: form.serialize()
    });
  }

  function showFollowToolTip(e) {
    e.stop();
    var helpText = e.element().getAttribute('title');
    showToolTip('toolTip', e.element(), -65, 30, helpText);
  }

  $$('body').first().observe('click', Event.delegate({
    'form.follow .prompt .subscribe': submitFollowForm,
    'a.follow-tip' : showFollowToolTip
  }));

});
