var svnwikiRating = new Object();

svnwikiRating.vote = function ( direction, file, id ) {
  var content = document.getElementById(id);
  svnwikiJavascript.cleanContent(content);
  content.appendChild(svnwikiJavascript.makeElement('i', document.createTextNode("Updating...")));
  svnwikiJavascript.loadXml(svnwikiRating.url + file + "?action=extension&extension=rating&vote=" + direction, function (x) { svnwikiRating.updateStats(x, id); });
}

svnwikiRating.updateStats = function ( xmlDoc, id ) {
  var content = document.getElementById(id);
  svnwikiJavascript.cleanContent(content);
  var data = xmlDoc.getElementsByTagName('data');
  if (data && data[0]) {
    content.appendChild(document.createTextNode('Rating: '));
    content.appendChild(svnwikiJavascript.makeElement('b', document.createTextNode(data[0].getAttribute('score') || data[0].getAttribute('rating'))));
    votes = data[0].getAttribute('votes');
    if (votes) {
      content.appendChild(document.createTextNode(' ('));
      content.appendChild(document.createTextNode(votes));
      content.appendChild(document.createTextNode(' votes)'));
    }
  }
}