/**
 * Add a member impact.
 */
function articleVote(articleId, vote) {
  if (!hasSession) {
    showStatusError("Not logged in.");
    return;
  }

  if (articleId == null) {
    alert("Error");
    return;
  }

  showStatusWorking("Voting...");

  var sUrl = websiteRoot + "/ajax/article_vote.php?article_id=" + articleId + "&vote=" + vote;
  $.ajax({
      url: sUrl,
      type: 'GET',
      dataType: 'html',
      timeout: 10000,
      error: function(request, errMsg, errObj) {
        if (request.responseText == "1") {
          showStatusError("Error voting.");
        } else {
          showStatusError("Already voted on this article.");
        }
      },
      success: function(html){
	  showStatusComplete("Vote recorded.");
          var curScore = parseInt($("#articleVoteScore" + articleId).html());
          $("#articleVoteScore" + articleId).html("" + (curScore+vote));
      }
  });
}

/**
 * Show a counter of the length of the article description.
 */
function showDescriptionCount() {
    var textArea = document.getElementById("articleSubmitDesc");
    var text = textArea.value;
    $("#articleDescriptionCount").text("Length: " + text.length + " / 255");
}

