/**
 * @author Caroline Schnapp
 */
// $Id: jquery.plus1.js,v 1.1.4.2 2008/09/10 20:25:33 chill35 Exp $
// Global killswitch: only run if we are in a supported browser.
if (Drupal.jsEnabled) {
  jQuery(function(){
    jQuery('.'+ Drupal.settings.plus1.widget_class).each(function(){
      var plus1_widget = jQuery(this);
      plus1_widget.find('.'+ Drupal.settings.plus1.link_class).attr('href', function(){ return jQuery(this).attr('href') + '/json'; }).click(function(){
        jQuery.getJSON(jQuery(this).attr('href'), function(json){
          plus1_widget.find('.'+ Drupal.settings.plus1.score_class).hide().fadeIn('slow').html(json.score);
          plus1_widget.find('div.plus1-msg').addClass('plus1-voted');
          plus1_widget.find('div.plus1-msg').find('div.plus1-vote').removeClass('plus1-vote');
          plus1_widget.find('.'+ Drupal.settings.plus1.message_class).html(json.voted);
        });
        return false;
      });
    });
  });
}
