function updateMetric(user_id, metric_id, value, do_help)
{
  // TODO: Coalesce updates by queueing, so if we rapid-fire update all 10
  // of our metrics within 5-10 seconds, we update all in one request rather than
  // 10 seperate requests
  $.post("/metric/update", {metric_id: metric_id, value: value});
  var cacheBreaker = new Date().getTime().toString();
  $("#graph_image").attr("src", '/graph/user/' + user_id +'.png?' + cacheBreaker);
  
  if (do_help == true){
    $('#help_text').html("")
    $('#help_title').html("Wasn't That Easy?")

    if (value < 5 && metric_id == 1) {
      $('#help_text').html("<p>Sorry you're having a bad day.</p>")
    }

    if (value > 5 && metric_id == 1) {
      $('#help_text').html("<p>Good to hear you're having a good day!</p>")
    }

    $('#help_text').html($('#help_text').html() + ' <p>If you change your mind or your mood, you can readjust the slider accordingly. After a couple days of entering data, you\'ll be able to view trends on your graph.</p>')
  }
}

jQuery.ajaxSetup({ 
  'beforeSend': function(xhr) {xhr.setRequestHeader("Accept", "text/javascript")} 
})

$(document).ready(function(){
  // global Ajax callbacks, toggle the activity indicator
  $("#activity").ajaxStart(function(){
    $(this).show();
  });

  $("#activity").ajaxStop(function(){
    $(this).hide();
  });

  // Submit up/down vote links as JS
  $(".feature .vote a").click(function(){
    $.ajax({
      url: this.href,
      method: "post",
      dataType: "script",
      beforeSend: function(xhr) {xhr.setRequestHeader("Accept", "text/javascript");}
    });
    return false;
  });
});